Skip to main content
Glama

execute_code

Run custom TypeScript/JavaScript code to call MCP tools, process large data with TOON compression, and implement complex workflows.

Instructions

WHEN TO USE:

  • Batching 3+ MCP tool calls (saves round-trips, maintains state)

  • Processing large structured data (TOON compression: 30-90% savings)

  • Complex logic with conditionals/loops across tool results

DO NOT USE:

  • Single simple tool call → use direct MCP

  • Unstructured prose → TOON compression <10%

AVAILABLE SERVERS: LAZY-LOAD ON DEMAND:

WORKFLOWS (use execute_workflow instead for these):

  • k8s-detective: Comprehensive Kubernetes cluster security and health auditor | USAGE: Scans pods, deployments, services, and events for security vulnerabilities, resource inefficiencies, and stability issues. Outputs detailed findings with severity ratings. EXAMPLE: "Audit my production cluster for security risks" PARAMETERS:

  • outputFile: Path to save TOON-compressed audit data (required)

  • namespace: Specific namespace to scan (optional, default: all)

  • includeEvents: Analyze recent events for warnings (optional, default: true) REQUIRES: kubectl configured with cluster access NOTES: Requires kubectl in PATH. Large clusters auto-TOON-encode. Run from bastion or local with kubeconfig.

  • post-mortem: Intelligent log analysis with pattern clustering and anomaly detection | USAGE: Parses log files, clusters similar messages by signature, extracts dynamic data (timestamps, IDs, IPs), identifies anomalies and errors, and generates an actionable report. EXAMPLE: "Analyze application logs from the outage and find the root cause" PARAMETERS:

  • logFile: Path to the log file to analyze (required)

  • outputFile: Path to save TOON-compressed analysis (required)

  • maxExamples: Max example lines per cluster (optional, default: 5)

  • includePatterns: Include normal patterns in output (optional, default: true) REQUIRES: filesystem access NOTES: Supports large files via streaming. Auto-detects log levels and categories.

  • research: Multi-source research aggregator with parallel execution and synthesis | USAGE: Orchestrates data fetching from Context7 (library docs), Wikipedia (concepts), and Perplexity (web Q&A). Supports parallel execution, retry logic, rate limiting, optional LLM synthesis, and file output. EXAMPLE: "Research xsync library performance vs sync.Map with benchmarks and theory. libraryIDs: ['puzpuzpuz/xsync'], wikipediaTopics: ['Hash table']" PARAMETERS:

  • goal: Primary research objective (required)

  • libraryIDs: Context7 library IDs for docs ["puzpuzpuz/xsync"] (optional)

  • queries: Perplexity questions ["xsync benchmarks?"] (optional)

  • wikipediaTopics: Wikipedia articles ["Lock-free data structures"] (optional)

  • synthesize: LLM synthesis of findings (optional, default: false)

  • outputFile: Path to save TOON-compressed results (optional)

  • batchSize: Max parallel requests per source (optional, default: 5) REQUIRES: At least one of: context7, wikipedia, perplexity (optional: brave-search as fallback) NOTES: Gracefully degrades if MCPs unavailable. Large outputs auto-TOON-encode.

USAGE PATTERN:

// 1. Discover tools first
const api = await get_tool_api({serverName: 'perplexity'});

// 2. Call tools via proxy
const result = await servers['perplexity'].perplexity_ask({
  messages: [{role: 'user', content: 'Your query'}]
});

// 3. Compress large results
console.log(TOON.encode(result));

ERROR RECOVERY:

  • "Server not found" → list_servers shows available

  • "Tool undefined" → get_tool_api({serverName}) shows tools

  • "Timeout (60s)" → break into smaller operations

All results TOON-compressed by default.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesTypeScript/JavaScript code. Use servers['name'].tool({params}) to call MCP tools.
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It mentions TOON compression default and error recovery patterns (timeout, server not found), but lacks warnings about security implications or side effects of executing arbitrary code.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well-structured with headings, but overly long. Includes extensive workflow descriptions for other tools that are not directly relevant, reducing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers when to use, not to use, usage pattern, and error recovery. Lacks security warnings and return value details, but given the single parameter and no output schema, it is reasonably complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and schema description already explains the 'code' parameter. The description adds a usage pattern example that shows how to call MCP tools via proxy, adding practical context beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the tool executes TypeScript/JavaScript code for batching MCP calls and processing data. It distinguishes from sibling execute_workflow by noting that specific workflows should use that tool instead.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly lists when to use (batching 3+ calls, large data, complex logic) and when not to (single call, low-compression prose). Also mentions alternatives like execute_workflow for specific workflows.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ziad-hsn/code-mode-toon'

If you have feedback or need assistance with the MCP directory API, please join our Discord server