Align with spec #3002: optional clientInfo, serverInfo in result _meta (#3143)

This commit is contained in:
Max 2026-07-23 12:00:36 +01:00 • committed by GitHub
commit 837ef904f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,23 @@
"""Shared helpers for the docs_src tests."""
from typing import TypeVar
from mcp_types import SERVER_INFO_META_KEY, Result
from mcp.server import Server
from mcp.server.mcpserver import MCPServer
R = TypeVar("R", bound=Result)
def strip_server_info(result: R, server: Server | MCPServer) -> R:
"""Assert the 2026-era serverInfo stamp, then drop it so snapshots stay focused.
The doc snippets set no explicit version, so the stamp's version is empty;
the fenced outputs in the docs pages leave the stamp out, and the tests
mirror the fences.
"""
assert result.meta is not None
assert result.meta[SERVER_INFO_META_KEY] == {"name": server.name, "version": ""}
result.meta = None
return result