Skip to main content
Glama

Create Python tool

create_python_tool
Destructive

Create a custom Python tool an agent can call: code run in the sandbox, with the internet, the Vault read-only at /data and 30 s a call. _args is the call's arguments as a dict; what the code prints is the tool's result (print JSON for structured results). Its code reads no workspace variable until a person adds one in the tool's editor (Tools, the tool, 'Variables this tool can read'): when it needs a key, name the variable and say so. Prove it with test_python_tool. Re-creating a Python tool with an existing name replaces it, keeping the variables a person added.

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": {
      "name": "<name>",
      "description": "<description>",
      "code": "<code>"
    },
    "name": "create_python_tool"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesThe Python source. Reads `_args`, prints its result.
nameYesUnique tool name (snake_case, e.g. region_totals)
groupNoOptional group name to file the tool under
read_onlyNofalse when this GET changes something (e.g. /send?to=…). Omit otherwise.
idempotentNofalse when calling twice does the work twice (books two rooms). Omit otherwise.
open_worldNoEvery HTTP tool reaches outside this workspace; omit.
descriptionYesWhat the tool does — the model reads this to decide when to call it
destructiveNotrue when a call deletes, cancels, pays or sends something that cannot be undone. Omit otherwise.
confirm_tokenNoLeave out at first: the answer previews what this would do and gives a token. Call again with the same arguments and that token to do it.
input_schema_jsonNoJSON Schema object describing the tool's arguments, e.g. '{"type":"object","properties":{"path":{"type":"string"}},"required":["path"]}'

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.5/5.0
Behavior5/5

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

Annotations already declare destructiveHint=true and idempotentHint=false; the description goes further by naming the destructive mechanism (same-name re-creation replaces the tool, though person-added variables survive) and the sandbox constraints (30 s cap, read-only Vault, internet). It also discloses a non-obvious permission model: code reads no workspace variable until a human adds one in the editor. The 'with the internet' phrasing describes the created tool, not this one, so it does not conflict with openWorldHint=false.

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?

One dense paragraph, front-loaded with the definition and followed by runtime limits, argument contract, and replacement behavior — no filler sentences. The inline navigation parenthetical ('Tools, the tool, "Variables this tool can read"') is wordy but earns its place by telling the agent what to relay to a user.

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?

For a 10-parameter mutation tool with no output schema, the description covers runtime, limits, argument/output contract, testing, and replacement semantics. It leaves the confirm_token preview flow and the read_only/idempotent/open_world flags to the schema, which documents them adequately, so nothing critical is missing.

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 real meaning on top: `_args` is the call's argument dict and printed output becomes the tool's result (JSON for structured results). It also explains the human-gated variable binding, which is what makes input_schema_json and the variable editor coherent together.

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 ('Create a custom Python tool an agent can call') and immediately bounds the artifact: sandboxed execution, internet access, read-only Vault at /data, 30 s per call. That runtime profile is what separates it from the HTTP-tool siblings without the agent needing to open a schema.

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

Usage Guidelines4/5

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

Gives a clear post-creation workflow ('Prove it with test_python_tool') and a re-use rule ('Re-creating a Python tool with an existing name replaces it'), plus the escalation path when a key is needed. It does not explicitly say when to prefer this over create_http_tool, so the alternative-selection guidance is implied rather than stated.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.