Skip to content

For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.

Page as Markdown

MCP federation

Learn how to federate tools from multiple MCP servers through a single endpoint

Expose a single MCP endpoint that aggregates tools from multiple backend servers with unified security.

What you’ll build

In this tutorial, you configure the following.

  1. Configure agentgateway to federate multiple MCP servers
  2. Combine filesystem and memory servers into a single endpoint
  3. Access tools from both servers with automatic name prefixing
  4. Test federated tools in the Playground

Before you begin

Step 1: Install agentgateway

curl -sL https://agentgateway.dev/install | bash

Step 2: Create the config

cat > config.yaml << 'EOF'
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
mcp:
  port: 3000
  policies:
    cors:
      allowOrigins: ["*"]
      allowHeaders: [mcp-protocol-version, content-type, cache-control]
      exposeHeaders: ["Mcp-Session-Id"]
  targets:
  - name: filesystem
    stdio:
      cmd: npx
      args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
  - name: memory
    stdio:
      cmd: npx
      args: ["-y", "@modelcontextprotocol/server-memory"]
EOF

Step 3: Start agentgateway

agentgateway -f config.yaml

Example output:

INFO agentgateway: Listening on 0.0.0.0:3000
INFO agentgateway: Admin UI available at http://localhost:15000/ui/

Step 4: View backends in the UI

Go to http://localhost:15000/ui/ and click Backends to see your federated MCP servers:

MCP Federation Backends

The UI shows:

  • 1 total backend with 1 MCP configuration
  • MCP: filesystem, memory - Both servers combined into one backend
  • 2 targets - The filesystem and memory MCP servers

Step 5: Test in the Playground

Click Playground to test your federated tools:

MCP Federation Playground

  1. Select Route 1 in the Routes panel
  2. Click Connect to discover all tools
  3. Available Tools shows tools from both servers:
    • filesystem_read_file - Read the complete contents of a file
    • filesystem_read_text_file - Read file contents as text
    • filesystem_write_file - Create or overwrite a file
    • filesystem_list_directory - List directory contents
    • And more…

Notice tools are prefixed with their server name (filesystem_ and memory_).

Step 6: Run a tool

  1. Click on filesystem_read_text_file in the Available Tools list
  2. Enter a path (e.g., /tmp/test.txt)
  3. Click Run Tool

You’ll see the file contents in the response panel.


Adding more servers

Add GitHub tools (requires a token):

export GITHUB_TOKEN=your-github-token
targets:
- name: filesystem
  stdio:
    cmd: npx
    args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
- name: github
  stdio:
    cmd: npx
    args: ["-y", "@modelcontextprotocol/server-github"]
  env:
    GITHUB_PERSONAL_ACCESS_TOKEN: "${GITHUB_TOKEN}"

Next steps

Authorization

Add JWT authentication

MCP Auth

OAuth-based authentication

MCP Overview

Understanding MCP connectivity

Was this page helpful?
Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.