Skip to main content
Glama

translate_to_source

Read-onlyIdempotent

Convert native-language Python code back to English-keyword Python so the interpreter, toolchain, and upstream collaborators receive the canonical source form.

Instructions

Translate native-language code back to English-keyword Python.

The inverse of translate_to_native and the round-trip half of the collaboration story: the output is the form the interpreter, the toolchain, and upstream collaborators use. The target is fixed to English — for a general X→Y translation call translate_to_native with an explicit source_lang.

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": {
      "source": "<source>",
      "source_lang": "<source_lang>"
    },
    "name": "translate_to_source"
  }
}

Input Schema

NameRequiredDescriptionDefault
sourceYesPython source text (a complete file or a fragment).
source_langYesISO 639 language code from the legesher://languages catalog.
python_versionNo3.13
verify_round_tripNoAlso verify the round trip: translate the result back, compare byte-for-byte, and check the canonical form compiles. Use this instead of comparing two renderings yourself — exact comparison over a long file is not a judgement to make by eye. Doubles translation cost; quadruples via a pivot.

Output Schema

NameRequiredDescriptionDefault
pivotedYesTrue when translated via the English pivot (X→en→Y): the engine has no direct X→Y path, so both hops rode language packs and round-trip fidelity depends on both.
round_tripNoRound-trip verification result. Present only when the tool was called with verify_round_trip: true; absent otherwise.
source_langYes
target_langYes
python_versionYes
translated_sourceYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.24.0

TDQS

A4.3/5.0
Behavior4/5

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

The annotations already declare it read-only, idempotent, non-destructive, and closed-world, so the safety profile is covered. The description adds context the annotations do not: the output is the form the interpreter and upstream collaborators expect, and round-trip verification doubles the cost (quadruples via a pivot). It does not say what happens on error, such as a language code that isn't in the catalog.

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?

The purpose and inverse relationship are front-loaded, and the alternative-tool sentence follows immediately. The line-wrapped prose is slightly verbose, but no sentence is filler.

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?

Given that an output schema exists, return values need no explanation, and the description covers purpose, the alternative tool, and the cost trade-off of verification. The remaining gaps are minor: failure modes for an invalid or unsupported source_lang, and the role of python_version.

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

Parameters3/5

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

Schema description coverage is 75%, so the schema already explains source, source_lang, and verify_round_trip. The description adds routing semantics for source_lang (the target is fixed to English, so it is not a target selector), but it says nothing about python_version, the one parameter with no schema description.

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?

The description opens with a specific verb+resource: 'Translate native-language code back to English-keyword Python.' It also states the fixed target language and that output is the canonical form used by the interpreter and toolchain, which distinguishes it precisely from the sibling translate_to_native.

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?

It gives an explicit routing rule: for a general X→Y translation, call translate_to_native with an explicit source_lang, because this tool's target is fixed to English. It also gives guidance in the schema-supplied text on when to use verify_round_trip rather than eyeballing a comparison (long files).

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