Token导航 LogoToken导航

MCP Server · 开发工具

MCP Pyrepl

一个基于FastMCP框架的轻量级Python交互式解释器服务,支持LLM以对话方式执行Python代码,包括分支执行路径和按需包安装。

stdio官方级别未说明来源级核验工具 4
包管理PythonClaude

快速开始

作者 / 组织
aiamblichus
提供方
aiamblichus
运行时
Python

工具数量

4

来源目录标注

资源数量

0

来源目录标注

提示词数量

0

来源目录标注

GitHub Star

0

仓库热度

收录来源

1 个

MCP World

选型结论

MCP Pyrepl 属于开发工具类 MCP Server,公开资料标注 4 个工具,通过stdio 本地进程接入,适配 Claude,有可以直接复制的安装命令;接入前要先准备 会话凭据。

分类

开发工具

传输方式

stdio

认证方式

会话凭据

部署方式

公开资料未说明

安装与配置

安装命令

uv run fastmcp dev src/mcp_pyrepl/server.py

公开命令不是通用的启动方式,拼不出可靠配置示例;请在客户端 MCP 配置里按官方文档填写 command 和 args。

上手步骤

  1. 1

    准备运行环境

    stdio 服务在本地起进程,需要先装好 Python,再按安装命令拉取依赖。

  2. 2

    安装服务

    复制下面的安装命令执行;命令里带占位符的位置换成自己的密钥或路径。

  3. 3

    写入客户端配置

    在客户端的 MCP 配置里填启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4

    验证是否可用

    连接成功后客户端会列出 4 个工具,随便调一个只读工具确认能返回结果。

接入前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

详细介绍

MCP PyREPL

A Model Context Protocol (MCP) server that gives an LLM a way to interact with a Python code interpreter. Built on the FastMCP framework, this lightweight, self-contained server enables LLMs (like Claude) to execute Python code in a conversational manner, supporting branching execution paths and package installation on demand without relying on the full Jupyter stack.

Features

  • Conversational Code Execution: Support for branching execution paths that match the non-linear nature of chat conversations
  • Isolated Execution: Run Python code in isolated sessions with state preservation
  • Graph-Based Code Model: Code blocks are organized in a directed acyclic graph (DAG) rather than linear cells
  • Package Installation: Install Python packages on demand within isolated environments
  • Rich Output Support: Capture and display standard output, errors, and rich content (like plots)
  • Efficient Execution: Automatic detection of which code blocks need re-execution
  • Session Management: Create and reset sessions with unique identifiers
  • MCP Integration: Fully compatible with the Model Context Protocol framework

Prerequisites

  • Python 3.13+
  • uv package manager (required for dependency installation)
  • fastmcp CLI (installed automatically with dependencies)

Available Tools

The following MCP tools are provided:

  • create_repl(): Create a new REPL session with a dedicated isolated environment. Pre-installs base packages (numpy, pandas, matplotlib, scipy, scikit-learn, seaborn, plotly) and returns a session ID.
  • run_code(session_id, code, parent_cell_id): Execute code with optional branching from a previous code block. Returns execution results (stdout, stderr, display data, images) and the new cell ID.
  • install_packages(session_id, packages): Install Python packages in the session environment using uv package manager.
  • reset_repl(session_id): Reset a session, terminating the helper process and clearing the graph state.

Important Note: To display matplotlib figures, code must call display_figure(fig) rather than plt.show() or plt.savefig(). The display_figure() function is automatically available in each session's namespace.

Architecture

The system is built on FastMCP and designed around these core components:

  1. MCP Server (server.py): Defines MCP tools using FastMCP decorators and manages user sessions with progress updates for long-running operations
  2. Session Manager (session_manager.py): Manages multiple active sessions, handles creation, retrieval, resurrection from disk, reset, and destruction
  3. Session (session.py): Handles individual session lifecycle, code execution coordination, helper process management, and ZeroMQ communication
  4. Graph Manager (graph_manager.py): Manages code blocks as a directed acyclic graph with persistence and hash-based state tracking for efficient re-execution
  5. Helper Process (helper.py): A dedicated subprocess for each active session that runs within an isolated virtual environment, executing code via IPython and communicating via ZeroMQ IPC sockets
  6. Protocol (protocol.py): Defines the Pydantic-based communication protocol for server-helper communication
  7. Shell Config (shell.py): IPython shell configuration with custom PlotCapturingShell that captures rich display outputs

Each session maintains:

  • A dedicated directory with isolated virtual environment (managed by uv)
  • A graph structure of related code blocks that supports branching execution paths
  • Runtime state between code executions (variables, imports, etc.) preserved across executions
  • A hash-based verification system to detect state changes and optimize execution (only re-executes full paths when code has changed)
  • ZeroMQ IPC sockets for inter-process communication between server and helper processes

Development

  1. Clone the repository
  2. Install dependencies:
uv install
  1. Run the server:

Using FastMCP CLI (recommended):

# Development mode with MCP Inspector
make dev
# or
uv run fastmcp dev src/mcp_pyrepl/server.py

# Production mode (stdio transport)
make run
# or
uv run fastmcp run src/mcp_pyrepl/server.py

