CodeMode MCP Bridge - Bridge your MCP servers using Code Mode!
  • TypeScript 97.9%
  • JavaScript 2.1%
Find a file
Yip Rui Fung 29e8a1ebfe
Beginning of manual cleanup of AI generated code
While they made something that worked, initially, adding features caused increased complexity and spaghettification, leading to AI models being unable to debug issues at all.
2026-02-28 23:41:40 +08:00
.github/workflows ci/docs: remove Bun from CI workflow, update runtime and executor docs 2026-02-28 13:38:09 +08:00
docs feat(sandbox): enforce EvalReturn format validation and add outputSchema support 2026-02-28 18:43:18 +08:00
src Beginning of manual cleanup of AI generated code 2026-02-28 23:41:40 +08:00
tests Beginning of manual cleanup of AI generated code 2026-02-28 23:41:40 +08:00
todo-plans docs: add preliminary plan for HITL tool verification 2026-02-28 15:25:58 +08:00
.gitignore chore: trim AGENTS.md to conventions-only, update .gitignore 2026-02-26 15:01:19 +08:00
AGENTS.md chore: trim AGENTS.md to conventions-only, update .gitignore 2026-02-26 15:01:19 +08:00
DIAGNOSTIC_SUMMARY.md refactor: remove @cloudflare/codemode dependency and inline core functionality 2026-02-28 15:47:19 +08:00
LICENSE Add Apache License 2.0 2026-02-24 18:23:41 +08:00
package-lock.json feat(utils): add utils virtual server with yaml parse/stringify tools 2026-02-28 19:31:26 +08:00
package.json feat(utils): add utils virtual server with yaml parse/stringify tools 2026-02-28 19:31:26 +08:00
README.md docs: update tool names, descriptions, and language for MCP tool rename 2026-02-28 17:01:48 +08:00
tsconfig.json feat(cli): integrate executor status into version output and modernize environment 2026-02-25 22:12:28 +08:00
vitest.config.ts refactor: extract shared base class and types for remote executors 2026-02-28 13:34:34 +08:00

Code Mode Bridge

npm

An MCP (Model Context Protocol) multiplexer that connects to upstream MCP servers and exposes all their tools through a single sandbox_eval_js tool for unified orchestration and execution. Runs on Node.js and Deno. Bun is not officially supported — if you need to use Bun, ensure a container runtime (Docker or Podman) or Deno is available in your PATH so the bridge can delegate code execution to a supported executor.

Key Features

  • Multi-server bridging: Connect to multiple upstream MCP servers simultaneously.
  • Tool aggregation: Exposes all upstream functions through a single sandbox_eval_js tool.
  • Dynamic discovery: Three built-in discovery tools let agents find and inspect available functions before writing code.
  • Multi-executor sandbox: Secure execution via Deno, isolated-vm, Docker/Podman containers, or vm2.
  • Automatic detection: Automatically selects the best available executor for your environment.
  • Live reload: Watches mcp.json for changes and hot-reloads upstream connections without restarting.
  • CLI management: Easy command-line interface for server configuration.

Quick Start

Installation & Run

# Run without installing
npx @ruifung/codemode-bridge

# Or install globally
npm install -g @ruifung/codemode-bridge
codemode-bridge run

Basic Usage

  1. Add a server:
    codemode-bridge config add kubernetes --type stdio --command "npx" --args "-y,kubernetes-mcp-server@latest"
    
  2. Start the bridge:
    codemode-bridge run
    
  3. Use in your client: Point your MCP client (Claude Desktop, VS Code, etc.) to npx @ruifung/codemode-bridge.

Discovery Tools

The bridge exposes three tools for discovering what's available before writing sandbox_eval_js code:

Tool Description
sandbox_get_functions List all available functions grouped by server. Accepts an optional server filter.
sandbox_get_function_schema Get the TypeScript type definition for a specific function by name.
sandbox_search_functions Keyword-search all function names and descriptions. Returns matching functions with their schemas.

Use these before calling sandbox_eval_js to find the correct function name and parameter types.

Using the sandbox_eval_js Tool

The sandbox_eval_js tool executes JavaScript in a sandboxed environment with access to all upstream functions via the codemode object. You can write either a function body or a complete async arrow function:

// Function body (auto-wrapped):
const result = await codemode.server_name__function_name({ param: "value" });
return result;

// Or as a complete async arrow function:
async () => {
  const result = await codemode.server_name__function_name({ param: "value" });
  return result;
}

Documentation Index

  • Architecture: How the bridge works, project structure, and logical flow.
  • Executors: Detailed comparison of sandbox backends (Deno, isolated-vm, Containers).
  • CLI & Configuration: Full command reference and configuration format.
  • HTTP Serve Mode: Multi-client HTTP transport, session isolation, and security.
  • Integration Guide: Setup instructions for Claude Desktop, VS Code, and more.
  • Development: Build and test instructions for contributors.
  • Sandbox Hardening: Security details for the execution environments.