You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to put together a small PoC for an mcp registry where I can define configurations for MCP servers and proxy requests to them based on the headers.
A client request that only pass something along the lines of X-Backend: user:dev,payment:staging to connect to the relevant tiers. I rather do this by establishing new sessions to avoid mounting all the servers and iterating through the different mounted servers for filtering.
My approach involved using a middleware that on_list_tools utilizes a proxy session on the requested backends. As of now it's not working because the ProxyClient returns mcp.types.Tool instances but the server expect them to be fastmcp.tool.tools.Tool type.
Should I change my approach here? Or could we change the following to:
async def _list_tools_mcp(self) -> list[MCPTool]:
"""
List all available tools, in the format expected by the low-level MCP
server.
"""
logger.debug(f"[{self.name}] Handler called: list_tools")
async with fastmcp.server.context.Context(fastmcp=self):
tools = await self._list_tools_middleware()
return [
tool if isinstance(tool, MCPTool) else tool.to_mcp_tool(
name=tool.key,
include_fastmcp_meta=self.include_fastmcp_meta,
)
for tool in tools
]
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to put together a small PoC for an mcp registry where I can define configurations for MCP servers and proxy requests to them based on the headers.
An example config would look like:
{ "servers": [ { "name": "payment", "urls": { "dev": "https://dev-payments.example.com", "staging": "https://staging-payments.example.com", "prod": "https://payments.example.com" } }, { "name": "user", "urls": { "dev": "https://dev-user.example.com", "staging": "https://staging-user.example.com", "prod": "https://user.example.com" } } ] }A client request that only pass something along the lines of
X-Backend: user:dev,payment:stagingto connect to the relevant tiers. I rather do this by establishing new sessions to avoid mounting all the servers and iterating through the different mounted servers for filtering.My approach involved using a middleware that on_list_tools utilizes a proxy session on the requested backends. As of now it's not working because the ProxyClient returns mcp.types.Tool instances but the server expect them to be fastmcp.tool.tools.Tool type.
Should I change my approach here? Or could we change the following to:
Beta Was this translation helpful? Give feedback.
All reactions