A Model Context Protocol (MCP) server for Python code execution and REPL interaction using Jupyter kernels.
Execute Python code in a new subprocess and get results immediately.
- Returns stdout, stderr, execution time, and success status
- Configurable timeout (default: 30 seconds)
- Safe subprocess execution with proper cleanup
Manage persistent Python REPL sessions powered by Jupyter kernels.
- start_repl: Create a new Python REPL session
- execute_in_repl: Execute code in existing session (variables persist)
- list_repls: View all active sessions with status info
- kill_repl: Terminate a specific session
- kill_all_repls: Terminate all sessions
- Python 3.13+
- UV package manager
- Claude Desktop
uv sync
uv run python test_client.py
- Open Claude Desktop
- Click Settings → Developer tab → Edit Config
- Add this configuration to
claude_desktop_config.json
:
{
"mcpServers": {
"pyscriptor": {
"command": "uv",
"args": ["run", "python", "main.py"],
"cwd": "D:/project/pyscript-mcp",
"env": {}
}
}
}
{
"mcpServers": {
"pyscriptor": {
"command": "D:/project/pyscript-mcp/run_server.bat",
"args": [],
"cwd": "D:/project/pyscript-mcp",
"env": {}
}
}
}
Close and restart Claude Desktop completely for changes to take effect.
Can you calculate 2^10 using Python?
Uses py-execute to run: print(2**10)
Start a Python REPL session and create some variables for data analysis.
Creates a new REPL session and sets up variables that persist between commands
1. Start a Python REPL session
2. Import pandas and numpy
3. Create a sample dataset
4. Perform some analysis
5. Show me the session status
- PythonExecutor: Handles one-time code execution via subprocess
- JupyterReplSession: Manages individual Jupyter kernel sessions
- JupyterReplManager: Coordinates multiple REPL sessions
- FastMCP Integration: Provides MCP protocol compliance
- All code execution requires explicit user approval in Claude Desktop
- Each REPL session runs in an isolated Jupyter kernel
- Subprocess execution with proper timeout and cleanup
- No automatic code execution without user consent
- Check UV is installed:
uv --version
- Verify Python 3.13+ is available
- Check project dependencies:
uv sync
- Ensure config file path is correct
- Verify absolute paths in configuration
- Check Claude Desktop logs for connection errors
- Restart Claude Desktop after config changes
- Check Jupyter dependencies are installed
- Verify kernel can start:
uv run python -c "from jupyter_client import KernelManager; print('OK')"
- Check for port conflicts or permission issues
uv run python test_client.py
uv run python debug_test.py
uv run python debug_py_execute.py
pyscript-mcp/
├── main.py # FastMCP server entry point
├── python_executor.py # Core execution logic
├── test_client.py # Test suite
├── run_server.bat # Windows startup script
├── pyproject.toml # Project configuration
└── README.md # This file
This project is for educational and development purposes.