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

mcp-python

MCP.Pizza Chef: hdresearch

mcp-python is an MCP server that provides a Python REPL (Read-Eval-Print Loop) environment accessible through the MCP protocol. It allows users to execute Python code interactively with a persistent session, meaning variables and state are maintained across executions. The server supports executing arbitrary Python code, listing current session variables, and installing Python packages from PyPI dynamically. It requires no complex setup and uses 'uv' for dependency management, making it easy to run and integrate with MCP clients like Claude Desktop. This server is ideal for developers needing a programmable Python environment embedded within their AI workflows or agents.

Use This MCP server To

Execute Python code interactively with persistent state Dynamically install Python packages during sessions Inspect current Python session variables Integrate Python scripting into AI workflows Enable real-time Python code evaluation in MCP clients

README

Python REPL MCP Server

This MCP server provides a Python REPL (Read-Eval-Print Loop) as a tool. It allows execution of Python code through the MCP protocol with a persistent session.

Setup

No setup needed! The project uses uv for dependency management.

Running the Server

Simply run:

uv run src/python_repl/server.py

Usage with Claude Desktop

Add this configuration to your Claude Desktop config file:

{
  "mcpServers": {
    "python-repl": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/python-repl-server",
        "run",
        "mcp_python"
      ]
    }
  }
}

The server provides three tools:

  1. execute_python: Execute Python code with persistent variables

    • code: The Python code to execute
    • reset: Optional boolean to reset the session
  2. list_variables: Show all variables in the current session

  3. install_package: Install a package from pypi

Examples

Set a variable:

a = 42

Use the variable:

print(f"The value is {a}")

List all variables:

# Use the list_variables tool

Reset the session:

# Use execute_python with reset=true

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. Here are some ways you can contribute:

  • Report bugs
  • Suggest new features
  • Improve documentation
  • Add test cases
  • Submit code improvements

Before submitting a PR, please ensure:

  1. Your code follows the existing style
  2. You've updated documentation as needed
  3. Maybe write some tests?

For major changes, please open an issue first to discuss what you would like to change.

mcp-python FAQ

How do I start the mcp-python server?
Run the command 'uv run src/python_repl/server.py' to start the server with dependency management handled by uv.
Can I reset the Python session state?
Yes, the 'execute_python' tool accepts an optional 'reset' boolean parameter to clear the session variables.
How do I install new Python packages during a session?
Use the 'install_package' tool to install packages from PyPI dynamically within the running session.
Is any setup required before running the server?
No setup is needed; dependencies are managed automatically using uv.
How do I integrate mcp-python with Claude Desktop?
Add the provided JSON configuration snippet to your Claude Desktop config file to register the server.
What tools does the mcp-python server provide?
It provides 'execute_python' for code execution, 'list_variables' to show session variables, and 'install_package' to add PyPI packages.
Does the server maintain variable state between code executions?
Yes, the Python REPL session is persistent, preserving variables and state across executions.
Can I use mcp-python with other LLM providers besides Claude?
Yes, mcp-python can be integrated with any MCP-compatible client, supporting models like OpenAI GPT, Anthropic Claude, and Google Gemini.