Status: Experimental. This repository provides a multi-language reference implementation of the variants proposal for the Model Context Protocol (MCP), as described in SEP-2053.
by modelcontextprotocolGo
Last 12 weeks ยท 7 commits
5 of 6 standards met
Add four new example servers demonstrating different SEP-2053 variant patterns: model-optimized (same tools, different descriptions per LLM family) trading (API versioning with deprecation lifecycle) research (context budget management) Refactor the existing variants-http example into a GitHub-style server with custom ranking.
Repository: modelcontextprotocol/experimental-ext-variants. Description: Status: Experimental. This repository provides a multi-language reference implementation of the variants proposal for the Model Context Protocol (MCP), as described in SEP-2053. Stars: 5, Forks: 1. Primary language: Go. Languages: Go (98%), Python (0.9%), TypeScript (0.9%), JavaScript (0.2%). License: Apache-2.0. Topics: experimental, extension. Open PRs: 1, open issues: 0. Last activity: 4d ago. Community health: 87%. Top contributors: Degiorgio, sambhav.
Summary Builds on the types and architecture from the previous PR to deliver a working variant-aware MCP server that routes requests to inner mcp.Server instances based on per-request _meta variant selection, enabling a single MCP endpoint to serve multiple tool/resource/prompt variants simultaneously. Key additions Backend abstraction (inMemoryBackend) โ creates in-memory transport pairs between the variant server and inner mcp.Server instances, with notification forwarding for progress and logging events. Request dispatcher (dispatch.go) โ handles routing for tools/list, tools/call, resources/list, resources/read, resources/subscribe, prompts/list, prompts/get, and completion/complete methods. Implements variant-scoped cursor wrapping to correctly paginate across multiple inner servers. Session middleware (session.go) โ manages per-session inner connections in stateful mode and shared connections in stateless HTTP mode, ensuring proper lifecycle management. Initialize enrichment โ injects availableVariants into the server's capabilities response so clients can discover which variants are available. Capability discovery โ merges inner server capabilities via union to present a unified capability set to clients. NewStreamableHTTPHandler โ provides an HTTP handler for multi-client serving over Streamable HTTP transport. Integration tests (server_test.go, 458 lines) โ covers end-to-end variant selection, backward compatibility (no variant specified), HTTP transport, and stateless modes. Examples โ stdio-based (examples/server/variants/main.go) and HTTP-based (examples/server/variants-http/main.go) example servers demonstrating the API. README โ rewritten with API documentation and architecture diagrams. TODO (subsequent PRs): Unit Testing More integration tests
Defines the core types and API for server variants extension, laying groundwork for multi-variant server implementation. Server.Run() is not yet implemented but architecture is designed and documented. Add Server type with variant registration Implement default priority-based ranking Define ServerVariant, VariantHints, and related types per SEP spec Add comprehensive example demonstrating intended multi-variant usage Document implementation plan for Server.Run() dispatch architecture Next PRs: Unit Tests Implementation for Server.Run Conformance Testing