Add experimental Server Cards support (SEP-2127)#2696
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.
|
Is this SEP going to be in the current spec release? Otherwise maybe this PR should be draft |
|
@maxisbey the Server Card SEP as been moved to proposing an extension and it's almost ready, I agree I think it would be reasonable to leave the experimental PR as a draft, but I think the majority of blockers are now done, and likely the SEP will be up for review shortly. |
|
@SamMorrowDrums hmm would it make more sense for this to be marked as an extension in the SDK rather than experimental? Currently experimental is only for Tasks (which will soon be fully deleted form the SDK anyway). If it does make sense as an extension then we also need to figure out a proper way to put extensions in the SDK as currently it's not possible (can't edit capabilities), but all that will definitely be coming with v2 release :) |
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).