Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AIFire in da houseCheck it out free

python_mcp

MCP.Pizza Chef: Alec2435

The python_mcp is an MCP server that offers an interactive Python REPL environment for executing Python code locally. It supports persistent sessions, allowing separate state management per session, and captures both stdout and stderr outputs. Users can access session history through a custom repl:// URI scheme, viewing input code and corresponding outputs as plain text resources. This server is ideal for integrating live Python code execution into AI workflows, enabling real-time code evaluation and debugging within the MCP ecosystem.

Use This MCP server To

Execute Python code interactively within MCP workflows Maintain persistent Python REPL sessions with state Access and review Python REPL session history Capture and return stdout and stderr from Python code Integrate live Python code execution in AI agents Debug Python scripts interactively via MCP Run Python expressions and statements remotely

README

python_local MCP Server

An MCP Server that provides an interactive Python REPL (Read-Eval-Print Loop) environment.

Components

Resources

The server provides access to REPL session history:

  • Custom repl:// URI scheme for accessing session history
  • Each session's history can be viewed as a text/plain resource
  • History shows input code and corresponding output for each execution

Tools

The server implements one tool:

  • python_repl: Executes Python code in a persistent session
    • Takes code (Python code to execute) and session_id as required arguments
    • Maintains separate state for each session
    • Supports both expressions and statements
    • Captures and returns stdout/stderr output

Configuration

Install

Claude Desktop

On MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json On Windows: %APPDATA%/Claude/claude_desktop_config.json

Development/Unpublished Servers Configuration ```json "mcpServers": { "python_local": { "command": "uv", "args": [ "--directory", "/path/to/python_local", "run", "python_local" ] } } ```
Published Servers Configuration ```json "mcpServers": { "python_local": { "command": "uvx", "args": [ "python_local" ] } } ```

Development

Building and Publishing

To prepare the package for distribution:

  1. Sync dependencies and update lockfile:
uv sync
  1. Build package distributions:
uv build

This will create source and wheel distributions in the dist/ directory.

  1. Publish to PyPI:
uv publish

Note: You'll need to set PyPI credentials via environment variables or command flags:

  • Token: --token or UV_PUBLISH_TOKEN
  • Or username/password: --username/UV_PUBLISH_USERNAME and --password/UV_PUBLISH_PASSWORD

Debugging

Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the MCP Inspector.

You can launch the MCP Inspector via npm with this command:

npx @modelcontextprotocol/inspector uv --directory /path/to/python_local run python-local

Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.

python_mcp FAQ

How do I install the python_mcp server on my machine?
For Claude Desktop, configure the server in claude_desktop_config.json located at ~/Library/Application Support/Claude/ on MacOS or %APPDATA%/Claude/ on Windows. Follow the provided JSON configuration snippet for setup.
Can python_mcp maintain separate states for multiple Python sessions?
Yes, python_mcp supports multiple sessions, each with its own persistent state, allowing isolated execution contexts.
How does python_mcp expose session history?
It uses a custom repl:// URI scheme to provide access to session history as text/plain resources showing input code and output.
What types of Python code can I run with python_mcp?
You can run both Python expressions and statements, with outputs and errors captured and returned.
Does python_mcp capture error output from Python code?
Yes, it captures both stdout and stderr, returning any error messages generated during execution.
Is python_mcp limited to any specific Python version?
The server runs Python code locally, so it uses the installed Python interpreter version on the host machine.
Can python_mcp be integrated with other LLM providers besides OpenAI?
Yes, it is compatible with MCP clients using models from OpenAI, Anthropic Claude, and Google Gemini, among others.
How is the python_mcp server secured when running code?
Security depends on the host environment; it runs code locally, so standard OS-level security and sandboxing should be applied as needed.