Proves AI-generated Python does what you asked: lint, types, security, sandbox run, exact fixes.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
A hosted service that checks AI-generated Python before it ships: syntax and lint diagnostics, an AST security policy that also catches calls hidden behind dynamic imports and runtime attribute lookups, a bandit pass, a credential scan and deterministic repair β one verdict with a score. Code that parses, lints, type-checks and runs can still be wrong, so it also checks the code against what you asked for.
This repository holds the client side: the MCP configuration, the CI script and
the pre-commit hook. The service itself runs at https://api.statemind.ai, so
there is nothing to install or host.
100 validations a day, metered per UTC day. Every answer carries the state of
the allowance (x-quota-remaining, x-quota-reset), so a client can back off
before it is cut off.
Registered in the official MCP registry as
ai.statemind/python-code-validator, a name verified against the domain that
serves it rather than a GitHub account. Any MCP client adds it with one
block:
claude mcp add --transport http python-code-validator https://api.statemind.ai/mcp --header "Authorization: Bearer msvc_free_β¦"~/.cursor/mcp.json, same block..vscode/mcp.json under "servers".A client that only launches a command uses the stdio bridge in this repository instead, which forwards the same tool over HTTPS:
Or as a container, which the Dockerfile here builds:
Gemini CLI installs the same bridge as an extension, with the instruction file that makes it get used:
Three tools, named after what they do to the code:
| tool | runs the code | key |
|---|---|---|
validate_python | no | free |
repair_python β also returns fixed_code | no | paid |
execute_python β also runs it in a sandbox | yes | paid |
The old single python_code_validator tool, with its mode argument, still
answers for clients that already configured it, but is no longer listed.
Every check above passes on a function that computes the wrong answer. The one thing that catches it is the intent, and the agent that asked for the code is the only one who has it β so pass it along:
Doctest lines (>>> bitcount(127) then 7) work the same way, as do >>>
examples already written in the source. execute_python runs them in the
sandbox: one that does not hold is a python:example-mismatch error, and the
repair search returns a fix only when every example passes. On the QuixBugs
defect set β real bugs, hidden test inputs deciding correctness β that repairs
41% and refuses 77% as not doing what they say, with no false alarms on the
corrected programs.
Repeating a call costs nothing: the same key asking the same question β same
mode, same code, same examples β is answered from the answer it already got,
marked x-msvc-repeat: 1, so an agent that checks its work at every step is not
billed for verdicts that cannot have changed.
Configuring the server is not what gets it called: the instruction file is.
AGENTS.md in this repository is that text, written to be dropped
into any project under whichever name the client reads:
Cursor reads rules with front matter instead, so that one is a separate file β
copy .cursor/rules/python-code-validator.mdc
into .cursor/rules/ of the project.
The short version, if you would rather add a line to instructions you already have:
Write what the code should do as
assertexamples before writing the code, and pass them inoptions.examples. Callvalidate_pythonafter every edit andexecute_pythononce a function is finished, not again until what it does has changed. When a call returnsfixed_code, take it β the service ran it against your examples. Do not present code that came backvalid: false.
The service hands out the client, so a workflow needs no checkout of this repository and no secret:
Or as an action, from the Marketplace:
The changed Python is validated and offending lines are annotated on the diff, failing the job on syntax errors and unsafe patterns. Files the service refuses outright (over its 200 kB limit) are skipped with a warning rather than failing the run.
validate.py is standard library only, so it also works as python validate.py file.py in a Makefile, a git hook or a container:
VALIDATOR_API_KEY is used when set; otherwise the client mints a free key.
VALIDATOR_URL points it at another deployment. VALIDATOR_SOURCE names the
caller, which is only ever counted: a run inside a workflow says
github-action by itself.
A repository whose Python is checked on every pull request can say so:
mode is static, repair or execute; repair and execute need a
configured key. Submitted code is not logged.
A refused call says what to do about it, so a caller with no operator to ask can resolve it itself:
MIT.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/python-code-validator)<a href="https://allmcps.com/mcp/python-code-validator"><img src="https://allmcps.com/api/badge/python-code-validator?style=directory" alt="Python Code Validator on AllMCPs" /></a>