Skip to main content

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/mcp_python/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/mcp_python",
        "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.

Metadata

Release files for mcp-python 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-python 0.1.4
File Size Uploaded
mcp_python-0.1.4.tar.gz 15.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-python 0.1.4
File Interpreter ABI Platform
mcp_python-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 21.3 kB

Release files / mcp_python-0.1.4.tar.gz

Download URL mcp_python-0.1.4.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0a85ed659141126cc115da90fb139c542a9dbd0c107bc3273c3e8e8f23d8b6b1
BLAKE2b-256 checksum
How to use checksums
e766b6e5311c793b25b19ac9177bfbbabca867c1beb61b2cc813aa031574370d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.3

Release files / mcp_python-0.1.4-py3-none-any.whl

Download URL mcp_python-0.1.4-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c86bc3017c7317a4980dab2a8301fc58389c44dd8c0bd9a65832f9c3870d6b8
BLAKE2b-256 checksum
How to use checksums
ed5f4d429de941b7b89fcf30940f4199055e334088f83729af904d141850b375
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.3

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page