# HTTP transport
make run-http
# or
uv run python -m mcp_pyrepl.server --transport http --port 8484

Using the installed entrypoint:

uv run mcp-pyrepl
  1. Run tests:
make test
# or
uv run pytest
  1. Clean build artifacts:
make clean

Project Structure

src/mcp_pyrepl/
├── server.py         # Main MCP server implementation
├── session.py        # Session management and execution
├── session_manager.py # Manages multiple sessions
├── graph_manager.py  # Manages code block graph and persistence
├── helper.py         # Helper process for code execution
├── protocol.py       # Communication protocol definitions
└── shell.py          # IPython shell configuration

Usage Examples

Linear Code Execution

# Create a new session (base packages are pre-installed)
session_id = await create_repl()

# Install additional packages if needed
await install_packages(session_id, ["requests"])

# Run initial code (no parent)
result_1 = await run_code(
    session_id=session_id,
    code="import numpy as np\nimport matplotlib.pyplot as plt",
    parent_cell_id=None
)
cell_1 = result_1[-1].text  # Extract cell ID from response

# Run code that builds on the previous code
result_2 = await run_code(
    session_id=session_id,
    code="""x = np.linspace(0, 10, 100)
y = np.sin(x)""",
    parent_cell_id=cell_1
)
cell_2 = result_2[-1].text  # Extract cell ID from response

# Run a plotting cell that depends on the previous code
# Note: Use display_figure() instead of plt.show()
result_3 = await run_code(
    session_id=session_id,
    code="""fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_title('Sine Wave')
display_figure(fig)""",
    parent_cell_id=cell_2
)

Branching Code Execution

# Create a branch from cell_2 with different analysis
result_3a = await run_code(
    session_id=session_id,
    code="""# Calculate some statistics
mean = np.mean(y)
std = np.std(y)
print(f"Mean: {mean}, Std Dev: {std}")""",
    parent_cell_id=cell_2
)
cell_3a = result_3a[-1].text  # Extract cell ID from response

# Create another branch with a different visualization
result_3b = await run_code(
    session_id=session_id,
    code="""# Create a different plot
fig, ax = plt.subplots()
ax.scatter(x, y)
ax.set_title('Sine Wave Scatter')
display_figure(fig)""",
    parent_cell_id=cell_2
)
cell_3b = result_3b[-1].text  # Extract cell ID from response

Resetting a Session

# Reset a session, clearing all state and terminating the helper process
await reset_repl(session_id)
# The helper process will be recreated automatically on next code execution

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

工具与能力

工具数量

4

资源数量

0

提示词数量

0

能力标签

Python执行Python本地部署交互式编程代码分支包管理会话管理

支持客户端

Claude

数量来自来源目录的标注,具体工具清单以官方文档为准。

典型使用场景

让助手直接读代码

把仓库、提交记录和 issue 交给模型检索,补全和重构时不用来回复制文件。

在对话里跑命令

触发构建、测试和脚本,执行结果直接回到上下文,省去切终端。

接进开发流程

把 PR、CI 状态和代码审查接进助手,减少在几个工具之间跳。

选择建议

值得选的地方

  • 只提供 4 个工具,职责集中,接入后不容易误操作。
  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 公开说明写得比较完整,接入前能看清能力边界。

先想清楚的地方

  • stdio 方式要求本地装好 Python,换机器要重新装一遍。
  • 需要自备会话凭据,没有凭据没法直接试。
  • 第三方目录整理,版本更新和行为细节以官方仓库为准。

更适合

  • 需要在开发工具场景里让模型直接调用外部能力的人。
  • 已经在用 Claude 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 暂时拿不到会话凭据的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

5 个同类
MCP Server工具数传输方式安装命令收录来源最后核验
MCP Pyrepl

MCP World · 本页

4stdio有1 个2026-05-17
Git 838e2ec1

MCP World

12stdio有2 个2026-05-17
Markitdown MCP 2c653a5f

MCP World

1stdio有1 个2026-05-17
Context7 MCP C671e75a

MCP World

0stdio有1 个2026-05-17
Context7 831acf40

MCP World

0stdio有1 个2026-05-17

按同分类和工具数量挑出最接近的几条,字段以各自详情页为准。

常见问题

5 条

MCP Pyrepl 怎么安装?

公开资料给出的安装命令是 uv run fastmcp dev src/mcp_pyrepl/server.py,运行环境为 Python。装完后按客户端要求写进 MCP 配置,重启客户端生效。

MCP Pyrepl 怎么在 Claude Desktop、Cursor 里配置?

它是stdio 本地进程,客户端配置里要写启动命令和参数,运行环境是 Python;保存后完全退出客户端再打开,配置才会生效。

MCP Pyrepl 收费吗?

本站只整理公开资料,不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

MCP Pyrepl 需要 API Key 吗?

公开资料标注的认证方式是会话凭据,也就是要先拿到凭据才能连上;凭据只填在自己本地的配置里,不要写进公开仓库。

MCP Pyrepl 支持哪些客户端?

公开资料标注支持 Claude;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

来源信息

继续浏览同类 MCP