Skip to main content
Glama

executeTool

Run sandboxed Starlark code to call permitted MCP tools via Server.tool_name(param=value) and return the result plus logs.

Instructions

Executes Python-like (Starlark) code in a sandboxed interpreter with MCP tool access as Server.tool_name(param=value) (e.g., Filesystem.read_file(path=".")). Final step of listToolFiles -> readToolFile -> (optional) getToolDocs -> executeTool; read the stub first and use the exact callable name shown. Security: L1 code validation (no imports/classes/file-IO/network primitives), L2 sandboxed runtime (no external modules, no filesystem/network/process access except via MCP tools, memory isolation), L3 bounded execution timeout, L4 Tool ACL (only tools_to_execute-allowed CodeMode servers/tools are visible). CALLS: keyword or positional arguments; positional ones bind in the order the stub declares them (Filesystem.read_file(".")). STARLARK RULES: no try/except/raise, no classes, no imports, no f-strings (use % formatting), no is (use ==), synchronous calls only, dict access via result["key"]. RETURN: assign result, or end the script with an expression and it is returned implicitly; a script that does neither returns null and says so in logs. Each call runs in a FRESH ISOLATED SCOPE (no state persists); print() output is captured to logs. Returns {"result": ..., "logs": [...]}. BUDGET: optional timeout in seconds; omitted uses MCP_GWAY_EXEC_TIMEOUT, then 30s.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>"
    },
    "name": "executeTool"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesStarlark code calling tools as Server.tool_name(param="value") or Server.tool_name("value") — assign `result`, or end with an expression
timeoutNoWall-clock budget in seconds (float). Omit to use MCP_GWAY_EXEC_TIMEOUT, then the 30s default.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv6.8.0
    • addedInput schema / properties / timeout
      Added value: +{
      +  "description": "Wall-clock budget in seconds (float). Omit to use MCP_GWAY_EXEC_TIMEOUT, then the 30s default.",
      +  "exclusiveMinimum": 0,
      +  "type": "number"
      +}
  2. Changed1 schema field changedv6.2.0
    • changedInput schema / properties / code / description
      Previous value: -"Starlark code calling tools as result = Server.tool_name(param=\"value\") — assign `result` to your final answer"New value: +"Starlark code calling tools as Server.tool_name(param=\"value\") or Server.tool_name(\"value\") — assign `result`, or end with an expression"
  3. Addedv6.1.1

TDQS

A4.8/5.0
Behavior5/5

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

There are no annotations, so the description carries the full burden and meets it: it discloses L1-L4 security behavior, that each call runs in a fresh isolated scope with no persistent state, that print() is captured to logs, and the exact return shape {"result": ..., "logs": [...]}. It also explains what happens when no result is assigned (null plus a log notice), which is precisely the kind of non-obvious behavior an agent would otherwise discover only by failing.

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

Conciseness4/5

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

Purpose is front-loaded and every section (CALLS, STARLARK RULES, RETURN, BUDGET) carries information; nothing is filler. It is a dense single block with several all-caps inline labels, so scanning is slower than it needs to be, and the RETURN rules partially duplicate the code parameter's schema description.

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

Completeness5/5

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

For a two-parameter code-execution tool with no output schema and no annotations, the description covers the full decision surface: how to call siblings, what language subset is legal, how values are returned, what is logged, and how the time budget resolves. An agent could write a correct, first-try script from this alone.

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%, so baseline is 3, and the description adds genuine meaning beyond it: positional arguments bind in the stub's declared order, and the timeout is bounded with an exclusive minimum and resolves MCP_GWAY_EXEC_TIMEOUT then 30s. That fallback chain is restated from the schema rather than newly added, which keeps it out of 5 territory.

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?

States a specific verb and resource: executes Starlark code in a sandboxed interpreter with MCP tool access via Server.tool_name(). It also explicitly positions itself as the final step of the listToolFiles -> readToolFile -> getToolDocs -> executeTool chain, so an agent can separate it from readToolFile and listToolFiles at a glance.

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?

Gives an explicit prerequisite chain and the ordering constraint ('read the stub first and use the exact callable name shown'), which is the key failure mode for this tool. It also states an access restriction (only tools_to_execute-allowed CodeMode servers/tools are visible), so the agent knows the callable surface before writing code.

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