Skip to main content
Glama
jkanselaar

Python Code Validator

Repair Python

repair_python
Read-onlyIdempotent

Repairs failing Python code with deterministic fixes, returning the corrected source in fixed_code and preserving the original when no safe fix exists.

Instructions

Everything validation does, plus deterministic fixes: the corrected source comes back in fixed_code, and the original is kept whenever the fix cannot be proven safe. The code is still never run. Use it when validation failed and you want the fix rather than the diagnosis. Alternatives: validate_python when the diagnosis is enough; execute_python when the fix has to be proven to run. Auth: a key is required. This call needs a paid key and answers HTTP 402 without one. Credits are bought without an account, 3 per call: GET /v1/pricing says where to send the xDAI. Arguments: code: the whole file, 1..200000 bytes of UTF-8 measured after encoding (empty is refused with 400, larger with 413); a fragment is fine, but line and column numbers in the answer count from 1 in what you sent. language: must be 'python'; anything else is 400, and the field may be omitted. options.max_iterations (1..10, default 3) caps the fix/verify rounds: raise it for a file with several independent faults, leave it for a snippet. options.optimize (default false) additionally folds constants and drops dead code, and is only worth setting when you asked for a rewrite anyway. options.transpile_to (e.g. 'javascript') returns a translation of the repaired source in transpiled, not of what you sent. fixed_code is null when nothing could be proven safe to change, so treat null as 'no fix', not as an error. options.timeout_s, options.examples and options.expected_output do nothing here: nothing is run, so there is no clock, no stdout, and no way to check an example. Returns valid, score 0..1, diagnostics (rule, message, line, column), security findings, fixes, fixed_code and runtime; see outputSchema. The code and its verdict are retained to improve the service.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesThe source to check, as a whole file where possible: diagnostics carry the line and column of the text you send, and a fragment hides the imports and definitions the type check needs. A deployment may accept fewer bytes than the 200000 here.
optionsNoTuning knobs. Most of them only take effect in the mode that does the corresponding work; see each field.
languageNoThe language of the code. A service that does not handle it refuses the request rather than guessing; the enum is shared across services, so it lists more than any one of them accepts.python

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
metaYes
fixesNo
scoreYes
validYes
runtimeNo
securityNo
fixed_codeNo
transpiledNo
diagnosticsNo
Behavior5/5

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

The description clearly discloses that 'The code is still never run', that fixed_code is null when nothing can be proven safe to change, and that the original is kept when a fix is uncertain. It also explains HTTP 402 without a paid key, credit purchases, and which options are ignored ('timeout_s, examples and expected_output do nothing here'). This adds significant behavioral context beyond the readOnly/idempotent annotations.

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 long but every sentence earns its place, covering purpose, use case, auth, all arguments, and return fields. It is front-loaded with the core promise ('plus deterministic fixes') and organized into clear thematic segments (what it does, when to use, auth, arguments, returns). The density is appropriate for the tool's complexity, with no redundant filler.

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?

All essential context is present: what the tool does, when to use it, auth requirements, parameter constraints, ignored options, null semantics for fixed_code, retention/privacy note, and a pointer to outputSchema for return details. With a complex tool and rich schema, there are no significant gaps; an agent can confidently select and invoke it correctly.

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

Parameters5/5

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

Although the input schema is highly detailed (100% coverage), the description enriches parameter meaning with specifics like '1..200000 bytes of UTF-8 measured after encoding', 'line and column numbers count from 1 in what you sent', 'language must be 'python'; anything else is 400', and per-option guidance (max_iterations for multiple independent faults, optimize for rewrites, transpile_to translating repaired source). It also clarifies which options are inert in this mode, providing value well 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?

The description opens with 'Everything validation does, plus deterministic fixes' and specifies that corrected source is returned in fixed_code while code is never run, clearly distinguishing this repair tool from pure diagnosis. It further contrasts with validate_python and execute_python, naming their exact roles, so the tool's unique purpose is unmistakable.

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?

Explicit guidance is given: 'Use it when validation failed and you want the fix rather than the diagnosis.' Alternatives are named with their appropriate use cases ('validate_python when the diagnosis is enough; execute_python when the fix has to be proven to run'). Auth prerequisites and credit costs are also stated, leaving no ambiguity about when and how to call this tool.

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/jkanselaar/python-code-validator'

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