Skip to main content
Glama

translate_code

Translate code between programming languages, then automatically verify equivalence by running both versions on the same test inputs and comparing output.

Instructions

Port code from source language to target, then VERIFY equivalence.

An LLM translates; the executor runs BOTH versions on the same test inputs
and compares stdout. Accepted only if outputs match (one retry feeding the
diff back). Returns translated_code + per-input verification. Example:
source='python3', target='go', code='import sys

n=int(sys.stdin.readline()) print(n*2)'.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
sourceYes
targetYes
test_inputsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior4/5

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

With no annotations, the description carries the behavioral burden. It fully discloses that the tool executes both code versions, compares stdout, enforces output matching, and allows exactly one retry with diff feedback. This goes beyond the schema, though it does not cover failure modes or side effects of execution.

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

Conciseness5/5

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

The description is compact, front-loaded with the main action, and every sentence adds value: the verification mechanism, the retry policy, the return value, and a concrete example. No fluff or redundancy.

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 the tool's complexity (translation + execution + verification) and the presence of an output schema, the description covers the core workflow, retry behavior, and return type. It lacks supported-language enumeration and post-retry failure details, but the example and verification logic make it sufficiently complete for an AI agent.

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 0%, so the description must compensate. It explains 'code', 'source', and 'target' via the example, and 'test_inputs' is implied by 'same test inputs' and 'per-input verification'. However, it does not explicitly document test_inputs as optional or its null default, leaving a minor gap.

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 clearly specifies the action ('Port code from source to target') and the resource (code), with the distinctive verification step ('VERIFY equivalence') that separates it from simple translation tools. The example further anchors the purpose without ambiguity.

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

Usage Guidelines3/5

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

The description explains how the tool operates (LLM translates, executor compares stdout) but does not explicitly state when to choose this tool over siblings like 'optimize_code' or 'execute_code'. It provides context about the verification workflow but no exclusion criteria or alternative naming.

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/The-40-Thieves/codecalc'

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