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
2 changed files with 1757 additions and 567 deletions

View file

@ -30,7 +30,9 @@ leg fails there today — run over `--http`.
at construction; no date strings appear in the body.
- `client.py` — `client.protocol_version` / `client.server_info` /
`client.server_capabilities` are era-neutral: populated by `initialize` *or*
`server/discover`, whichever ran.
`server/discover`, whichever ran. On the 2026 era `server_info` comes from
the optional `serverInfo` `_meta` stamp (`None` for a server that does not
identify itself); `initialize` always carries it.
- `server.py` — `ctx.request_context.protocol_version` is the era branch key
(lowlevel: `ctx.protocol_version` directly). Compare against
`MODERN_PROTOCOL_VERSIONS`, never a date literal.

View file

@ -13,7 +13,11 @@ async def main(targets: TargetFactory, *, mode: str = "auto") -> None:
# The version/info/capabilities accessors are era-neutral.
async with Client(targets(), mode=mode) as modern:
assert modern.protocol_version == LATEST_MODERN_VERSION
assert modern.server_info.name == "dual-era-example"
# On the 2026 era, server identity is an optional serverInfo stamp in the
# result _meta (None for an anonymous server); this server stamps it.
info = modern.server_info
assert info is not None, "the server stamps serverInfo into its results"
assert info.name == "dual-era-example"
assert modern.server_capabilities.tools is not None
listed = await modern.list_tools()
@ -28,7 +32,9 @@ async def main(targets: TargetFactory, *, mode: str = "auto") -> None:
# The same accessors are populated identically — here by ``initialize``.
async with Client(targets(), mode="legacy") as legacy:
assert legacy.protocol_version == LATEST_HANDSHAKE_VERSION
assert legacy.server_info.name == "dual-era-example"
info = legacy.server_info
assert info is not None, "initialize always carries serverInfo"
assert info.name == "dual-era-example"
assert legacy.server_capabilities.tools is not None
result = await legacy.call_tool("greet", {"name": "2025 client"})