contextswitcher
April 13, 2025 ยท View on GitHub
contextswitcher is a lightweight MCP (Model Context Protocol) gateway that helps manage multiple MCP servers across different environments and projects. It enables tools like Claude Desktop and Roo Code to interact with various contextual AI agent setups seamlessly.
๐ Features
- Launches and manages multiple MCP servers defined in
.roo/mcp.json - Routes
tools/listrequests to all registered servers and merges the results - Supports context switching via the
context/switchtool - Adds configurable suffixes to tool names (default:
_cs) - Communicates with MCP servers over
stdiofor lightweight integration - Designed for human-controlled context switching (explicit is better than implicit!)
๐งฉ Use Cases
- Serve as a single MCP entrypoint for Claude Desktop or Roo Code
- Run multiple specialized agents (e.g., coder, designer) and route requests accordingly
- Enable explicit switching between contexts in a project
๐ Project Structure (Planned)
contextswitcher/
โโโ src/
โ โโโ cli.ts
โ โโโ context.ts
โ โโโ mcpLauncher.ts
โ โโโ toolAggregator.ts
โ โโโ types.ts
โโโ .roo/
โ โโโ mcp.json
โโโ vitest.config.ts
โโโ package.json
๐ Example .roo/mcp.json
{
"mcpServers": {
"contextSwitcher": {
"command": "node",
"args": ["dist/cli.js"],
"cwd": "./",
"env": {
"SWITCHING_ENABLED": "true",
"TOOL_SUFFIX": "_cs"
}
},
"coder": {
"command": "bun",
"args": ["src/mcp-server.ts"],
"cwd": "/Users/you/projects/awesome-agent/coder"
},
"designer": {
"command": "bun",
"args": ["src/mcp-server.ts"],
"cwd": "/Users/you/projects/awesome-agent/designer"
}
}
}
โ๏ธ Context Switching
The context/switch tool allows you to dynamically change the set of MCP servers:
{
"method": "context/switch",
"params": {
"configPath": "/path/to/other/mcp.json"
}
}
This will:
- Load the specified configuration file
- Stop all running MCP server processes
- Start new servers based on the configuration
- Return the new set of available tools
๐ท๏ธ Tool Suffix Configuration
All tools are exposed with a suffix (default: _cs) to avoid name collisions:
- Enable/disable with the
SWITCHING_ENABLEDenvironment variable in the contextSwitcher config - Customize the suffix with the
TOOL_SUFFIXenvironment variable
๐ Development Notes
- CLI context switching UI (TUI or Web UI) planned
- Goal: route all MCP traffic from Claude, Gemini, CLI, and CI tools through this gateway