Skip to main content

MCP server providing a Python REPL with persistent session

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_python-0.1.4.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

mcp_python-0.1.4-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file mcp_python-0.1.4.tar.gz.

File metadata

  • Download URL: mcp_python-0.1.4.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.3

File hashes

Hashes for mcp_python-0.1.4.tar.gz
Algorithm Hash digest
SHA256 0a85ed659141126cc115da90fb139c542a9dbd0c107bc3273c3e8e8f23d8b6b1
MD5 ac29111337ed12c0e4c7f4dbb874cfb9
BLAKE2b-256 e766b6e5311c793b25b19ac9177bfbbabca867c1beb61b2cc813aa031574370d

See more details on using hashes here.

File details

Details for the file mcp_python-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_python-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9c86bc3017c7317a4980dab2a8301fc58389c44dd8c0bd9a65832f9c3870d6b8
MD5 4a213c4ebc3f81bfec9a476ef90b9e37
BLAKE2b-256 ed5f4d429de941b7b89fcf30940f4199055e334088f83729af904d141850b375

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page