Skip to content
Back to search

mcp-python-interpreter

MCP Python Interpreter: run python code. Python-mcp-server, mcp-python-server, Code Executor

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/yzfly--mcp-python-interpreter/badge.svg)](/listings/yzfly--mcp-python-interpreter)

HTML

<a href="/listings/yzfly--mcp-python-interpreter"><img src="/api/listings/yzfly--mcp-python-interpreter/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

You can install the MCP Python Interpreter using pip:

pip install mcp-python-interpreter

Or with uv:

uv install mcp-python-interpreter

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 165 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. [![MseeP.ai Security Assessment Badge](https://mseep.net/pr/yzfly-mcp-python-interpreter-badge.png)](https://mseep.ai/app/yzfly-mcp-python-interpreter)
  2. # MCP Python Interpreter
  3. A Model Context Protocol (MCP) server that allows LLMs to interact with Python environments, read and write files, execute Python code, and manage development workflows.
  4. ## Features
  5. - **Environment Management**: List and use different Python environments (system and conda)
  6. - **Code Execution**: Run Python code or scripts in any available environment
  7. - **Package Management**: List installed packages and install new ones
  8. - **File Operations**:
  9. - Read files of any type (text, source code, binary)
  10. - Write text and binary files
  11. - **Python Prompts**: Templates for common Python tasks like function creation and debugging
  12. ## Installation
  13. You can install the MCP Python Interpreter using pip:
  14. ```bash
  15. pip install mcp-python-interpreter
  16. ```
  17. Or with uv:
  18. ```bash
  19. uv tool install mcp-python-interpreter
  20. ```
  21. ## Usage with Claude Desktop
  22. 1. Install [Claude Desktop](https://claude.ai/download)
  23. 2. Open Claude Desktop, click on menu, then Settings
  24. 3. Go to Developer tab and click "Edit Config"
  25. 4. Add the following to your `claude_desktop_config.json`:
  26. ```json
  27. {
  28. "mcpServers": {
  29. "mcp-python-interpreter": {
  30. "command": "uvx",
  31. "args": [
  32. "mcp-python-interpreter",
  33. "--dir",
  34. "/path/to/your/work/dir",
  35. "--python-path",
  36. "/path/to/your/python"
  37. ],
  38. "env": {
  39. "MCP_ALLOW_SYSTEM_ACCESS": "0"
  40. }
  41. }
  42. }
  43. }
  44. ```
  45. For Windows:
  46. ```json
  47. {
  48. "mcpServers": {
  49. "python-interpreter": {
  50. "command": "uvx",
  51. "args": [
  52. "mcp-python-interpreter",
  53. "--dir",
  54. "C:\\path\\to\\your\\working\\directory",
  55. "--python-path",
  56. "/path/to/your/python"
  57. ],
  58. "env": {
  59. "MCP_ALLOW_SYSTEM_ACCESS": "0"
  60. }
  61. }
  62. }
  63. }
  64. ```
  65. 5. Restart Claude Desktop
  66. 6. You should now see the MCP tools icon in the chat interface
  67. The `--dir` parameter sets the working directory (default: the directory where the server starts). File tools and `run_python_code(save_as=...)` restrict paths to this directory unless `MCP_ALLOW_SYSTEM_ACCESS=1` is set. It is **not a sandbox** for executed Python code.
  68. ### Prerequisites
  69. - Make sure you have `uv` installed. If not, install it using:
  70. ```bash
  71. curl -LsSf https://astral.sh/uv/install.sh | sh
  72. ```
  73. - For Windows:
  74. ```powershell
  75. powershell -ExecutionPolicy Bypass -Command "iwr -useb https://astral.sh/uv/install.ps1 | iex"
  76. ```
  77. ## Available Tools
  78. The Python Interpreter provides the following tools:
  79. ### Environment and Package Management
  80. - **list_python_environments**: List all available Python environments (system and conda)
  81. - **list_installed_packages**: List packages installed in a specific environment
  82. - **install_package**: Install a Python package in a specific environment
  83. ### Code Execution
  84. - **run_python_code**: Execute Python code inline or in a subprocess. Optional `save_as` saves a `.py` file before execution; existing files require `overwrite=true`. A rejected save does not execute the code.
  85. - **run_python_file**: Execute a Python file in a specific environment
  86. ### File Operations
  87. - **read_file**: Read contents of any file type, with size and safety limits
  88. - Supports text files with syntax highlighting
  89. - Displays hex representation for binary files
  90. - **write_file**: Create or overwrite files with text or binary content
  91. - **write_python_file**: Create or overwrite a Python file specifically
  92. - **list_directory**: List Python files in a directory
  93. ## Available Resources
  94. - **python://environments**: List all available Python environments
  95. - **python://packages/{env_name}**: List installed packages for a specific environment
  96. - **python://file/{file_path}**: Get the content of a Python file
  97. - **python://directory/{directory_path}**: List all Python files in a directory
  98. ## Prompts
  99. - **python_function_template**: Generate a template for a Python function
  100. - **refactor_python_code**: Help refactor Python code
  101. - **debug_python_error**: Help debug a Python error
  102. ## Example Usage
  103. Here are some examples of what you can ask Claude to do with this MCP server:
  104. - "Show me all available Python environments on my system"
  105. - "Run this Python code in my conda-base environment: print('Hello, world!')"
  106. - "Create a new Python file called 'hello.py' with a function that says hello"
  107. - "Read the contents of my 'data.json' file"
  108. - "Write a new configuration file with these settings..."
  109. - "List all packages installed in my system Python environment"
  110. - "Install the requests package in my system Python environment"
  111. - "Run data_analysis.py with these arguments: --input=data.csv --output=results.csv"
  112. ## File Handling Capabilities
  113. The MCP Python Interpreter now supports comprehensive file operations:
  114. - Read text and binary files up to 1MB
  115. - Write text and binary files
  116. - Syntax highlighting for source code files
  117. - Hex representation for binary files
  118. - File-tool path checks within the working directory by default, including `save_as`
  119. ## Security Considerations
  120. File tools and `run_python_code(save_as=...)` check resolved paths, including symlinks, against the working directory unless `MCP_ALLOW_SYSTEM_ACCESS=1` is explicitly enabled. Existing files require an explicit overwrite flag; saved snippets use exclusive creation by default.
  121. Inline and subprocess execution run arbitrary Python with the server user's permissions. They can access files or the network independently of these file-tool checks. A subprocess separates interpreter state; it is not an operating-system sandbox. Run only trusted code, or isolate the entire server with a container or a restricted user account. Inline execution has no enforced timeout. `sys.exit()` is reported as an execution error without stopping the MCP server.
  122. ## MCP SDK compatibility
  123. Version 1.2.5 supports MCP Python SDK 1.x (`FastMCP`) and 2.x (`MCPServer`). The standalone `fastmcp` package is not required. The `MCP_TRANSPORT`, `MCP_HOST`, `MCP_PORT`, `MCP_JSON_RESPONSE`, `MCP_STATELESS_HTTP`, and transport-security environment settings work with either SDK version.
  124. ## License
  125. MIT

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.