Skip to content

Improvement MCP server for OAuth flow#205

Open
bettercallsaulj wants to merge 4 commits intofix/improve_for_mcp_inspectorfrom
fix/improve_for_mcp_oauth
Open

Improvement MCP server for OAuth flow#205
bettercallsaulj wants to merge 4 commits intofix/improve_for_mcp_inspectorfrom
fix/improve_for_mcp_oauth

Conversation

@bettercallsaulj
Copy link
Collaborator

This PR must be merged after #201

RahulHere added 4 commits March 8, 2026 16:09
The handleCallTool function was manually building a response with
content as a plain string, which violates the MCP protocol spec.
MCP requires content to be an array of content blocks with type/text.

Before: {"content": "Hello", "isError": false}
After:  {"content": [{"type": "text", "text": "Hello"}]}

Changes:
- Use json::to_json(result) to properly serialize CallToolResult
- Add unit tests for MCP format compliance
#203)

The HTTP routing filter now properly handles POST/PUT/PATCH requests by
accumulating the request body before calling the handler. Previously,
handlers were called immediately in onHeaders without access to the body.

Additionally, the filter now strips query strings from paths for routing
purposes while still providing the full URL (with query string) to handlers.

Changes:
- Add state variables for pending POST requests and body accumulation
- Defer POST/PUT/PATCH handler execution until onMessageComplete
- Strip query strings in extractPath for route matching
- Provide full URL with query string in RequestContext.path
- Add unit tests for POST body handling and query string routing
This commit adds two extensibility features to the HTTP/SSE filter chain,
using the existing FilterFactoryCb pattern for consistency:

1. Filter factory support: Allows adding custom filter factories that run
   before protocol filters (HTTP/SSE/JSON-RPC). Useful for authentication,
   logging, and other cross-cutting concerns. Uses addFilterFactory() which
   matches the existing pattern in FilterChainFactoryImpl.

2. Route registration callback: Allows registering custom HTTP endpoints
   when the filter chain is created. Useful for OAuth discovery endpoints,
   health checks, and other custom routes.

Changes:
- Add HttpRouteRegistrationCallback type for route registration
- Add addFilterFactory() and getFilterFactories() to HttpSseFilterChainFactory
- Add setRouteRegistrationCallback() to HttpSseFilterChainFactory
- Add filter_factories and route_registration_callback to McpServerConfig
- Update McpServer to apply config options to filter chain factory
- Add unit tests for filter factory and route callback functionality
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant