Fix unknown-method error code and add a protocol version registry (#2836)
This commit is contained in:
parent
1e21814ed5
commit
7267818e44
2 changed files with 430 additions and 23 deletions
|
|
@ -819,6 +819,24 @@ class TestProtectedResourceMetadata:
|
|||
assert "resource=" in content
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("protocol_version", "expected"),
|
||||
[
|
||||
("2025-03-26", False),
|
||||
("2025-06-18", True),
|
||||
("2025-11-25", True),
|
||||
# Unrecognized strings gate conservatively, even ones sorting after 2025-06-18.
|
||||
("zzz", False),
|
||||
("9999-99-99", False),
|
||||
],
|
||||
)
|
||||
def test_should_include_resource_param_by_protocol_version(
|
||||
oauth_provider: OAuthClientProvider, protocol_version: str, expected: bool
|
||||
) -> None:
|
||||
"""Resource param is included only for recognized versions >= 2025-06-18."""
|
||||
assert oauth_provider.context.should_include_resource_param(protocol_version) is expected
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_validate_resource_rejects_mismatched_resource(
|
||||
client_metadata: OAuthClientMetadata, mock_storage: MockTokenStorage
|
||||
|
|
|
|||
|
|
@ -113,6 +113,12 @@ async def test_client_is_initialized(app: MCPServer):
|
|||
assert client.initialize_result.server_info.name == "test"
|
||||
|
||||
|
||||
async def test_client_initialize_result_exposes_negotiated_protocol_version(app: MCPServer):
|
||||
"""The negotiated protocol version is readable after initialization."""
|
||||
async with Client(app) as client:
|
||||
assert client.initialize_result.protocol_version == types.LATEST_PROTOCOL_VERSION
|
||||
|
||||
|
||||
async def test_client_with_simple_server(simple_server: Server):
|
||||
"""Test that from_server works with a basic Server instance."""
|
||||
async with Client(simple_server) as client:
|
||||
|
|
|
|||
Loading…
Reference in a new issue