MCP multiplexing
Federate tools of multiple MCP servers on the Agent Gateway by using MCP multiplexing.
Configure the Agent Gateway
-
Create a listener and target configuration for your Agent Gateway. In this example, the Agent Gateway is configured as follows:
- Listener: An SSE listener is configured and exposed on port 3000.
- Target: The Agent Gateway defines two targets that both point to the same sample MCP server,
server-everything
. To federate the tools of the MCP server targets, you give each target a unique name. This name is used as a prefix for the tools that are exposed on the MCP server. In this example, theeverything
andeverything-else
prefixes are used. Note that the prefix name cannot include underscores (_
).
cat <<EOF > config.json { "type": "static", "listeners": [ { "name": "sse", "protocol": "MCP", "sse": { "address": "[::]", "port": 3000 } } ], "targets": { "mcp": [ { "name": "everything", "stdio": { "cmd": "npx", "args": [ "@modelcontextprotocol/server-everything" ] } }, { "name": "everything-else", "stdio": { "cmd": "npx", "args": [ "@modelcontextprotocol/server-everything" ] } } ] } } EOF
-
Run the Agent Gateway.
agentgateway -f config.json
Verify access to tools
-
Open the Agent Gateway UI to view your listener and target configuration.
-
Connect to the MCP server with the Agent Gateway UI playground.
-
Go to the Agent Gateway UI Playground.
-
In the Connection Settings card, select your Listener Endpoint and click Connect. The Agent Gateway UI connects to the target that you configured and retrieves the tools that are exposed on the target.
-
Verify that you see a list of Available Tools and that all tools are listed twice, one time with the prefix
everything
and one time with the prefixeverything-else
. You now have a federated view of all the tools that are exposed on all defined targets.
-
-
Verify access to a tool.
-
Select the
everything_echo
tool, enter any string in the message field, such ashello world
, and click Run Tool. Verify that access to the tool is granted and that you see your message echoed. -
Select the
everything-else_echo
tool, enter any string in the message field, such ashello everything else
, and click Run Tool. Verify that access to the tool is granted and that you also see your message echoed.
-