-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Hello everyone,
Problem
I am facing the following problem. I am building a multi-tenant agentic solution that uses MCP servers. I am currently trying to implement some MCP servers provided by Klavis AI. So, an implementation would look like this (taken from their website:
root_agent = Agent(
name="my_agent",
model="gemini-2.5-flash",
description="An agent with access to tools through Klavis MCP",
instruction="You are a helpful assistant with access to MCP tools.",
tools=[
McpToolset(
connection_params=StreamableHTTPConnectionParams(
url=mcp_server_url,
),
)
],
)
The thing is that, in a multi-tenant architecture, the mcp_server_url should be a dynamic value, not a fixed one. In the context of deployed agents this is a problem because it means I would need a different agent for each tenant and the corresponding MCP server URL. I have talked to the supplier and he confirmed that the server URL is related to the user_id, so the idea is that for each user, there is a different MCP server URL.
What I expect
I would like to dynamically modify the MCP server URL, for example through a state like in regular agent tools. Something like this would be awesome:
McpToolset(
connection_params=StreamableHTTPConnectionParams(
url=tool_context.state["mcp_server_url"],
),
)
Alternatives
From the top of my head, I do not see any alternatives other than deploying a new agent for each tenant, given each one the right tenant's MCP server URL.
Is there any workaround for this or some feature that could be implemented to address this issue?
Thank you, best!