Code Mode
Enables AI agents to search Cloudflare's OpenAPI spec and execute requests to the Cloudflare API, with optional write access, for inspecting and managing Cloudflare resources through generated JavaScript calls.
Provides Code Mode access to GitHub's REST API: agents can search endpoints and run sandboxed JavaScript to query repositories, issues, pull requests, users, and other GitHub resources, read-only by default with optional write access.
Integrates with the OpenAI API by letting agents search its OpenAPI endpoints and execute API calls, read-only by default with optional write access, to inspect and manage OpenAI resources.
Lets agents search Stripe's API spec and execute sandboxed requests against Stripe endpoints for payments, customers, subscriptions, and other Stripe resources, read-only by default unless writes are enabled.
Provides access to Vercel's API through Code Mode, allowing agents to search endpoints and execute requests to inspect and manage Vercel projects, deployments, domains, and related resources, read-only by default.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Code Mode for any API

Give your AI agent a whole API for under 1,000 tokens.
New to this? Get the step-by-step setup and a copy-paste AI prompt at jamesrowdy.com/tools/code-mode.
Most MCP servers give your agent one tool per endpoint. GitHub's API has 1,259 endpoints, so the agent reads about 427,000 tokens of tool definitions before it does anything. That is twice the size of a 200K context window.
Code Mode, the approach Cloudflare published for its own API, swaps all of that for two tools:
search: the agent writes a few lines of JavaScript that look through the API's OpenAPI spec and find the endpoints it needs.
execute: the agent writes a small program that calls those endpoints, loops, filters and returns only the answer.
The spec stays on your machine, and the agent only sees what its code returns.
This tool does that for any API with an OpenAPI spec, and shows you the token count before and after.
Token counts
Measured on 5 Nov 2026 with code-mode count <api>:
API | Endpoints | One tool per endpoint | Same, required inputs only | Code Mode | Smaller by |
GitHub | 1,259 | 427,509 | 87,236 | 677 | 631x |
Stripe | 612 | 437,776 | 31,821 | 653 | 670x |
Cloudflare | 3,767 | 1,540,853 | 258,272 | 650 | 2,371x |
OpenAI | 388 | 431,488 | 20,587 | 634 | 681x |
Vercel | 482 | 170,044 | 29,109 | 648 | 262x |
One tool per endpoint is what most OpenAPI to MCP converters build: every endpoint as a tool, with its inputs and their schemas filled in.
Required inputs only strips each of those tools down to what it must have. It is the smallest that approach can get.
Code Mode is the exact tool list this server sends.
Tokens are counted with OpenAI's o200k tokenizer. Cloudflare's own post counted 1.17 million tokens for 2,500+ endpoints. The spec downloaded on 5 Nov 2026 has 3,767, so the count here is higher.
Related MCP server: codemode-workers
Quick start
You need Node.js 20 or newer.
See the numbers for any built-in API:
npx -y github:jamesrowdyy/code-mode count githubThis also downloads and caches the spec, so your agent starts the server fast the first time.
Add it to your agent
Claude Code
claude mcp add github-api -- npx -y github:jamesrowdyy/code-mode githubCodex
codex mcp add github-api -- npx -y github:jamesrowdyy/code-mode githubCursor, Hermes Agent, Claude Desktop or any other MCP app: add a stdio server with command npx and args ["-y", "github:jamesrowdyy/code-mode", "github"].
Swap github for stripe, cloudflare, openai, vercel, or a link to any OpenAPI spec.
API keys
The server reads your key from an environment variable and adds it to each request itself. Pass it when you add the server, for example claude mcp add stripe-api -e STRIPE_API_KEY=rk_live_... -- npx -y github:jamesrowdyy/code-mode stripe.
API | Variable | Notes |
github |
| Optional. If you are logged in with the |
stripe |
| Use a restricted key with read access only. |
cloudflare |
| Make a read-only API token. |
openai |
| |
vercel |
|
Any other API
# The spec says where the API lives
npx -y github:jamesrowdyy/code-mode https://petstore3.swagger.io/api/v3/openapi.json
# A local spec, with its address and key
npx -y github:jamesrowdyy/code-mode ./openapi.yaml --base-url https://api.example.com --token-env EXAMPLE_API_KEYThe key goes in an Authorization: Bearer header by default. Use --auth header:X-Api-Key, --auth query:api_key or --auth none for APIs that do it differently.
Safe by default
Read-only. Only GET requests go out. Start the server with
--allow-writesif you want your agent to create, change or delete things.Your key never enters the AI's code. The code runs in a QuickJS sandbox (WebAssembly) with no network, files, environment variables or modules. Its only way out is
api.request(), which the server sends to the API's own address and signs with your key on the way out.Limits. Each execute call gets 30 seconds and 100 requests, and a memory cap. Results over about 6,000 tokens are cut off with a note telling the agent to return less.
What your agent writes
Asked "how many pull requests were merged into cloudflare/mcp in the last 30 days, who merged them, and what were the latest three?", Codex used only these two tools. It made 5 calls, and its answer (71 merged) matched the gh CLI. A search call looks like this:
async () => ops
.filter(o => /pull request/i.test(o.summary) && o.method === 'GET')
.map(o => o.method + ' ' + o.path + ' ' + o.summary)And an execute call:
async () => {
const pulls = await api.request({
method: 'GET',
path: '/repos/{owner}/{repo}/pulls',
params: { owner: 'cloudflare', repo: 'mcp' },
query: { state: 'closed', per_page: 100 },
});
const merged = pulls.filter(p => p.merged_at);
return { merged: merged.length, latest: merged.slice(0, 3).map(p => p.title) };
}Commands
code-mode <api> [options] Start the MCP server (your agent runs this)
code-mode count <api> [options] Show the tokens before and after
code-mode list Show the built-in APIs
Options:
--base-url URL Where requests go, if the spec does not say
--token-env NAME Environment variable that holds the API key
--auth TYPE bearer (default), header:NAME, query:NAME or none
--header "K: V" Extra header on every request (repeatable)
--allow-writes Allow POST, PUT, PATCH and DELETE (off by default)
--timeout SEC Time limit per execute call (default 30)
--max-requests N Request limit per execute call (default 100)
--name NAME Display name for the API
--refresh Download the spec again instead of using the cache
--json With count: print JSONSpecs are cached in ~/.cache/code-mode and refreshed in the background once a day.
Credit
Code Mode is Cloudflare's idea, from their post Code Mode: give agents an entire API in 1,000 tokens and their server for the Cloudflare API. This project applies the same idea to any OpenAPI spec. It is not affiliated with Cloudflare.
Development
git clone https://github.com/jamesrowdyy/code-mode
cd code-mode
npm install
npm testLicense
MIT. Made by James Rowdy. More free tools at jamesrowdy.com/tools.
This server cannot be deployed
Maintenance
Related MCP Connectors
Verified, pay-per-use API tools for AI agents through one authenticated connection.
Point Gecko at an OpenAPI spec; get first-call-correct, auth-hidden agent tools.
Turn any task into the right API calls: discover, evaluate, and integrate public APIs.
AI-callable tools for API mocking, testing, monitoring, security, and automation.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceTurns any OpenAPI/Swagger spec into queryable tools for LLMs, enabling endpoint search, detail retrieval, and schema exploration.1-
- AlicenseNot gradedqualityDmaintenanceExpose any API to an LLM agent as two sandboxed MCP tools (search + execute) on Cloudflare Workers.3 npm2MIT
- FlicenseAqualityBmaintenanceEnables LLMs to dereference and query OpenAPI/Swagger specifications, search endpoints and schemas, validate payloads, extract security schemes, and generate production-ready integration code in multiple languages.8-
- AlicenseBqualityBmaintenanceEnables AI agents to explore any OpenAPI 3 spec, inspect endpoints and schemas, generate TypeScript types, and make authenticated API calls using credentials mapped to the spec's security schemes.716 npmMIT