Code Mode
Give your agents thousands of tools in only 1'000 tokens
Listing tools can often end up consuming a significant amount of tokens, due to large number of tools and/or overly long descriptions and complex schema definitions. Code Mode replaces all your tools with only two (2): search_tools and execute_code:
search_tools(query): Returns the tools and their schema matchingquery.execute_code(code): Executes TypeScript/JavaScript code in a isolated virtual machine, the tools returned fromsearch_toolsare available undercodemode.*.
Conceptual Example
const result = await client.callTool('execute_code', { code:`
// Chain multiple operations in one request
const [ pr, comments, reviews ] = await Promise.all([
codemode.github.getPullRequest({ owner: 'microsoft', repo: 'vscode', pull_number: 1234 }),
codemode.github.getPullRequestComments({ owner: 'microsoft', repo: 'vscode', pull_number: 1234 }),
codemode.github.getPullRequestReviews({ owner: 'microsoft', repo: 'vscode', pull_number: 1234 })
]);
// Process data efficiently in-sandbox
return {
title: pr.title,
commentCount: comments.length,
approvals: reviews.filter(r => r.state === 'APPROVED').length
};
`});Actual Response Content
Calling search_tools with "linear":
# linearDash.getDiff(urlOrId)
Description:
Exact lookup for a Linear diff. Use with review URLs, GitHub PR URLs, Linear full identifiers, UUIDs, or slugs.
Arguments: urlOrId(required, type=string, description: "Linear review URL, diff slug, pull request ID, Linear full identifier, or GitHub PR URL", minLength=1)
Returns: unknown — log the result to see its shape
-
# linearDash.getDiffThreads(orderBy, urlOrId, resolved, threadId)
Description:
Exact lookup for diff threads. Use with review URLs, GitHub PR URLs, Linear full identifiers, UUIDs, or slugs.
Arguments: orderBy(optional, type=string, description: "Sort: createdAt | updatedAt", enum=[createdAt, updatedAt]), urlOrId(required, type=string, description: "Linear review URL, diff slug, pull request ID, Linear full identifier, or GitHub PR URL", minLength=1), resolved(optional, type=boolean, description: "Filter returned threads by resolved state"), threadId(optional, type=string, description: "Optional top-level thread/comment ID to return")
Returns: unknown — log the result to see its shape
-
(...snip)Using search_tools for with no query returns a summary:
# Servers (e.g. codemode.SERVER)
linear
gmail
gdrive
compression
fetch
codemode
supabase
# Tools (e.g. codemode.SERVER.TOOL) (first 20)
linear.createAttachment
linear.createAttachmentFromUpload
linear.createIssueLabel
(...)
linear.listDiffs
linear.listDocuments
... and 34 more
Use search_tools with a query to display more details (e.g. input schema)Enabling Code Mode
You can enable Code Mode explicitly by either using a profile, appending the query-string ?codemode to the MCP URL, or specifying auto-mode in your organization settings, so that code mode automatically is used if the number of tools exceed a certain threshold.
Automatic Code-Mode
You can configure a tool count threshold, which will enable Code Mode if the number of available tools exceed it. You may set the threshold to zero (0) to always use code mode.
- In Gatana, navigate to Settings
- Scroll down to Features
- Check Automatic Code Mode
- Optional: Adjust the threshold value
- Optional: Set the threshold value to
0to always use code mode
Forcing with Profiles
First, you need a profile which has force code mode enabled:
- In Gatana, navigate to Profiles
- Either create a new or edit an existing Profile
- In the modal, select Force Code Mode
- Click on Save
Whenever this profile is used in a request, code mode will be enabled for all servers, not only the ones covered in the profile.
Query-String codemode
Normally you would connect to: https://ORG_ID.gatana.ai/mcp. To force code-mode, you can instead use either:
https://ORG_ID.gatana.ai/mcp?codemodehttps://ORG_ID.gatana.ai/mcp?codemode=true
Read More
- https://blog.cloudflare.com/code-mode-mcp/
- https://blog.cloudflare.com/code-mode/
- https://github.com/universal-tool-calling-protocol/code-mode
Environment and Isolation
The code is executed in an isolated (per-organization) virtual machine using Kata Containers, which provides a very strong layer of security and isolation.