MCP Catalogs
首页

mcp-python-interpreter

by yzfly·99·综合分 44

MCP Python 解释器服务器,让 LLM 能够运行 Python 代码、管理环境和处理文件,具有适当的安全隔离。

developer-toolsai-llmfile-system
36
Forks
2
活跃 Issue
7 个月前
最近提交
2 天前
收录于

概述

MCP Python 解释器是一个功能强大的服务器,使 AI 模型能够与 Python 环境交互。它提供了在不同 Python 环境中执行代码、管理软件包和执行文件操作的综合功能。该服务器通过隔离的工作目录和文件路径限制实施了安全措施,使其适用于开发工作流程。文档详尽,包含清晰的示例和安全考虑说明。

试试问 AI

装完之后,这里有 5 个你可以让 AI 做的事:

:AI 辅助 Python 开发,包括代码执行和调试
:在安全沙箱环境中执行文件操作和内容生成
:通过 LLM 交互管理 Python 环境和软件包
:采取了哪些安全措施?
:我可以使用不同的 Python 环境吗?

什么时候选它

当您需要让 AI 代理在受控环境中执行 Python 代码、管理 Python 环境和包,或在特定目录中处理文件时,选择此 MCP 服务器。

什么时候不要选它

如果您需要在隔离工作目录之外的更广泛系统访问,或需要访问超出 Python 的环境,请避免使用此服务器。

此 server 暴露的工具

从 README 抽取出 12 个工具
  • list_python_environments

    List all available Python environments (system and conda)

  • list_installed_packages

    List packages installed in a specific Python environment

  • install_package

    Install a Python package in a specific environment

  • run_python_code

    Execute Python code in a specific environment

  • run_python_file

    Execute a Python file in a specific environment

  • read_file

    Read contents of any file type, with size and safety limits

  • write_file

    Create or overwrite files with text or binary content

  • write_python_file

    Create or overwrite a Python file specifically

  • list_directory

    List Python files in a directory

  • python_function_template

    Generate a template for a Python function

  • refactor_python_code

    Help refactor Python code

  • debug_python_error

    Help debug a Python error

可对比工具

mcp-shellmcp-code-executormcp-sandbox

安装

使用 pip 安装:

pip install mcp-python-interpreter

或使用 uv:

uv install mcp-python-interpreter

Claude 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 对比

GitHub →

最后更新于 · 由 README + GitHub 公开数据自动生成。