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

@ -2,7 +2,8 @@
Meta is opaque pass-through data, so these tests assert identity against the value that was sent
rather than snapshotting a literal: the expected value and the sent value are the same variable,
which also proves the SDK injected nothing alongside it.
which also proves the SDK injected nothing alongside it beyond the 2026-era serverInfo stamp,
stripped via `unstamped` before comparison.
"""
import mcp_types as types
@ -10,6 +11,7 @@ import pytest
from mcp_types import CallToolResult, RequestParamsMeta, TextContent
from mcp.server import Server, ServerRequestContext
from tests._stamp import Unstamp
from tests.interaction._connect import Connect
from tests.interaction._requirements import requirement
@ -42,7 +44,7 @@ async def test_request_meta_reaches_handler(connect: Connect) -> None:
@requirement("meta:result-to-client")
async def test_result_meta_reaches_client(connect: Connect) -> None:
async def test_result_meta_reaches_client(connect: Connect, unstamped: Unstamp) -> None:
"""The _meta object a handler attaches to its result is delivered to the client unchanged."""
result_meta = {"example.com/cost": 3}
@ -60,4 +62,4 @@ async def test_result_meta_reaches_client(connect: Connect) -> None:
async with connect(server) as client:
result = await client.call_tool("metered", {})
assert result == CallToolResult(content=[TextContent(text="done")], _meta=result_meta)
assert unstamped(result) == CallToolResult(content=[TextContent(text="done")], _meta=result_meta)