repl-mcp
This server provides a persistent, stateful Python REPL that AI agents can call to run code, keep variables across calls, and orchestrate other MCP servers from within Python.
Run Python code with
execute_python(code); variables, imports, and functions persist between calls.Execute async code with top-level
await(e.g.await client.get(url)).Enforce real timeouts: runaway code gets interrupted with
KeyboardInterrupt, preserving namespace state.Survive crashes: segfaults/OOM kill only the kernel, which respawns with a clear notice.
Use the built-in
sh()helper to run shell commands and parse output directly, replacingcmd | python3 -cpipelines.Access the full filesystem with
open(), absolute paths, and~; cwd is the project directory.Call any discovered MCP server in-code via
mcp.call('server', 'tool', **args)— project, global, and plugin scopes, connected on demand.Inspect available MCP servers without connecting:
print(mcp.help())ormcp.servers.Reset the namespace with
reset=True(keepssh/mcphelpers).Install missing packages into the running environment with
sh('uv pip install ...').Aggregate large results in-REPL to stay under output truncation limits (50KB stdout / 20KB return values).
Restrict bridge scope via
--mcp-scopeif needed, or disable it with--mcp-scope none.
Provides tools for interacting with GitHub's API via the MCP bridge, enabling actions such as creating issues.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@repl-mcpimport requests and fetch the JSON from the API"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Stateful Python REPL MCP Server
A Model Context Protocol (MCP) server giving AI agents a persistent Python REPL with honest execution semantics. Code runs in a subprocess kernel (Jupyter-style): variables survive across calls, runaway code is interruptible without losing state, and crashes never take the server down. Your other MCP servers — project, global and plugin alike — are callable in-code via a pre-injected mcp bridge.
Features
Persistent State: variables, imports, and functions survive across calls (~0.1s warm calls vs ~3s per fresh
python3spawn)Real Timeouts: runaway code (sync or async) is interrupted at
timeoutseconds — KeyboardInterrupt, namespace state preserved. Cells that swallow the interrupt are killed and the kernel respawns with an explicit "variables cleared" noticeCrash Isolation: a segfault/OOM in REPL code kills only the kernel child; the server respawns it instantly
Top-level
await:await client.get(url)directly — noasyncio.run()wrapperShell Composition: pre-injected
sh()helper —json.loads(sh("gh pr view 1 --json title"))replacescmd | python3 -cpipelinesFull Filesystem Access:
open(), absolute paths, and~all work; cwd is your projectMCP Bridge:
mcp.call("server", "tool", **args)reaches every MCP server Claude Code knows — project (./.mcp.json), user/global (~/.claude.json) and plugin-provided — each connected on demand, the first time you name it. Failures stay visible inmcp.failed/mcp.help()Claude Code Plugin: one install bundles the server, a usage skill, and a Bash-nudge hook
Related MCP server: mcp-python-repl
Installation
Claude Code (plugin — recommended)
# In Claude Code:
/plugin marketplace add iota-uz/repl-mcp
/plugin install python-repl@repl-mcpRestart the session and all three components are active. Portable across machines — nothing is hand-edited in ~/.claude.json.
Migrating from a
claude mcp addinstall? Remove the old entry first:claude mcp remove python-repl -s user. Keeping both registers two REPL server processes with duplicate tools and can skew versions between them.
What the plugin bundles:
Component | What it does |
MCP server |
|
Skill ( | Teaches Claude when to reach for the REPL (instead of |
Nudge hook (PostToolUse) | When Claude runs inline Python through Bash ( |
To update later: /plugin marketplace update repl-mcp then /plugin update python-repl@repl-mcp.
Claude Code (MCP server only)
claude mcp add python-repl -- uvx --from git+https://github.com/iota-uz/repl-mcp@v2.1.2 repl-mcpPin to a tag (as above) so uvx caches the build instead of fetching GitHub on every session start.
Codex CLI
codex mcp add python-repl -- uvx --from git+https://github.com/iota-uz/repl-mcp@v2.1.2 repl-mcpClaude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"python-repl": {
"command": "uvx",
"args": ["--from", "git+https://github.com/iota-uz/repl-mcp@v2.1.2", "repl-mcp"]
}
}
}Manual (development)
git clone https://github.com/iota-uz/repl-mcp && cd repl-mcp
uv sync --extra dev
uv run repl-mcp # stdio transport (the only transport)Usage
One tool: execute_python(code, reset=False, timeout=120).
# State persists across calls
execute_python(code="import httpx; data = (await httpx.AsyncClient().get(url)).json()")
execute_python(code="len(data['items'])") # → 42
# Shell composition
execute_python(code="prs = json.loads(sh('gh pr list --json number,title'))")
# MCP bridge — see what's reachable (free, connects nothing)
execute_python(code="print(mcp.help())")
# Any scope: project, user/global, plugin. The named server starts on first call.
execute_python(code="mcp.call('github', 'create_issue', owner='me', repo='proj', title='Bug')")
execute_python(code="for f in files: mcp.call('telegram-mcp', 'download_media', **f)")
# Runaway code? Interrupted at timeout, state survives:
execute_python(code="while True: pass", timeout=5)
# → KeyboardInterrupt: execution interrupted. Namespace state ... preserved.
# Missing package? Install into the running env:
execute_python(code="sh('uv pip install openpyxl')")Notes:
The
mcpbridge sees claude.ai host connectors (Notion/Gmail/Drive/chrome) not at all — those are server-managed with nothing on disk, so call their tools directly. Everything configured locally is reachable; see Scopes below.mcp.callarguments must be JSON-serializable (they cross the kernel process boundary).Output truncates at 50KB (stdout) / 20KB (return values) — aggregate in-REPL.
reset=Trueclears variables but keepssh/mcp.
MCP bridge scopes
Discovery mirrors Claude Code's own config layout. On a name collision the highest-precedence
scope wins; the loser stays reachable as project:name / user:name / plugin:id:name.
Precedence | Scope | Source |
1 | local |
|
2 | project |
|
3 | user (global) |
|
4 | plugin | each enabled plugin's |
Servers listed in disabledMcpjsonServers are skipped. This REPL server itself is always excluded,
so mcp.call can never fork a nested bridge.
Discovery runs at startup and spawns nothing — a server process starts only when you name it in
mcp.call() (~1-3s the first time, warm after). print(mcp.help()) shows every available server
with its scope and status without connecting anything.
Security: in-REPL code can now start any of your configured MCP servers with your credentials.
Narrow it with --mcp-scope project,local (or --mcp-scope none to disable the bridge entirely).
Architecture (v2: subprocess kernel)
MCP client ── stdio ──► PARENT (FastMCP, pure async) CHILD (owns namespace)
execute_python ── EXECUTE ──────► exec / await cell
◄──── RESULT ────── captured output
timeout: SIGINT ────────────────► KeyboardInterrupt
crash: respawn + clear notice (state survives)
MCP sessions (on demand) ◄─ MCP_CALL ─ in-code mcp.* proxyThe server's event loop never blocks on REPL code; in-cell mcp.* calls are serviced on an independent channel while the cell runs. See CLAUDE.md for the full development guide.
v2.1.2 changes
Restores startup with MCP Python SDK v2 / FastMCP v4.
Migrates Streamable HTTP clients to
streamable_http_clientandhttpx2.Constrains dependency major versions so future resolver changes cannot silently select an incompatible SDK generation.
v2.1.1 changes
Discoverability fixes — v2.1.0 made global servers reachable, but an agent still had to know that:
The
mcpbridge is named in the first paragraph of theexecute_pythondescription. Clients that defer tools show agents a truncated description; everything fromHelpers:down was being cut, so the bridge was invisible exactly when it matteredrepr(mcp)now names the reachable servers instead of just listing its own methodsmcp.serversrenders as<available: [...] | live: [...]>— a bare list read as "these are running"
v2.1.0 changes
Global MCP servers are reachable: the bridge merges user-scope (
~/.claude.json), local, project and plugin configs instead of only./.mcp.jsonOn-demand connect: naming a server starts that one server; a session that never touches
mcp.*still spawns zero child processes. Failed connects are remembered briefly so a loop over a dead server doesn't pay the timeout each iterationmcp.serversnow lists what is available (any scope), not just what happens to be connected${VAR}expansion applies tocommand/args/urltoo; unset vars fail the connect with a clear reason instead of exec'ing an empty commandNew
--mcp-scopeflag (allby default)
v2.0.0 breaking changes
Removed (zero observed usage across real agent transcripts):
workspace/git/ast_utils/codepre-injected utilities (useopen()/pathlib/sh('git …')),%magiccommands andobject?queries, theinjectparameter,mcp.tools.<server>.<tool>dot-style access anddiscover_tools()(usemcp.call/mcp.list_tools), SSE transport (stdio only)Changed: execution moved to a subprocess kernel —
timeoutis now actually enforced; kernel restarts are reported explicitlyAdded: top-level
await,mcp.failed, lazy MCP connectInstall footprint dropped ~350MB (tree-sitter removed)
Development
uv run pytest tests/ -v # full suiteSee CLAUDE.md for architecture details, test map, gotchas, and the release process.
License
MIT
Available Tools
1 toolexecute_pythonExecute PythonA
Persistent Python REPL — use instead of python3 -c, heredocs or
cmd | python3 via Bash. Also the way to BATCH MCP WORK: the injected
mcp bridge reaches your project, global (user-scope) and plugin MCP
servers, so one loop replaces N separate tool calls —
for f in files: mcp.call('telegram-mcp', 'download_media', **f).
State (variables, imports, functions) survives across calls: a warm
call takes ~0.1s vs ~3s for each fresh python3 Bash spawn. Full
filesystem access — open(), absolute paths, and ~ all work. Top-level
await is supported (e.g. await client.get(url) with httpx).
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Python code to execute | |
| reset | No | Clear namespace (keeps sh/mcp helpers) | |
| timeout | No | Max execution seconds (default 120). Enforced for real: runaway code is interrupted (KeyboardInterrupt) with namespace state preserved. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden, and it delivers: state persists across calls, performance characteristics are quantified, full filesystem access is disclosed, and top-level await is supported. The schema further clarifies that timeouts interrupt with KeyboardInterrupt and preserve namespace state.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Dense but purposeful: every sentence adds value, from purpose and alternatives to the MCP batch example and performance claims. Core concepts are front-loaded, and the inline example earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a complex tool, coverage is strong: persistence, MCP bridge, filesystem access, await, reset behavior, and timeout semantics are all covered. The only notable gap is that the description does not state what the tool returns (stdout, exceptions, etc.), which matters slightly more given no output schema is present.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, and the schema fully documents code, reset (clears namespace, keeps sh/mcp helpers), and timeout (real enforcement, KeyboardInterrupt, preserved state). The description enriches what code can do (await, mcp bridge) but adds no parameter-specific semantics, so the baseline 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific verb and resource: 'Persistent Python REPL'. It immediately differentiates itself from alternatives like `python3 -c`, heredocs, and `cmd | python3` via Bash, and highlights distinctive features (state persistence, MCP bridge, top-level await).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It explicitly says 'use instead of' Bash Python invocations and explains why (persistence and ~0.1s warm vs ~3s spawn). It also declares itself the way to batch MCP work, giving a concrete example, so an agent has clear grounds to select it over alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
v2.1.1- First observed
execute_python
TDQS
Scored across 1 tool
With only one tool, there is no possibility of confusion or overlap. The tool's purpose is unambiguous and clearly described.
The single tool follows a clear verb_noun pattern (execute_python), and there are no other tools to create inconsistency.
The server is purpose-built as a Python REPL, and a single tool fully satisfies that narrow scope. The tool is powerful and not trivial, so the count is appropriate.
The tool covers all expected REPL functionality: persistent state, filesystem access, top-level await, and MCP bridging. There are no obvious gaps for the stated domain.
Maintenance
Related MCP Connectors
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
MCP server for building and testing AI agents with multi-model experimentation and insights.
Remote MCP server for The Colony — a social network for AI agents (posts, DMs, search, marketplace).
Related MCP Servers
- AlicenseAqualityDmaintenanceUniversal Python code execution MCP server that lets LLMs write and run Python for any task, with auto-install packages, streaming output, and automatic file display.91MIT
- AlicenseAqualityDmaintenanceA production-grade MCP server providing a persistent Python REPL with multi-session support, sandboxing, and timeout protection, enabling LLM agents to execute Python code across multiple turns with variables that persist between calls.121MIT
- AlicenseNot gradedqualityDmaintenanceA secure, production-grade MCP server that provides filesystem operations, AST math evaluation, and system diagnostics for LLM agents.MIT
- FlicenseCqualityDmaintenanceAn MCP server that enables AI agents to execute terminal commands and Python code on the host system, leveraging Agent Zero's battle-tested implementation with session management and smart output handling.4-