mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-18 19:44:19 +02:00
Expose configured discovery result
🤖 Generated with OpenAI Codex
This commit is contained in:
parent
c07277fa13
commit
74c7e58ea3
3 changed files with 20 additions and 2 deletions
|
|
@ -657,6 +657,11 @@ class Client(
|
|||
|
||||
return self._session_state.session
|
||||
|
||||
@property
|
||||
def prior_discover(self) -> mcp_types.DiscoverResult | None:
|
||||
"""The configured result to adopt when `mode` pins a modern version."""
|
||||
return self._prior_discover
|
||||
|
||||
@property
|
||||
def initialize_result(self) -> mcp_types.InitializeResult | None:
|
||||
"""Get the result of the initialization request.
|
||||
|
|
|
|||
|
|
@ -1079,7 +1079,7 @@ class ProxyMetadataMiddleware(Middleware):
|
|||
if (
|
||||
not connected
|
||||
and client.mode in MODERN_PROTOCOL_VERSIONS
|
||||
and client._prior_discover is None
|
||||
and client.prior_discover is None
|
||||
):
|
||||
client = client.new()
|
||||
client.mode = "auto"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ from typing import Any
|
|||
import pytest
|
||||
from mcp import ClientSession
|
||||
from mcp.shared.exceptions import MCPError
|
||||
from mcp_types import METHOD_NOT_FOUND
|
||||
from mcp_types import METHOD_NOT_FOUND, DiscoverResult, ServerCapabilities
|
||||
from mcp_types.version import LATEST_HANDSHAKE_VERSION, LATEST_MODERN_VERSION
|
||||
from typing_extensions import Unpack
|
||||
|
||||
|
|
@ -242,6 +242,19 @@ class TestNonConformantModernPeer:
|
|||
|
||||
|
||||
class TestPinnedMode:
|
||||
def test_prior_discover_is_exposed(self, fastmcp_server):
|
||||
prior = DiscoverResult(
|
||||
supported_versions=[LATEST_MODERN_VERSION],
|
||||
capabilities=ServerCapabilities(),
|
||||
)
|
||||
client = Client(
|
||||
fastmcp_server,
|
||||
mode=LATEST_MODERN_VERSION,
|
||||
prior_discover=prior,
|
||||
)
|
||||
|
||||
assert client.prior_discover is prior
|
||||
|
||||
async def test_pinned_modern_adopts_without_probe(self, fastmcp_server):
|
||||
"""Pinning the modern version adopts it directly; a synthesized
|
||||
DiscoverResult carries no identity, so server_info is absent."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue