→ For agents: read llms.txt
→ For humans: send your agent this prompt:
Install mcp-switch (
pip install mcp-switch) and use it as an MCP switchboard so only the needed namespaces are loaded at a time. Read https://raw.githubusercontent.com/Zer0Wav3s/mcp-switch/main/llms.txt for setup and usage.
What It Does
When you connect a pile of MCP servers to an agent, every tool usually gets dumped into context up front. That is dumb. More tools means more noise, slower tool selection, and worse calls.
mcp-switch fixes that by exposing 5 meta-tools first:
list_namespacesload_namespaceunload_namespaceload_groupunload_group
The agent starts focused, loads what it needs, then unloads it when done.
flowchart LR
subgraph before["Without mcp-switch"]
A1["🤖 Agent"] --> T1["46 tools loaded\n(database, GitHub, Slack,\nDocker, K8s...)"]
T1 --> R1["❌ Slower, noisier,\nworse tool picks"]
end
subgraph after["With mcp-switch"]
A2["🤖 Agent"] --> T2["5 meta-tools\n(list, load, unload,\nload_group, unload_group)"]
T2 -->|"load_namespace('postgres')"| T3["+ only the database tools"]
T3 --> R2["✅ Focused, fast,\nright tool at the right time"]
T3 -->|"unload_namespace('postgres')"| T2
end
style before fill:#1a1a2e,stroke:#e74c3c,color:#fff
style after fill:#1a1a2e,stroke:#2ecc71,color:#fff
How It Works
- Define namespaces for MCP servers, hosted HTTP MCP endpoints, or CLI tools
- Start mcp-switch as one MCP server in your client
- Let the agent discover namespaces with
list_namespaces - Load only what is needed with
load_namespaceorload_group - Unload when done to keep context clean
It supports:
mcpbackends - local stdio MCP servershttpbackends - remote MCP servers over StreamableHTTP with SSE fallbackclibackends - shell commands wrapped as MCP tools- groups
idle_ttl,pinned, andmax_loaded_namespaces- tools, resources, resource templates, and prompts
Install
pip install mcp-switch
Or use uvx without installing globally:
uvx mcp-switch --help
Quick Start
1. Create a config
Fastest path:
uvx mcp-switch setup
Or import an existing MCP config:
uvx mcp-switch init
uvx mcp-switch init --from ~/.config/claude/claude_desktop_config.json
Or write one manually at ~/.config/mcp-switch/config.yaml:
max_loaded_namespaces: 3
namespaces:
postgres:
type: mcp
command: "uvx mcp-server-postgres"
args: ["--connection-string", "postgresql://localhost/mydb"]
description: "Query and manage PostgreSQL databases"
idle_ttl: 300
supabase:
type: http
url: "https://mcp.supabase.com/mcp"
headers:
Authorization: "Bearer ${SUPABASE_TOKEN}"
description: "Supabase database tools"
git:
type: cli
description: "Git version control"
tools:
git_status:
command: "git status --porcelain"
description: "Show working tree status"
git_log:
command: "git log --oneline -20"
description: "Show recent commits"
groups:
dev:
- git
- postgres
2. Verify it works
uvx mcp-switch validate
uvx mcp-switch doctor
uvx mcp-switch test --json-output
3. Add it to your MCP client
General pattern:
{
"mcpServers": {
"mcp-switch": {
"command": "uvx",
"args": ["mcp-switch", "serve", "--config", "~/.config/mcp-switch/config.yaml"]
}
}
}
Examples:
Claude Code
claude mcp add mcp-switch -- uvx mcp-switch serve --config ~/.config/mcp-switch/config.yaml
Cursor
Add to .cursor/mcp.json:
{
"mcpServers": {
"mcp-switch": {
"command": "uvx",
"args": ["mcp-switch", "serve", "--config", "~/.config/mcp-switch/config.yaml"]
}
}
}
VS Code
Add to .vscode/mcp.json:
{
"servers": {
"mcp-switch": {
"command": "uvx",
"args": ["mcp-switch", "serve", "--config", "~/.config/mcp-switch/config.yaml"]
}
}
}
Hermes
mcp_servers:
mcp-switch:
command: uvx
args: ["mcp-switch", "serve", "--config", "~/.config/mcp-switch/config.yaml"]
Or generate it:
uvx mcp-switch export hermes
Features
Namespace groups
Load related namespaces together:
groups:
dev:
- git
- postgres
- docker
Auto-unload with idle_ttl
Unload inactive namespaces automatically to keep context lean.
Pinned namespaces
Mark important namespaces as pinned: true so LRU eviction never removes them.
Max loaded namespace cap
Set max_loaded_namespaces to enforce a ceiling. If the cap is reached, mcp-switch evicts the least recently used unpinned namespace.
Full MCP surface
Tools are the main event, but resources, resource templates, and prompts are also proxied.
CLI
mcp-switch setup # interactive config wizard
mcp-switch init # import existing MCP configs
mcp-switch serve # start the MCP server
mcp-switch validate # validate config
mcp-switch doctor # check env, commands, config health
mcp-switch test # connect to backends and list tools
mcp-switch status # config and policy summary
mcp-switch list # list configured namespaces
mcp-switch export hermes # generate client-specific config
Troubleshooting
${VAR} values are not resolving
Use standard shell-style placeholders like ${SUPABASE_TOKEN}. mcp-switch expands them in both env and HTTP headers values.
doctor says an env var is missing
That means the placeholder resolved to an empty string in your current environment. Set it first, then rerun mcp-switch doctor.
Agent is not seeing new tools after loading
Some clients cache tool lists aggressively. mcp-switch sends tools/list_changed, but if your client ignores it, reconnect the MCP server.
Why does status not show what is live right now?
Because status is a config and policy summary, not a runtime inspector.
Links
- Repository: https://github.com/Zer0Wav3s/mcp-switch
- PyPI: https://pypi.org/project/mcp-switch/
- License: MIT © 2026 ZeroWaves
Metadata
Release files for mcp-switch 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mcp_switch-0.4.1.tar.gz | 35.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mcp_switch-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 68.2 kB
Release files / mcp_switch-0.4.1.tar.gz
| Download URL | mcp_switch-0.4.1.tar.gz |
|---|---|
| Size | 35.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd2b5c9cdbd6128921e2308b9a219d0c47c24379081a0201cb410eb7626a847e
|
|
BLAKE2b-256 checksum How to use checksums |
2d0c21f761e58bbe9f585e270d0f10193f1106414a63d3c2de389c664b72e8a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.
Transparency logRelease files / mcp_switch-0.4.1-py3-none-any.whl
| Download URL | mcp_switch-0.4.1-py3-none-any.whl |
|---|---|
| Size | 32.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0caf1764406423f283bec7395b988c8b6fce7e14c3a13d1babf3066043dc3b12
|
|
BLAKE2b-256 checksum How to use checksums |
b440a86b7d44d3a828bdb9616e40cbd8712fedd8d692956d5ac61781175d44c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.
Transparency log