MCP Switch
Let your VS Code agent turn MCP servers on and off.
VS Code agents (Copilot Chat in agent mode, and other Language Model Tools
clients) can't start or stop MCP servers on their own — VS Code doesn't give
the model access to its MCP lifecycle commands. MCP Switch bridges that gap:
it's a small extension that exposes four agent-callable tools which drive
VS Code's own MCP lifecycle commands (workbench.mcp.startServer,
stopServer, restartServer).
| Tool |
What it does |
mcp_switch_list_servers |
List MCP servers configured in this window, with their scope, transport, and VS Code definition ID |
mcp_switch_start_server |
Start one server (by name, or by explicit definition ID, or by agent-host session + server ID) |
mcp_switch_stop_server |
Stop one server — ends the current connection only |
mcp_switch_restart_server |
Restart one server |
Just ask your agent: "Start the GitHub MCP server", "Turn off the
database MCP", "Restart CloudTest".
The MCP Switch activity-bar view lists every configured server as a
card with its inferred state — a green "On · N tools" pill when its tools
are live in this window, "Off" when they're not — and a large
Start/Stop toggle button (one button, labeled and color-coded by
what it will do: green to start, red to stop) plus a Restart button
and a full-width Refresh button. (It's a webview rather than a tree view because VS Code fixes
tree-view inline icons at a small size extensions can't change.) The list
refreshes automatically when tools appear or disappear and when any
mcp.json changes.
State is tracked and inferred: VS Code exposes no authoritative
per-server running state, so MCP Switch records every start/stop it
dispatches in the window (authoritative for its own actions) and otherwise
infers state from the window's visible tools. A server's tools are
registered under its announced name, which may differ from its config
label — when MCP Switch starts a server itself it remembers which tools
appeared for it, so its state stays accurate on later runs. Two honest
caveats: a stopped server's tools can linger in the visible set, and a
server started entirely outside MCP Switch before it ever ran may show as
off until it has been started through MCP Switch once.
Design principles
- Non-migrating. Your configuration stays where it is. Servers are
discovered by reading the user profile
mcp.json, each workspace
folder's .vscode/mcp.json, and each folder's root .mcp.json. Nothing
is imported, moved, rewritten, or deleted — ever.
- Stop means stop. Stopping ends the current connection. It does not
disable the server, remove it, or change any setting; a later request can
start it again.
- No wildcards. Every action names exactly one server. If two scopes
define the same name, the tool asks for a scope or definition ID instead
of guessing.
- Prompts stay human. Start/stop/restart tool calls ask for your
confirmation, and VS Code's own trust and OAuth sign-in prompts remain
fully interactive. The extension never auto-trusts a server and never
sees or returns credentials, headers, commands, or environment values —
list returns names, scopes, transports, and IDs only.
- Honest state. VS Code doesn't expose authoritative per-server running
state to extensions through a stable API, so state is always labeled as
what it is: dispatch results from the tools, and an inferred on/off —
derived from the tools actually visible in the window — in the list tool
and the sidebar.
Known limits
- Discovery covers file-configured servers (user profile, workspace folder,
workspace root). Servers provided by other extensions and agent-host
session servers can't be enumerated by any stable API — but they can
still be started/stopped by passing their explicit
definitionId, or
agentHostSession + serverId for session-managed servers, to the
start/stop/restart tools. An extension-provided server's definition ID is
predictable: <publisher>.<extensionName>/<server label> — for example
acme.my-extension/My Server. The list tool returns this formula too.
- The internal definition-ID scheme used to address config servers
(
mcp.config.usrlocal.<name>, mcp.config.ws<index>.<name>,
workspace-dot-mcp.<index>.<name>) is VS Code-internal. It is verified
against the VS Code source and current builds, but a future VS Code
release could change it; the explicit-ID path will keep working.
Commands
The same actions are available to humans from the Command Palette:
MCP Switch: List / Start / Stop / Restart / Toggle / Refresh MCP
Server(s). Details are written to the MCP Switch output channel.
Requirements
VS Code 1.102 or later, and a language-model tool client such as GitHub
Copilot Chat in agent mode for the agent-callable tools.
License
MIT
| |