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:
-
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
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:
- 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.
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
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 |
0a85ed659141126cc115da90fb139c542a9dbd0c107bc3273c3e8e8f23d8b6b1
|
|
MD5 |
ac29111337ed12c0e4c7f4dbb874cfb9
|
|
BLAKE2b-256 |
e766b6e5311c793b25b19ac9177bfbbabca867c1beb61b2cc813aa031574370d
|
File details
Details for the file mcp_python-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: mcp_python-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
9c86bc3017c7317a4980dab2a8301fc58389c44dd8c0bd9a65832f9c3870d6b8
|
|
MD5 |
4a213c4ebc3f81bfec9a476ef90b9e37
|
|
BLAKE2b-256 |
ed5f4d429de941b7b89fcf30940f4199055e334088f83729af904d141850b375
|