-
-
Notifications
You must be signed in to change notification settings - Fork 13
ModelContextProtocol
Rasmus Wulff Jensen edited this page May 20, 2026
·
1 revision
The AgentFrameworkToolkit.Tools.ModelContextProtocol package adds helpers for consuming MCP servers as AITool instances.
dotnet add package AgentFrameworkToolkit.Tools.ModelContextProtocol
AIToolsFactory aiToolsFactory = new();
await using McpClientTools remoteMcpClient =
await aiToolsFactory.GetToolsFromRemoteMcpAsync("https://mcp.example.com");
IList<AITool> remoteMcpTools = remoteMcpClient.Tools;AIToolsFactory aiToolsFactory = new();
await using McpClientTools localMcpClient =
await aiToolsFactory.GetToolsFromLocalMcpAsync("npx", ["@playwright/mcp@latest"]);
IList<AITool> localMcpTools = localMcpClient.Tools;The returned tools can be used with Agent Framework Toolkit agents or regular Microsoft Agent Framework AIAgent instances.
OpenAIAgent agent = agentFactory.CreateAgent(new AgentOptions
{
Model = "gpt-5",
Tools = remoteMcpTools
});Warning
Keep the McpClientTools instance alive while the tools are in use and dispose it with await using when finished.
- See AIToolsFactory for the provider-independent tool factory.
- See CommonTools for built-in tools that do not require MCP.