fix: Mock tooling server MCP protocol compliance for Python/Node.js agents#263
Merged
sellakumaran merged 2 commits intomicrosoft:mainfrom Feb 17, 2026
Conversation
The mock tooling server's JSON-RPC handler at /agents/servers/{mcpServerName}
only handled initialize, logging/setLevel, tools/list, and tools/call methods.
Python and Node.js MCP clients send additional standard MCP methods during
connection setup, causing unhandled exceptions and 500 errors.
Changes:
- Handle notifications/* with 202 Accepted (MCP Streamable HTTP spec)
- Handle ping with empty result (connection health check)
- Handle prompts/list with empty prompts array
- Handle resources/list with empty resources array
- Catch ArgumentException for unknown MCP server names in tools/list
and tools/call (return empty tools / JSON-RPC error instead of crash)
- Move idValue declaration before try block so catch handler preserves
the request id (was null)
Fixes microsoft#262
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes MCP protocol compliance issues in the mock tooling server that prevented Python and Node.js Agent Framework samples from connecting. The .NET samples worked because they didn't send certain standard MCP methods, but Python/Node.js MCP client libraries follow the full MCP Streamable HTTP specification and were encountering HTTP 500 errors on unhandled methods.
Changes:
- Added handlers for standard MCP methods (
ping,prompts/list,resources/list) that Python/Node.js clients send during connection setup - Implemented proper MCP notification handling (returning 202 Accepted for
notifications/*methods) - Added graceful error handling for unknown MCP server names in
tools/listandtools/call - Fixed JSON-RPC response id field preservation in error responses by moving
idValuedeclaration before try block
Fixes CR-263-001 through CR-263-007 from code review. Changes: 1. Extract JSON-RPC error codes to constants (CR-263-003) - Created JsonRpcConstants.cs with error codes and HTTP status codes - Replaced all magic numbers (-32601, -32602, -32603, 202) with named constants - Added XML documentation explaining each constant's purpose 2. Fix inconsistent error handling in tools/list (CR-263-002) - Changed tools/list to return JSON-RPC error instead of empty tools list for unknown MCP servers - Now consistent with tools/call behavior - Prevents misleading clients about server existence 3. Include exception in log.LogWarning calls (CR-263-007) - Added exception parameter to both tools/list and tools/call catch blocks - Follows .NET logging best practices for better debugging 4. Document null handling contract (CR-263-005) - Added comment explaining that 'method' field validation ensures non-null in subsequent code - Clarifies the null safety contract for maintainers 5. Add comment explaining idValue scope decision (CR-263-006) - Documents why idValue is declared outside try block - Ensures error responses include correct request ID 6. Add unit tests for constants (CR-263-001) - Created JsonRpcConstantsTests.cs with 7 tests - Validates error codes match JSON-RPC 2.0 specification - Documents intended use of each error code - Note: Full integration tests require server infrastructure setup (follow-up) All changes maintain backward compatibility and follow repository coding standards. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
sellakumaran
approved these changes
Feb 17, 2026
ajmfehr
approved these changes
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #262
The mock tooling server's JSON-RPC handler at
/agents/servers/{mcpServerName}only handledinitialize,logging/setLevel,tools/list, andtools/callmethods. Python and Node.js MCP clients send additional standard MCP methods during connection setup (ping,notifications/initialized,prompts/list,resources/list), causing unhandled exceptions and HTTP 500 errors that prevent these agents from connecting.Changes
6 fixes in
Server.cs(50 insertions, 10 deletions):notifications/*- Return202 Acceptedper MCP Streamable HTTP spec (was returning JSON-RPC error)ping- Return empty result{}for connection health checks (was method-not-found)prompts/list- Return{ prompts: [] }(was error)resources/list- Return{ resources: [] }(was error)ArgumentExceptionintools/listandtools/call; return empty tools list / JSON-RPC error instead of unhandled crashidValuescope fix - Moved declaration beforetryblock so thecatchhandler preserves the original request id (wasnull)Testing
microsoft/Agent365-Samples) successfully connects to mock tooling server, discovers tools, and executes tool calls after these fixesServer.cs(existing tests cover CLI command parsing only). Integration tests could be added as a follow-up.Risk Assessment