loading…
Search for a command to run...
loading…
A locally-running Python REPL server that integrates with Claude Desktop through the Model Context Protocol, offering shell bridge, streaming, and operational m
A locally-running Python REPL server that integrates with Claude Desktop through the Model Context Protocol, offering shell bridge, streaming, and operational memory features for secure code experimentation and system automation.
A locally-running Python REPL server that integrates with Claude Desktop through the Model Context Protocol (MCP).
Completely Local: Run Python code directly on your machine without any remote dependencies
State Persistence: Maintain state between code executions (completely local)
MCP Integration: Fully compatible with Claude Desktop through the Model Context Protocol
No API Keys: No registration or signup required
Privacy-Focused: Your code never leaves your machine if you use local models
Simple & Secure: Straightforward implementation with minimal dependencies
New Additions: See Modular-Empowerment-README.md or just try the prompts!
There are several powerful use cases for a local Python REPL integrated with Claude:

git clone https://github.com/angrysky56/local-repl-mcp.git
{
"mcpServers": {
"LocalREPL": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/local-repl-mcp",
"run",
"-m",
"local_repl"
]
}
}
}


cd local-repl-mcp
# Using uv (recommended)
# uv .venv/bin/activate && uv pip install <required-packages>
# If you don't have uv installed, you can install it with:
# pip install uv
# Then if not made by the server activating via Claude you can create then activate the virtual environment with:
# uv venv --python 3.12 --seed
# Then you can activate the virtual environment with:
uv .venv/bin/activate
# And install the packages with:
uv add numpy pandas matplotlib scipy scikit-learn tensorflow torch torchvision torchtext torchaudio seaborn sympy requests networkx beautifulsoup4 jupyter fastapi
create_python_repl() - Creates a new Python REPL and returns its IDrun_python_in_repl(code, repl_id) - Runs Python code in the specified REPLlist_active_repls() - Lists all active REPL instancesget_repl_info(repl_id) - Shows information about a specific REPLdelete_repl(repl_id) - Deletes a REPL instanceAs of v0.2 the REPL is no longer Python-only. Three modules expand it into a full CLI orchestration layer:
shell_bridge.py)Run one-shot commands with structured output. Every call auto-logs to
evolution.db so past executions become queryable memory.
run_shell(command, repl_id, timeout_seconds=30, cwd=None, use_shell=False, env_extra=None)
Returns {command, cwd, stdout, stderr, exit_code, duration_ms, timed_out, truncated_stdout, truncated_stderr}.
use_shell=True enables pipes/redirects via /bin/sh. Blocklist refuses
sudo, rm -rf /, dd of=/dev/…, shutdown/reboot, fork bombs, and
chained variants like echo x && sudo poweroff.set_repl_cwd(repl_id, path) / get_repl_cwd(repl_id) - track a
working directory per REPL so subsequent run_shell calls start there.streaming.py)Long-running processes with non-blocking output drain.
spawn_shell(command, repl_id, cwd=None, use_shell=False) → returns
proc_id (separate from OS PID to avoid reuse issues).tail_shell_output(proc_id, n_lines=50, stream='both', drain=False) -
read recent lines without blocking. Use drain=True in polling loops
so the next call sees only NEW output.send_to_shell(proc_id, input_text) - write to stdin for interactive
REPLs/servers.kill_shell(proc_id, signal_name='SIGTERM') - supports SIGTERM/SIGKILL/
SIGINT/SIGHUP.wait_shell(proc_id, timeout_seconds=30) - block until exit.list_shells() / reap_exited() - inventory and cleanup.evolution_memory.py)SQLite-backed log of every shell command. Like Atuin, but queryable by the agent directly.
query_command_history(pattern=None, repl_id=None, only_failures=False, only_timeouts=False, since=None, limit=20) - pattern uses SQL LIKE (%ripgrep%), since accepts '1h', '30m', '2d', or ISO timestamps.command_stats(since=None, top_n=5) - total/pass/fail, success rate, top commands, top failures, slowest runs.tag_command(command_id, tags) - attach ['flaky', 'solved'] etc.forget_command(command_id) - delete rows that captured secrets.vacuum_memory(keep_last_n=5000) - cap db size.venv_exec.py)Run Python code inside isolated virtual environments with their own packages and interpreters.
run_python_in_venv(code, venv_path, repl_id=None) - Run Python code inside a specified virtual environment path.find_venv(path=None) - Discover python virtual environments automatically.After pulling these changes:
uv run python -m local_repl.doctor
Expects all 9 checks green before you restart Claude Desktop.
Note on unified server: The entry point modules
server.pyand__main__.pyhave been fully unified. The pyproject script commandlocal-repl-mcpis now 100% feature-complete, containing all REPL, shell, streaming, memory, and virtual environment execution tools!
The shell bridge shines when paired with modern CLI utilities that produce structured, predictable output (exit codes, JSON flags, counts-first patterns). The recipes below assume Pop!_OS 24.04 / Ubuntu 24.04; other distros use the same package names with their own package manager.
sudo apt update
sudo apt install -y bat git-delta hyperfine
fd / bat naming fix (no sudo). Debian/Ubuntu ship fd-find / bat as fdfind / batcat to avoid name collisions. Symlink the usual names so scripts work unchanged:
mkdir -p ~/.local/bin
ln -sf "$(which fdfind)" ~/.local/bin/fd
ln -sf "$(which batcat)" ~/.local/bin/bat
echo "$PATH" | tr ':' '\n' | grep -q '\.local/bin' && echo OK
ast-grep and nvm-installed npm binaries. If you use nvm, npm installs global binaries under ~/.nvm/versions/node/<ver>/bin/. That path is added to $PATH by shell init files, which don't fire when an MCP server launches via launchd/systemd. Symlink into ~/.local/bin so it's visible to any subprocess regardless of how the parent was started:
ln -sf "$(npm root -g)/../bin/ast-grep" ~/.local/bin/ast-grep
ast-grep --version
# ast-grep: structural code search/rewrite.
npm install -g @ast-grep/cli
# tokei: per-language code statistics.
cargo install tokei
# just: self-documenting command runner via uv (no sudo, no cargo compile).
uv tool install rust-just
.deb (skip cargo)Don't cargo install watchexec-cli. As of watchexec 2.5.1 the crate uses fmt::from_fn, still nightly-only on Rust 1.95 (debug_closure_helpers tracking issue #117729; stabilization PR #146099 pending). Compilation fails with error[E0658]. Use the upstream .deb instead:
WATCHEXEC_VER=2.5.1
cd /tmp
curl -fsSLO "https://github.com/watchexec/watchexec/releases/download/v${WATCHEXEC_VER}/watchexec-${WATCHEXEC_VER}-x86_64-unknown-linux-gnu.deb"
echo "9bf40f223b3651e59c99ed463c44635fa71ab3f81b69927b5343b3935a4fdb14 watchexec-${WATCHEXEC_VER}-x86_64-unknown-linux-gnu.deb" | sha256sum -c -
sudo dpkg -i "watchexec-${WATCHEXEC_VER}-x86_64-unknown-linux-gnu.deb"
For future versions, grab the matching checksum from https://github.com/watchexec/watchexec/releases/download/v<VER>/watchexec-<VER>-x86_64-unknown-linux-gnu.deb.sha256.
for cmd in rg jq fd bat delta tokei hyperfine watchexec ast-grep just; do
printf "%-12s " "$cmd"
command -v "$cmd" >/dev/null && echo "✓ $($cmd --version 2>/dev/null | head -1)" || echo "✗ MISSING"
done
Ten green checkmarks = ai-cli skill has its full toolkit.
ToolReplacesAI-relevant winrggrepRespects .gitignore; --json output; blazing fastfdfindSimpler syntax, parallel walks, respects .gitignoreast-grepregex for codeMatches code by AST pattern, not text — kills "old_string not unique" edit failuresjqsed/awk on JSONSafe, predictable JSON parsingtokeiwc -l + findPer-language code stats in one call — great first-touch overviewbatcatLine numbers + git change markers give the agent immediate contextdeltadiff viewerSide-by-side, syntax-aware diffshyperfinetime ...Statistical benchmarking with JSON exportwatchexecpolling loopsReactive file-change triggers instead of pollingjustbash scriptsSelf-documenting recipes; just --list shows every task
sg is not ast-grep. On Debian/Ubuntu sg is the setsid/script-grep binary from util-linux. Use the full name ast-grep — the ast-grep team dropped the sg shortname in 2024 for this exact reason.$$$ binds to argument lists, not arbitrary bodies. To match "any function by name" use def $NAME, not def $NAME($$$): $$$ — the latter silently returns zero matches.use_shell=True runs under /bin/sh, not bash. No brace expansion {a,b}, no [[ ]], no process substitution. Use POSIX sh syntax or invoke bash -c '...' explicitly.rg and stdin. Ripgrep's is_readable_stdin heuristic hangs waiting on stdin if the parent's stdin is a pipe. The shell bridge handles this by passing stdin=DEVNULL by default.stdin_input parameter with JSON payloads. The MCP tool-call serializer auto-parses JSON-looking strings into dicts, failing Pydantic's str check. Workaround: pipe via use_shell=True with echo '{...}' | jq ....# First create a new REPL
repl_id = create_python_repl()
# Run some code
result = run_python_in_repl(
code="x = 42\nprint(f'The answer is {x}')",
repl_id=repl_id
)
# Run more code in the same REPL (with state preserved)
more_results = run_python_in_repl(
code="import math\nprint(f'The square root of {x} is {math.sqrt(x)}')",
repl_id=repl_id
)
# Check what variables are available in the environment
environment_info = get_repl_info(repl_id)
# When done, you can delete the REPL
delete_repl(repl_id)
To run the server during development:
mcp dev server.py
Create a virtual environment:
# Using uv (recommended)
uv venv --python 3.12 --seed
# Or using standard venv
python -m venv .venv
Activate the virtual environment:
# On Linux/macOS
. .venv/bin/activate
# On Windows
.venv\Scripts\activate
cd local-repl-mcp Install the package:
# Using uv
uv pip install -e .
# Using pip
pip install -e .
Run the following command to generate a configuration file for Claude Desktop:
mcp install server.py
Выполни в терминале:
claude mcp add localrepl-mcp-server -- npx Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории development