You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We leverage the same API as MCP server builder by adding our own WithTools<TTools> for now.
The notes agent sample is extended to showcase custom AIContextProvider (that injects the current notes as instructions) and an MCPTool method (save_notes) to mutate them as needed by the agent.
Copy file name to clipboardExpand all lines: src/Agents/ConfigurableAIAgent.cs
+13-12Lines changed: 13 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,9 @@
1
-
usingSystem.ComponentModel;
1
+
usingSystem;
2
+
usingSystem.ComponentModel;
2
3
usingSystem.Diagnostics;
4
+
usingSystem.Diagnostics.CodeAnalysis;
5
+
usingSystem.Linq.Expressions;
6
+
usingSystem.Reflection;
3
7
usingSystem.Text.Json;
4
8
usingDevlooped.Extensions.AI;
5
9
usingDevlooped.Extensions.AI.Grok;
@@ -8,6 +12,7 @@
8
12
usingMicrosoft.Extensions.Configuration;
9
13
usingMicrosoft.Extensions.DependencyInjection;
10
14
usingMicrosoft.Extensions.Logging;
15
+
usingModelContextProtocol.Server;
11
16
12
17
namespaceDevlooped.Agents.AI;
13
18
@@ -134,21 +139,17 @@ public override IAsyncEnumerable<AgentRunResponseUpdate> RunStreamingAsync(IEnum
134
139
135
140
if(contextFactoryis not null)
136
141
{
137
-
if(options.Use?.Count>0)
138
-
thrownewInvalidOperationException($"Invalid simultaneous use of keyed service {nameof(AIContextProviderFactory)} and '{section}:use' in configuration.");
142
+
if(options.Use?.Count>0||options.Tools?.Count>0)
143
+
thrownewInvalidOperationException($"Invalid simultaneous use of keyed service {nameof(AIContextProviderFactory)} and '{section}:use/tools' in configuration.");
thrownewInvalidOperationException($"Specified tool '{toolName}' for agent '{section}' is not registered as a keyed {nameof(AITool)} or {nameof(AIFunction)}.");
200
+
thrownewInvalidOperationException($"Specified tool '{toolName}' for agent '{section}' is not registered as a keyed {nameof(AITool)}, {nameof(AIFunction)} or MCP server tools.");
0 commit comments