MCP Tools
Overview
MCP (Model Context Protocol) tools allow agents to use standardized external tools provided by MCP servers. This enables seamless integration with a wide ecosystem of tools and services.
Quick Start
Please see https://github.com/GongRzhe/Gmail-MCP-Server for more details on setting up OAuth
csharp
MCPServer gmailServer = new MCPServer(
serverLabel:"gmail",
command: "npx",
arguments: new[] { "@gongrzhe/server-gmail-autoauth-mcp" },
allowedTools: [
"read_email",
"draft_email",
"search_emails"]);
await gmailServer.InitializeAsync(); // This will handle MCP Client connection to setup tools
TornadoAgent agent = new TornadoAgent(
client,
model: ChatModel.OpenAi.Gpt41.V41Mini,
instructions: "You are a useful assistant for managing Gmail."
);
agent.AddMcpTools(gmailServer.AllowedTornadoTools.ToArray()); // Register MCP tools to the agent
Conversation result = await agent.RunAsync("Did mom respond?");
Console.WriteLine(result.Messages.Last().Content);HTTP Transport Configuration
To connect to an MCP server over HTTP, configure the transport settings as follows:
csharp
MCPServer server = new MCPServer("github", "https://api.githubcopilot.com/mcp", additionalConnectionHeaders: new Dictionary<string, string>
{
{ "Authorization", $"Bearer {githubApiKey}" }
},
allowedTools:allowedTools);
await server.InitializeAsync(); // This will handle MCP Client connection to setup tools
TornadoAgent agent = new TornadoAgent(
client,
model: ChatModel.OpenAi.Gpt41.V41Mini,
instructions: "You are a useful assistant for managing Github."
);
agent.AddMcpTools(server.AllowedTornadoTools.ToArray()); // Register MCP tools to the agent
Conversation result = await agent.RunAsync("What repos do I have?");
Console.WriteLine(result.Messages.Last().Content);Server Management
Error Handling
Common Issues
MCP Server Not Responding
Solutions:
- Verify server is running
- Check transport configuration
- Ensure network connectivity
- Review server logs
Tools Not Available
Solutions:
- Confirm MCP server has tools registered
- Check agent initialization succeeded
- Verify server is compatible with protocol version
Tool Execution Fails
Solutions:
- Validate tool parameters
- Check server error logs
- Ensure required dependencies are available
- Test tools independently