Add experimental Server Cards support (SEP-2127)#2696
Open
dsp-ant wants to merge 1 commit into
Open
Conversation
Adds SDK support for MCP Server Cards: static metadata documents that describe a remote server's identity, transport endpoints, and supported protocol versions for pre-connection discovery. - mcp.shared.experimental.server_card: Pydantic models (ServerCard, Server, Remote, Package, ...) mirroring mcp.types conventions and validating purely through Pydantic. - mcp.server.experimental.server_card: build_server_card derives a card from a server's identity; server_card_route / mount_server_card serve it from a Starlette app at /.well-known/mcp/server-card. - mcp.client.experimental.server_card: fetch_server_card / load_server_card / well_known_url ingest and validate a card. Full test coverage for the new modules.
Contributor
|
Is this SEP going to be in the current spec release? Otherwise maybe this PR should be draft |
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
Adds first-class SDK support for MCP Server Cards (SEP-2127) under the experimental namespaces, so:
A Server Card is a static metadata document (typically at
https://<host>/.well-known/mcp/server-card) describing a remote server's identity, transport endpoints, and supported protocol versions. It deliberately omits primitive listings (tools/resources/prompts), which stay subject to runtime listing.API
Layout
mcp.shared.experimental.server_cardServerCard,Server,Remote,Package, transports, args, ...), mirroringmcp.typesconventions (camelCase wire format, reusesIcon)mcp.server.experimental.server_cardbuild_server_card(derive from a server's identity) +server_card_route/mount_server_card(Starlette)mcp.client.experimental.server_cardfetch_server_card/load_server_card/well_known_urlDesign notes
mcp.types— no separate JSON-Schema/CLI layer. Malformed cards raisepydantic.ValidationError; version ranges (which the field pattern can't express) are rejected by a validator.$schemadefaults to the canonical v1 URL so generation needs no boilerplate; ingestion is lenient about a missing$schema.ServerCardvsServer(registryserver.json) split matches the spec;Serveraddspackages.mcpAPI surface.Tests
tests/experimental/server_card/; 100% line + branch coverage on the three new modules (verified withstrict-no-cover).ruff+pyrightclean.Serverwith a package); server→client verified end-to-end over an in-memory ASGI transport.Supersedes #2692 (which added this only as a standalone example app).