Skip to content

Explore Code Mode pattern for token-efficient MCP interface #132

@jonathanpopham

Description

@jonathanpopham

Context

Cloudflare published a blog post on their "Code Mode MCP" pattern: https://blog.cloudflare.com/code-mode-mcp/

Instead of exposing thousands of individual tool definitions (which bloats context windows), they expose just 2 tools: search() and execute(). The agent writes JavaScript code against a typed SDK, which runs in a sandboxed V8 isolate. This achieves a 99.9% token reduction — their full API surface would consume 1.17M tokens as traditional MCP tools, but Code Mode uses ~1,000 tokens.

Relevance to Supermodel

As we add more graph types and analysis endpoints, the number of MCP tools grows. Each tool definition consumes context tokens on every agent turn. The Code Mode pattern could let us:

  1. Expose the full Supermodel API surface with minimal token overhead — replace individual graph/analysis tools with search() (to discover available endpoints/operations) and execute() (to run typed API calls)
  2. Let agents compose multi-step workflows — e.g., generate a call graph, then filter to a specific module, then check for dead code — all in a single execute() call rather than multiple tool round-trips
  3. Progressive capability discovery — new API endpoints become available automatically without shipping new tool definitions

Key Design Questions

  • What's the right SDK surface to expose? (REST client vs. higher-level graph query DSL)
  • Sandbox approach — Cloudflare uses V8 isolates. We could use Node VM, Deno, or similar
  • How to handle auth/scoping within the sandbox
  • Whether this complements or replaces the current per-tool MCP approach

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions