mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-27 15:51:33 +02:00
Ensure multi-client configurations use new ProxyClient (#1045)
* Validate elicitation responses are dicts * Ensure advanced MCP features are forwarded through proxy * Use proxy client in tests
This commit is contained in:
parent
dba9f2c81f
commit
ef742d9400
8 changed files with 145 additions and 29 deletions
|
|
@ -53,6 +53,11 @@ def create_elicitation_callback(
|
|||
if not isinstance(result, ElicitResult):
|
||||
result = ElicitResult(action="accept", content=result)
|
||||
content = to_jsonable_python(result.content)
|
||||
if not isinstance(content, dict | None):
|
||||
raise ValueError(
|
||||
"Elicitation responses must be serializable as a JSON object (dict). Received: "
|
||||
f"{result.content!r}"
|
||||
)
|
||||
return MCPElicitResult(**result.model_dump() | {"content": content})
|
||||
except Exception as e:
|
||||
return mcp.types.ErrorData(
|
||||
|
|
|
|||
|
|
@ -773,8 +773,6 @@ class MCPConfigTransport(ClientTransport):
|
|||
"""
|
||||
|
||||
def __init__(self, config: MCPConfig | dict):
|
||||
from fastmcp.client.client import Client
|
||||
|
||||
if isinstance(config, dict):
|
||||
config = MCPConfig.from_dict(config)
|
||||
self.config = config
|
||||
|
|
@ -792,9 +790,9 @@ class MCPConfigTransport(ClientTransport):
|
|||
composite_server = FastMCP()
|
||||
|
||||
for name, server in self.config.mcpServers.items():
|
||||
server_client = Client(transport=server.to_transport())
|
||||
composite_server.mount(
|
||||
prefix=name, server=FastMCP.as_proxy(server_client)
|
||||
prefix=name,
|
||||
server=FastMCP.as_proxy(backend=server.to_transport()),
|
||||
)
|
||||
|
||||
self.transport = FastMCPTransport(mcp=composite_server)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue