mcp-python-interpreter
by yzfly·★ 99·综合分 44
MCP Python 解释器服务器,让 LLM 能够运行 Python 代码、管理环境和处理文件,具有适当的安全隔离。
概述
MCP Python 解释器是一个功能强大的服务器,使 AI 模型能够与 Python 环境交互。它提供了在不同 Python 环境中执行代码、管理软件包和执行文件操作的综合功能。该服务器通过隔离的工作目录和文件路径限制实施了安全措施,使其适用于开发工作流程。文档详尽,包含清晰的示例和安全考虑说明。
试试问 AI
装完之后,这里有 5 个你可以让 AI 做的事:
什么时候选它
当您需要让 AI 代理在受控环境中执行 Python 代码、管理 Python 环境和包,或在特定目录中处理文件时,选择此 MCP 服务器。
什么时候不要选它
如果您需要在隔离工作目录之外的更广泛系统访问,或需要访问超出 Python 的环境,请避免使用此服务器。
此 server 暴露的工具
从 README 抽取出 12 个工具list_python_environmentsList all available Python environments (system and conda)
list_installed_packagesList packages installed in a specific Python environment
install_packageInstall a Python package in a specific environment
run_python_codeExecute Python code in a specific environment
run_python_fileExecute a Python file in a specific environment
read_fileRead contents of any file type, with size and safety limits
write_fileCreate or overwrite files with text or binary content
write_python_fileCreate or overwrite a Python file specifically
list_directoryList Python files in a directory
python_function_templateGenerate a template for a Python function
refactor_python_codeHelp refactor Python code
debug_python_errorHelp debug a Python error
可对比工具
安装
使用 pip 安装:
pip install mcp-python-interpreter或使用 uv:
uv install mcp-python-interpreterClaude Desktop 配置
将以下内容添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"mcp-python-interpreter": {
"command": "uvx",
"args": [
"mcp-python-interpreter",
"--dir",
"/path/to/your/work/dir",
"--python-path",
"/path/to/your/python"
],
"env": {
"MCP_ALLOW_SYSTEM_ACCESS": 0
},
}
}
}FAQ
- 采取了哪些安全措施?
- 服务器在通过 --dir 参数指定的隔离工作目录中运行,具有文件大小限制(最多 1MB),防止在指定目录外写入,并包含显式的覆写保护。
- 我可以使用不同的 Python 环境吗?
- 是的,服务器列出了允许使用的不同 Python 环境,包括系统环境和 conda 环境,可通过 list_python_environments 工具访问。
mcp-python-interpreter 对比
最后更新于 · 由 README + GitHub 公开数据自动生成。