P

Python 绘图沙箱

qwe1453098533/python-plot-sandbox-mcp
1 Stars 73 次浏览 更新于 2026-08-23

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "python-plot": {
      "args": [
        "python-plot-sandbox-mcp"
      ],
      "command": "npx"
    }
  }
}

服务介绍

Python Plot MCP

一个专注于 Python 画图的 MCP 服务器,支持在云端执行 Python 代码并生成 matplotlib 图表。

功能特点

  • Python 沙箱执行:安全隔离的 Python 代码执行环境
  • Matplotlib 支持:内置 matplotlib 和中文字体
  • Base64 图像返回:生成的图表直接返回为 data URL
  • 完整 MCP 协议:符合 MCP 标准
  • 多种安装方式:支持 npx、pip

安装

npx python-plot-sandbox-mcp

使用

配置示例

{
  "mcpServers": {
      "python-plot": {
            "command": "npx",
                  "args": ["python-plot-sandbox-mcp"]
                      }
                        }
                        }
                        ```

                        ## 工具:run_python

                        执行 Python 代码并生成图表。

                        ### 参数

                        - `code` (string, 必需): Python 代码
                        - `timeout_s` (integer, 可选): 超时时间(秒),默认 12

                        ### 示例

                        ```python
                        import matplotlib.pyplot as plt
                        import numpy as np

                        x = np.linspace(0, 10, 100)
                        y = np.sin(x)

                        plt.figure(figsize=(10, 6))
                        plt.plot(x, y)
                        plt.title('正弦波')
                        plt.xlabel('x')
                        plt.ylabel('sin(x)')
                        plt.grid(True)
                        plt.show()
                        ```

                        ## 依赖

                        - Python 3.9+
                        - matplotlib
                        - numpy
                        - Pillow

                        ## 许可证

                        MIT

相关 MCP 服务