Skip to main content
Glama
Python REPL MCP Server

Python REPL MCP Server

by hdresearch

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.

Related MCP server: Python REPL MCP Server

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.

Available Tools

3 tools
execute_pythonB

Execute Python code and return the output. Variables persist between executions.

Inputs: code (required), reset.

install_packageB

Install a Python package using uv

Inputs: package (required).

list_variablesB

List all variables in the current session

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no overlap: execute_python runs code, install_package manages dependencies, and list_variables inspects the session state. An agent can easily tell them apart as they target different aspects of the Python REPL workflow.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern (execute_python, install_package, list_variables) with clear, descriptive names. The naming convention is uniform throughout the set, making it predictable and easy to understand.

    Tool Count3/5

    With only 3 tools, the set feels thin for a Python REPL server, as it lacks operations like uninstalling packages, clearing variables, or handling errors. While the core functions are covered, the count is borderline low for the domain's typical scope.

    Completeness3/5

    The tools cover basic execution, package installation, and variable listing, but there are notable gaps: no way to update or remove packages, delete variables, or manage session state beyond listing. This could cause agent failures in more complex workflows.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      B
      quality
      D
      maintenance
      A Python-based MCP server implementation that can be easily installed via pip or directly from GitHub, providing a simple way to deploy and run MCP server functionality.
      1
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides a persistent Python REPL session as a tool for executing code, managing files, installing packages, and initializing projects via the MCP protocol.
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      A 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.
      12
      31 PyPI
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Async Python REPL + Shell execution for MCP. Provides persistent state, background jobs, interactive input() bridging, and crash isolation in a single server.
      1
      Apache 2.0