Python REPL MCP Server

by hdresearch

Integrations

  • Allows installation of Python packages directly from PyPI using the install_package tool, enabling access to additional Python libraries as needed.

  • Offers a persistent Python execution environment that maintains variable state between code executions, enabling multi-step programming workflows.

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.

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

A server that provides a persistent Python REPL environment through the MCP protocol, allowing execution of Python code, variable management, and package installation.

  1. Setup
    1. Running the Server
      1. Usage with Claude Desktop
        1. Examples
          1. Contributing

            Related MCP Servers

            • -
              security
              F
              license
              -
              quality
              This is an MCP server that facilitates building tools for interacting with various APIs and workflows, supporting Python-based development with potential for customizable prompts and user configurations.
              Last updated 2 months ago
              Python
            • -
              security
              F
              license
              -
              quality
              Provides an interactive Python REPL environment that maintains persistent session state, allowing users to execute Python code and access session history.
              Last updated 5 months ago
              49
              Python
              • Apple
            • A
              security
              F
              license
              A
              quality
              An MCP server implementation that enables interaction with the Unstructured API, providing tools to list, create, update, and manage sources, destinations, and workflows.
              Last updated 20 days ago
              39
              21
              • Apple
            • -
              security
              F
              license
              -
              quality
              A demonstration server showing MCP implementation in Python with resource handling, tool operations, and reusable prompts for a simple user/post system with local database.
              Last updated a month ago
              Python
              • Apple
              • Linux

            View all related MCP servers

            ID: jsorljnhdl