-
Notifications
You must be signed in to change notification settings - Fork 135
vMCP: Implement capability merging and routing integration #2376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@claude please review this |
|
Claude finished @JAORMX's task —— View job Code Review CompleteI've completed a thorough review of PR #2376. The implementation is solid and well-tested. Below are my findings organized by category. Overall AssessmentSummary: This is high-quality code that successfully implements the virtual MCP server capability merging and routing system. The architecture is clean, tests are comprehensive, and the code follows Go best practices. I found a few areas for improvement but no blocking issues. Test Results: ✅ All tests passing in both router and server packages Strengths
Issues Found1. Code Organization Violation (CLAUDE.md Guideline)
|
d853588 to
983561a
Compare
578f88b to
b31378c
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2376 +/- ##
==========================================
+ Coverage 54.29% 54.39% +0.09%
==========================================
Files 260 262 +2
Lines 24925 25177 +252
==========================================
+ Hits 13534 13694 +160
- Misses 10100 10178 +78
- Partials 1291 1305 +14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6ea7f3d to
bc80da6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added some minor comments
This completes issue #154 by implementing the final stage of the capability aggregation pipeline: exposing aggregated capabilities via MCP protocol and routing requests to backends. Components added: - Router (pkg/vmcp/router/default_router.go): Thread-safe routing using RWMutex for capability name → backend target mapping. Supports dynamic routing table updates for future backend discovery. - Virtual MCP Server (pkg/vmcp/server/server.go): Aggregates multiple backend MCP servers into unified interface. Uses mark3labs/mcp-go to expose tools/list, resources/list, prompts/list automatically. Routes incoming requests (tools/call, resources/read, prompts/get) to appropriate backends via Router. Features: - Automatic MCP protocol endpoint exposure - Tool/resource/prompt routing with conflict-resolved names - Request forwarding to backends via BackendClient - Streamable HTTP transport support - Graceful startup/shutdown Testing: - Router: 100% test coverage including concurrency tests - Server: Unit tests for configuration, registration, error handling - Integration tests: Full pipeline (Aggregator→Router→Server) - All tests passing, linting clean Architecture: Client → Virtual MCP Server → Router → BackendClient → Backend MCPs (MCP protocol) (routing) (HTTP) (MCP servers) Resolves: #154 Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
Fix points 4 and 5 from review: 4. Extract magic number timeouts to constants: - Add defaultReadHeaderTimeout (10s) for HTTP server security - Add defaultShutdownTimeout (10s) for graceful shutdown - Replace hardcoded values with named constants 5. Fix hardcoded MIME type in resource handler: - Remove hardcoded "text/plain" MIME type - Look up actual MIME type from aggregatedCapabilities.Resources - Use "application/octet-stream" as sensible default for unknown types - No data duplication - reuses existing aggregatedCapabilities This is production-ready: works with ANY resource type (JSON, images, PDFs, etc.) without hardcoding or TODOs. The MIME type comes from the backend's resource metadata and is properly preserved through the aggregation pipeline.
Address yrobla's review feedback: Add nil checks for routing table maps (Tools, Resources, Prompts) in addition to checking if the routing table itself is nil. Changes: - RouteTool: Check routingTable.Tools != nil - RouteResource: Check routingTable.Resources != nil - RoutePrompt: Check routingTable.Prompts != nil Tests added: - Test case for nil Tools map - Test case for nil Resources map - Test case for nil Prompts map This provides defense-in-depth against malformed routing tables and gives clearer error messages when maps are unexpectedly nil.
bc80da6 to
9e51a82
Compare
Add comprehensive HTTP server timeout configuration including ReadTimeout, WriteTimeout, IdleTimeout, and MaxHeaderBytes to prevent resource exhaustion attacks and improve security. Add server startup validation to the integration test to ensure the server actually starts listening on the configured port, not just that it's configured correctly. The test now validates the complete lifecycle including server startup and shutdown. Addresses review feedback from yrobla on PR #2376. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive HTTP server timeout configuration including ReadTimeout, WriteTimeout, IdleTimeout, and MaxHeaderBytes to prevent resource exhaustion attacks and improve security. Add server startup validation to the integration test to ensure the server actually starts listening on the configured port, not just that it's configured correctly. The test now validates the complete lifecycle including server startup and shutdown. Addresses review feedback from yrobla on PR #2376. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
9e51a82 to
0bb2849
Compare
Summary
Implements the final stage of the Virtual MCP Server capability aggregation pipeline: exposing aggregated capabilities via MCP protocol and routing requests to appropriate backends.
This PR completes the Virtual MCP Server implementation by adding:
Architecture
Data Flow
AggregatedCapabilitieswithRoutingTableWhat's Included
1. Router (
pkg/vmcp/router/)Purpose: Maps capability names/URIs to backend targets for request routing.
Implementation (
default_router.go):sync.RWMutex(supports dynamic updates)RouteTool,RouteResource,RoutePromptUpdateRoutingTableDesign Choice - RWMutex vs atomic.Pointer:
2. Virtual MCP Server (
pkg/vmcp/server/)Purpose: Aggregates multiple backend MCP servers into a single MCP interface.
Implementation (
server.go):mark3labs/mcp-goSDK for MCP protocol compliancetools/list,resources/list,prompts/listendpointstools/call→ routes by tool nameresources/read→ routes by resource URIprompts/get→ routes by prompt name/mcp)Request Handling Flow:
3. Integration Tests
Full pipeline integration (
server/integration_test.go):Key Features
Capability Registration
Request Routing
RoutingTablefrom aggregation phaseBackendTargetstructs containing:Error Handling
Testing Strategy
Unit Tests
Router (
router/default_router_test.go):Server (
server/server_test.go):Integration Tests
server/integration_test.go):Test Results
Design Decisions
1. Why separate Router from Server?
2. Why use mark3labs/mcp-go SDK?
3. Why handler closures?
4. Why dynamic capability registration?
Example Usage
Client connects to:
http://localhost:4483/mcpImplementation Completeness
This PR implements all requirements for capability merging and routing:
Files Changed
Total: 1,457 lines added (excluding generated mocks)
Checklist
task gen