Progressive tool discovery gateway for MCP, built on FastMCP
Project description
fastmcp-gateway
Progressive tool discovery gateway for MCP. Aggregates tools from multiple upstream MCP servers and exposes them through 3 meta-tools, enabling LLMs to discover and use hundreds of tools without loading all schemas upfront.
LLM
│
└── fastmcp-gateway (3 meta-tools)
├── discover_tools → browse domains and tools
├── get_tool_schema → get parameter schema for a tool
└── execute_tool → run any discovered tool
├── apollo (upstream MCP server)
├── hubspot (upstream MCP server)
├── slack (upstream MCP server)
└── ...
Why?
When an LLM connects to many MCP servers, it receives all tool schemas at once. With 100+ tools, context windows fill up and tool selection accuracy drops. fastmcp-gateway solves this with progressive discovery: the LLM starts with 3 meta-tools and loads individual schemas on demand.
Install
pip install fastmcp-gateway
Quick Start
Python API
import asyncio
from fastmcp_gateway import GatewayServer
gateway = GatewayServer({
"apollo": "http://apollo-mcp:8080/mcp",
"hubspot": "http://hubspot-mcp:8080/mcp",
})
async def main():
await gateway.populate() # Discover tools from upstreams
gateway.run(transport="streamable-http", port=8080)
asyncio.run(main())
CLI
export GATEWAY_UPSTREAMS='{"apollo": "http://apollo-mcp:8080/mcp", "hubspot": "http://hubspot-mcp:8080/mcp"}'
python -m fastmcp_gateway
The gateway starts on http://0.0.0.0:8080/mcp and exposes 3 tools to any MCP client.
How It Works
-
discover_tools()— Call with no arguments to see all domains and tool counts. Call withdomain="apollo"to see that domain's tools with descriptions. -
get_tool_schema("apollo_people_search")— Returns the full JSON Schema for a tool's parameters. Supports fuzzy matching. -
execute_tool("apollo_people_search", {"query": "Anthropic"})— Routes the call to the correct upstream server and returns the result.
LLMs learn the workflow from the gateway's built-in system instructions and only load schemas for tools they actually need.
Configuration
All configuration is via environment variables:
| Variable | Required | Default | Description |
|---|---|---|---|
GATEWAY_UPSTREAMS |
Yes | — | JSON object: {"domain": "url", ...} |
GATEWAY_NAME |
No | fastmcp-gateway |
Server name |
GATEWAY_HOST |
No | 0.0.0.0 |
Bind address |
GATEWAY_PORT |
No | 8080 |
Bind port |
GATEWAY_INSTRUCTIONS |
No | Built-in | Custom LLM system instructions |
GATEWAY_REGISTRY_AUTH_TOKEN |
No | — | Bearer token for upstream discovery |
GATEWAY_DOMAIN_DESCRIPTIONS |
No | — | JSON object: {"domain": "description", ...} |
GATEWAY_UPSTREAM_HEADERS |
No | — | JSON object: {"domain": {"Header": "Value"}, ...} |
LOG_LEVEL |
No | INFO |
Logging level |
Per-Upstream Auth
If your upstream servers require different authentication, use GATEWAY_UPSTREAM_HEADERS to set per-domain headers:
export GATEWAY_UPSTREAM_HEADERS='{"ahrefs": {"Authorization": "Bearer sk-xxx"}}'
Domains without overrides use request passthrough (headers from the incoming MCP request are forwarded to the upstream).
Health Endpoints
The gateway exposes Kubernetes-compatible health checks:
GET /healthz— Liveness probe. Always returns 200.GET /readyz— Readiness probe. Returns 200 if tools are populated, 503 otherwise.
Docker & Kubernetes
See examples/kubernetes/ for a ready-to-use Dockerfile and Kubernetes manifests.
# Build
docker build -f examples/kubernetes/Dockerfile -t fastmcp-gateway .
# Run
docker run -e GATEWAY_UPSTREAMS='{"svc": "http://host.docker.internal:8080/mcp"}' \
-p 8080:8080 fastmcp-gateway
Contributing
See CONTRIBUTING.md for development setup, architecture overview, and guidelines.
License
Apache License 2.0. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastmcp_gateway-0.1.0.tar.gz.
File metadata
- Download URL: fastmcp_gateway-0.1.0.tar.gz
- Upload date:
- Size: 32.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c795687e81e8b8ad268c3a1dc40982c3878a8bfe6db47df6ef92c11739b52533
|
|
| MD5 |
c840f61f921f5eac74dd2a4608b262da
|
|
| BLAKE2b-256 |
3ac796a90b4899bf19441e33d83fd103491bfe0f4658d26677b3ad31fdf8ab34
|
Provenance
The following attestation bundles were made for fastmcp_gateway-0.1.0.tar.gz:
Publisher:
publish.yml on Ultrathink-Solutions/fastmcp-gateway
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastmcp_gateway-0.1.0.tar.gz -
Subject digest:
c795687e81e8b8ad268c3a1dc40982c3878a8bfe6db47df6ef92c11739b52533 - Sigstore transparency entry: 965047798
- Sigstore integration time:
-
Permalink:
Ultrathink-Solutions/fastmcp-gateway@8bf4d2558739855d3e2ae322973c4395fdab6cc1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Ultrathink-Solutions
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8bf4d2558739855d3e2ae322973c4395fdab6cc1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file fastmcp_gateway-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fastmcp_gateway-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bffbe328a9c2170e2bd923a2e25fa69056252bca4e52531fe5e7b012f21ee849
|
|
| MD5 |
1973f87f62dce88e7097fbae639d5ab5
|
|
| BLAKE2b-256 |
074f73b842ac0964bbadee7bb9ce137d21c587c3152919a505d4d475059c3a6a
|
Provenance
The following attestation bundles were made for fastmcp_gateway-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Ultrathink-Solutions/fastmcp-gateway
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastmcp_gateway-0.1.0-py3-none-any.whl -
Subject digest:
bffbe328a9c2170e2bd923a2e25fa69056252bca4e52531fe5e7b012f21ee849 - Sigstore transparency entry: 965047863
- Sigstore integration time:
-
Permalink:
Ultrathink-Solutions/fastmcp-gateway@8bf4d2558739855d3e2ae322973c4395fdab6cc1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Ultrathink-Solutions
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8bf4d2558739855d3e2ae322973c4395fdab6cc1 -
Trigger Event:
release
-
Statement type: