Skip to main content

9 posts tagged with "MCP"

Model Context Protocol (MCP), the Open Standard That Gives AI Agents Tools and Data from MCP Servers

View All Tags

Fixed: KeyNotFoundException: The given key was not present in the dictionary when reading Microsoft Learn MCP search results

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

A C# program that read the excerpt of every result of the Microsoft Learn MCP server's search stopped at the fifth one with KeyNotFoundException: The given key was not present in the dictionary. The search used maxTokenBudget, and with a budget, the server leaves out the excerpts that don't fit and marks those results with content_omitted. Reading the excerpt with TryGetProperty fixed it.

How to Call an MCP Tool from C#

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

MCP tools are usually called by an AI model, but your own code can call them too, which is the quickest way to see what a tool really returns. This guide calls a tool of a remote MCP server from C#, checks whether it worked, and reads its result.

Fixed: warning CS8602: Dereference of a possibly null reference on McpClient.ServerInfo

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

Writing the name of an MCP server with client.ServerInfo.Name turned a clean build into warning CS8602: Dereference of a possibly null reference. In the MCP C# SDK, McpClient.ServerInfo is nullable, because a server that connects with the protocol's newest handshake doesn't have to describe itself. A null check with a pattern fixed the warning without hiding that case.

Fixed: Tool not found in cache during tools/call. Mcp-Param-* headers will not be sent

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

Calling an MCP server's tool by name with the MCP C# SDK logged Tool 'microsoft_docs_search' not found in cache during tools/call. Mcp-Param-* headers will not be sent. Call AddKnownTools or ListToolsAsync to populate the cache. The call still worked. The client didn't know the tool yet, so it couldn't check whether the server wanted some of its arguments copied into HTTP headers. Listing the tools first, and calling the tool from that list, fixed it.

Fixed: Request failed for method 'server/discover': Method 'server/discover' is not available (-32601)

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

Connecting to the Microsoft Learn MCP server with the MCP C# SDK logged warn: … request failed for method 'server/discover': Method 'server/discover' is not available. (-32601). and then connected anyway. The SDK first tries the newest revision of the protocol, which the server doesn't support yet, and falls back. Setting McpClientOptions.ProtocolVersion to the version the server speaks stopped the probe and the warning.