Skip to content

Connect your AI app

This page puts the MCP servers you already use in Claude Desktop, Cursor, VS Code or Windsurf behind Code Mode. Your app will then see one server, codemode, in place of all the others. It takes a few minutes and is easy to undo.

Before you start: install codemode-mcp and run codemode-mcp setup, as in Your first run.

1. Look before you switch

Import your app's server list and measure it. Nothing in the app changes yet:

codemode-mcp init --from claude      # or: cursor | vscode | windsurf
codemode-mcp stats

init writes the servers it found to mcp.json in the current folder. stats connects to them and prints how many tokens their tool definitions cost per request, the classic way and through Code Mode.

Is it worth it for you?

If stats reports a negative saving, you have too few tools for the definitions alone to pay off. Code Mode can still help if your tasks chain many calls with large results, but for a couple of simple tools you can stop here.

2. Switch the app over

codemode-mcp init --from claude --install

This does three things:

  1. copies the app's servers into ./mcp.json;
  2. saves a backup of the app's config next to it, named <file>.bak-YYYYMMDD-HHMMSS;
  3. replaces the app's server list with a single codemode entry that points at your mcp.json.

Open the app's MCP config file and replace its servers with this one entry. Use the full path to the mcp.json that holds your real servers:

{
  "mcpServers": {
    "codemode": {"command": "codemode-mcp", "args": ["serve", "-c", "/absolute/path/to/mcp.json"]}
  }
}

Where each app keeps that file, and the slightly different format VS Code uses, is in Use with MCP clients.

Keep mcp.json somewhere permanent. The app reads it every time it starts.

3. Restart the app and check

Quit the app completely and open it again. In its tool list you should now see:

  • run_code;
  • search_tools, if you have enough tools that their signatures don't fit inline;
  • nothing else, unless you chose to expose some tools directly.

Ask it something that needs your tools, the way you normally would. You do not have to mention Code Mode: the model is told to write one script for the whole task.

4. Decide what needs your approval

In classic MCP many apps ask you before each tool call. Through Code Mode the app sees a single run_code call, and one script can call many tools. Decide which tools should never run without a "yes" from you, and list them in mcp.json:

mcp.json
{
  "mcpServers": { "…": "your servers, unchanged" },
  "codemode": {
    "require_approval": ["*.delete_*", "*.send_*", "github.merge_pull_request"]
  }
}

Patterns are server.tool, and * matches anything. A matching call pauses the script and asks you in the app. See Approvals & safety before using Code Mode with tools that change or delete things.

5. Watch what it saves

codemode-mcp usage        # summary in the terminal
codemode-mcp dashboard    # the same data as a local web page

These show Code Mode's token use next to an estimate of what classic MCP would have used for the same tool calls. Monitoring savings explains how the estimate is calculated and what it leaves out.

Undo

Restore the backup that --install made, or put your original server entries back, and restart the app. Your servers were never modified.

If something went wrong

What you see What to do
The app shows no tools, or codemode fails to start Desktop apps often start with a minimal PATH. Use the full path to the codemode-mcp executable in the app's config (which codemode-mcp on macOS and Linux, where codemode-mcp on Windows)
Failed to connect to MCP server 'x' Run codemode-mcp -v stats in a terminal to see that server's own error output
Environment variable 'X' referenced in config is not set ${X} in mcp.json must be set in the environment of the app, not only in your terminal. Add it to the env block of the codemode entry
The first answer is slow The sandbox takes a few seconds to start, once per session

Next: Your first Python agent, or the full client guide.