Fastmcp Proxy Example
This example showcases how to proxy a Kapa hosted MCP server from fastmcp
Ask AI about Fastmcp Proxy Example
Powered by Claude Β· Grounded in docs
I know everything about Fastmcp Proxy Example. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
Kapa MCP Proxy Example
If you already have an MCP server that exposes functionality to your users, and you want to add Kapa's semantic retrieval for your knowledge bases without requiring users to install multiple MCP servers, you can proxy Kapa's MCP server from your existing one.
This example shows how to do this using FastMCP.
What is Proxying?
From the FastMCP docs:
Proxying means setting up a FastMCP server that doesn't implement its own tools or resources directly. Instead, when it receives a request (like
tools/callorresources/read), it forwards that request to a backend MCP server, receives the response, and then relays that response back to the original client.
In this example, we proxy Kapa's retrieval tool so it appears as a native part of your server:
ββββββββββββββββββββββββββββββββββββββββββ
β Your MCP Server β
β β
β β’ get_status (native) β
β β’ search_*_knowledge_sources ββββββββββΌβββΊ Kapa MCP Server
β β
ββββββββββββββββββββββββββββββββββββββββββ
Your users only need to install one MCP server, but get access to both your native tools and Kapa's retrieval.
Note: This example includes a simple native tool called
get_statusto demonstrate how proxied tools appear alongside your own.
Prerequisites
- Docker
- A Kapa hosted MCP server (setup guide)
Usage
1. Configure your Kapa credentials:
cp env.example .env
Edit .env with your credentials from Kapa Dashboard:
| Variable | Description |
|---|---|
KAPA_MCP_SERVER_URL | https://your-project.mcp.kapa.ai |
KAPA_API_KEY | Your API key |
2. Start the containers:
docker compose up
This starts two containers:
- MCP Server (
localhost:8787) β Example server with native tools and consumes the proxy - MCP Inspector (
localhost:6274) β a web UI for browsing and testing MCP tools
3. Open the MCP Inspector:
The MCP Inspector is a developer tool for testing MCP servers. It lets you browse available tools, call them, and see the results.
- Go to http://localhost:6274
- The server URL is prefilled β click Connect
- Navigate to the Tools tab
You'll see both tools listed:
get_statusβ your native toolsearch_<product>_knowledge_sourcesβ proxied from Kapa

How It Works
from fastmcp import FastMCP
mcp = FastMCP(name="My Product MCP Server")
# Your native tool
@mcp.tool
def get_status() -> dict:
return {"status": "healthy"}
# Create proxy to Kapa's MCP server
kapa_proxy = FastMCP.as_proxy({
"mcpServers": {
"kapa": {
"url": os.getenv("KAPA_MCP_SERVER_URL"),
"transport": "http",
"headers": {"Authorization": f"Bearer {os.getenv('KAPA_API_KEY')}"}
}
}
})
# Mount Kapa's tools
mcp.mount(kapa_proxy)
Why mount?
FastMCP offers two ways to compose servers:
mount()β Live link; changes to Kapa's tools are reflected immediatelyimport_server()β Static copy; fasterlist_tools()but requires restart to pick up changes
This example uses mount() so updates to your Kapa server are reflected without restarting. If performance is critical for your use case, see the FastMCP docs for alternatives.
