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.
- Install
uvif you haven't already - Clone this repository
git clone https://github.com/hdresearch/mcp-pythonSimply run:
cd mcp-python
uv run src/mcp_python/server.pyAdd this configuration to your Claude Desktop config file:
{
"mcpServers": {
"python-repl": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mcp-python",
"run",
"mcp_python"
]
}
}
}/absolute/path/to/mcp-pythonmight look like/Users/hdresearch/repos/mcp-python- if
mcp_pythonis not working, substitute withsrc/mcp_python/server.py
The server provides three tools:
-
execute_python: Execute Python code with persistent variablescode: The Python code to executereset: Optional boolean to reset the session
-
list_variables: Show all variables in the current session -
install_package: Install a package from pypi
Set a variable:
a = 42Use the variable:
print(f"The value is {a}")List all variables:
# Use the list_variables toolReset the session:
# Use execute_python with reset=trueContributions 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:
- Your code follows the existing style
- You've updated documentation as needed
- Maybe write some tests?
For major changes, please open an issue first to discuss what you would like to change.