Gatana logoGatana Docs

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 matching query.
  • execute_code(code): Executes TypeScript/JavaScript code in a isolated virtual machine, the tools returned from search_tools are available under codemode.*.

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.

  1. In Gatana, navigate to Settings
  2. Scroll down to Features
  3. Check Automatic Code Mode
  4. Optional: Adjust the threshold value
  5. Optional: Set the threshold value to 0 to always use code mode

Forcing with Profiles

First, you need a profile which has force code mode enabled:

  1. In Gatana, navigate to Profiles
  2. Either create a new or edit an existing Profile
  3. In the modal, select Force Code Mode
  4. 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?codemode
  • https://ORG_ID.gatana.ai/mcp?codemode=true

Read More

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.

On this page