Skip to main content
Glama

Your AI is paying for tools it never uses

Every MCP server you connect sends all its tool definitions into your AI's context, on every conversation. Ten servers can mean 100+ tools and tens of thousands of tokens before you type a word. Then every tool result lands in the chat in full — a whole web page, a 3,000-line document, a giant JSON — even when the AI only needed one number.

That is slower, more expensive, and leaves less room for the AI to think.

Related MCP server: mcplex

Code Mode fixes it with one button

Code Mode MCP puts all your MCP servers behind a single gateway with three tiny tools. Your AI searches for the tool it needs, writes a few lines of code that call it, and only the answer comes back. Intermediate data stays on your computer.

npx github:DiegoT21/Code-Mode-MCP-

That opens a local panel. Press Setup → Move into Code Mode. It finds the MCP config of every AI app on your computer, moves the servers into the panel, and leaves each app with one server: the gateway. Backed up, and undoable with one click.

Measured, not promised

Same task, same servers (context7, memory, everything, sequential-thinking). Classic = what the AI loads and receives with normal MCP; Code Mode = the gateway's 3 tools + the code + what it returns.

Task

Classic MCP

Code Mode

Saved

Look up docs and keep only the relevant lines (2 calls)

≈ 8,049 tokens

≈ 2,272

72%

Several calls, one small answer (4 calls)

≈ 6,772

≈ 1,154

83%

Check a web page on mobile (browser in code)

≈ 6,490

≈ 624

90%

The more servers you have and the bigger their results, the bigger the saving. The panel measures every run, so you can see it on your own tools.

How it works

The gateway gives your AI three tools:

Tool

search_tools(query)

Find tools across every server behind the gateway

describe_tool(server, tool)

See one tool's parameters

run_code(code)

Run JavaScript that calls the tools and returns only what matters

// What your AI writes inside run_code
const issues = await mcp.call('github', 'list_issues', { repo: 'acme/web', state: 'open' })
return issues
  .filter((i) => i.labels.some((l) => l.name === 'bug'))
  .map((i) => `#${i.number} ${i.title}`)
  .slice(0, 10)          // ← only these 10 lines reach the conversation

Also built in, no extra MCP needed:

  • Browser in code — browser.page({ screen: 'mobile' }) drives your installed Chrome with Playwright and browser.timings() gives TTFB / FCP / LCP / CLS. Replaces a browser MCP that would dump the page tree into the chat.

  • Blender in batch — blender.run(scene, python) runs Python in Blender without opening it (if installed).

  • Images when they matter — return an MCP image object and the AI gets the picture.

A panel to see where your tokens go

English and Spanish, light and dark mode, and it fits the window without scrolling.

Quick start

npx github:DiegoT21/Code-Mode-MCP-
  1. The panel opens at http://localhost:4777.

  2. Setup shows the AI apps and MCP servers it found. Untick any server you want to keep direct.

  3. Press the button, then restart your AI apps (or open a new session).

  4. Ask your AI anything that uses your tools. Watch the savings in History.

Changed your mind? Setup → Undo everything puts every server back where it was.

Command

code-mode-mcp

Open the panel

setup · setup --apply · setup --undo

The Setup button, from the terminal

add <name> --config '<json>' [--env NAME]

Test a server and add it behind the gateway. Keys come from your terminal with --env, never from the command line

remove <name>

Remove a server (backup kept)

list

Servers, tools and token weight

skill-add <folder> · skill-remove <name>

Claude Code skills

run <file.js>

Run code like run_code

check <url> [--screen mobile]

Quick page check with your Chrome

usage [--days 7]

Claude Code token usage

gateway

The MCP server itself (what your AI apps start)

Use them as npx github:DiegoT21/Code-Mode-MCP- <command>, or install once with npm i -g github:DiegoT21/Code-Mode-MCP-.

Installers for Windows, macOS and Linux are on the Releases page. Same panel, in its own window; it still needs Node.js 20+. They are not code-signed, so Windows Smart App Control or macOS Gatekeeper may block or warn. npx does exactly the same without an installer.

FAQ

Does my AI get worse at using tools? No: it gets the same tools, found on demand. Models are very good at writing short code, and doing several calls in one script is often more reliable than many separate tool calls.

Is it safe? Everything runs locally. The panel only listens on 127.0.0.1, rejects requests not addressed to localhost (so a website cannot reach it through DNS rebinding) and refuses changes coming from other pages. Every config file is backed up before it is touched and only its MCP section changes. Keys stay in ~/.code-mode-mcp/servers.json in your user folder and are never shown. run_code is not a security sandbox: it is handed only mcp, browser, blender and log, but determined code can get out of that context. Treat it like your AI's own terminal — it runs with your user's permissions.

When should a server stay direct? When the AI must look and decide step by step in real time (a live 3D scene, an interactive browser session). Untick it in Setup.

What about claude.ai connectors (Gmail, Drive…)? They live in your claude.ai account and cannot be moved to a local gateway.

How accurate are the numbers? Token counts are estimates (≈ 3.5 characters per token) — good for comparing, not for billing. The Usage cost comes from Claude Code's own logs.

Requirements

Node.js 20+ · Google Chrome or Microsoft Edge (for the browser tools) · Blender (optional)

Uninstall

Setup → Undo everything (or npx github:DiegoT21/Code-Mode-MCP- setup --undo), then delete ~/.code-mode-mcp.

Contributing

Issues and pull requests are welcome — especially support for more AI apps.

git clone https://github.com/DiegoT21/Code-Mode-MCP-.git && cd Code-Mode-MCP-
npm install
npm test     # Setup, gateway and Undo against fake configs
npm start    # the panel

If Code Mode saves you tokens, a ⭐ helps other people find it.

MIT License

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A meta-server that aggregates multiple MCP servers into a single interface, reducing token usage by 98%+ through progressive tool discovery and direct code execution that processes data between tools without consuming context window space.
      10
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Semantic tool-routing gateway for MCP servers that cuts 70-90% of context tokens, with RBAC, API-key auth, response caching, hot-reload config, and a real-time observability dashboard.
      3
      13
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI apps to connect to any local or remote MCP server through one local endpoint, with per-server permissions, tool prefixes, and an activity log. Supports one-click connections to multiple AI clients and imports servers already configured in those apps.
      2
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables coding agents to reach every configured MCP server through just three tools (search, describe, execute) and a sandboxed JavaScript runtime, so a model writes one short program instead of making dozens of tool calls. Runs without network, filesystem, or credential access, returning only the result.
      91 npm
      9
      MIT