Skip to main content
Glama
Python REPL MCP Server

Python REPL MCP Server

by hdresearch

Python REPL MCP 服务器

此 MCP 服务器提供了一个 Python REPL(读取-求值-打印循环)工具。它允许通过 MCP 协议以持久会话的方式执行 Python 代码。

设置

无需设置!该项目使用uv进行依赖管理。

Related MCP server: Python REPL MCP Server

运行服务器

只需运行:

uv run src/python_repl/server.py

与 Claude Desktop 一起使用

将此配置添加到您的 Claude Desktop 配置文件:

{
  "mcpServers": {
    "python-repl": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/python-repl-server",
        "run",
        "mcp_python"
      ]
    }
  }
}

该服务器提供了三种工具:

  1. execute_python带有持久变量的 Python 代码

    • code :要执行的 Python 代码

    • reset :可选布尔值,用于重置会话

  2. list_variables :显示当前会话中的所有变量

  3. install_package :从 pypi 安装包

示例

设置变量:

a = 42

使用变量:

print(f"The value is {a}")

列出所有变量:

# Use the list_variables tool

重置会话:

# Use execute_python with reset=true

贡献

欢迎贡献代码!欢迎提交 Pull 请求。以下是一些您可以贡献代码的方式:

  • 报告错误

  • 建议新功能

  • 改进文档

  • 添加测试用例

  • 提交代码改进

在提交 PR 之前,请确保:

  1. 您的代码遵循现有的风格

  2. 您已根据需要更新文档

  3. 也许写一些测试?

对于重大更改,请先打开一个问题来讨论您想要更改的内容。

Available Tools

3 tools
execute_pythonB

Execute Python code and return the output. Variables persist between executions.

Inputs: code (required), reset.

install_packageB

Install a Python package using uv

Inputs: package (required).

list_variablesB

List all variables in the current session

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no overlap: execute_python runs code, install_package manages dependencies, and list_variables inspects the session state. An agent can easily tell them apart as they target different aspects of the Python REPL workflow.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern (execute_python, install_package, list_variables) with clear, descriptive names. The naming convention is uniform throughout the set, making it predictable and easy to understand.

    Tool Count3/5

    With only 3 tools, the set feels thin for a Python REPL server, as it lacks operations like uninstalling packages, clearing variables, or handling errors. While the core functions are covered, the count is borderline low for the domain's typical scope.

    Completeness3/5

    The tools cover basic execution, package installation, and variable listing, but there are notable gaps: no way to update or remove packages, delete variables, or manage session state beyond listing. This could cause agent failures in more complex workflows.

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      B
      quality
      D
      maintenance
      A Python-based MCP server implementation that can be easily installed via pip or directly from GitHub, providing a simple way to deploy and run MCP server functionality.
      1
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides a persistent Python REPL session as a tool for executing code, managing files, installing packages, and initializing projects via the MCP protocol.
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      A production-grade MCP server providing a persistent Python REPL with multi-session support, sandboxing, and timeout protection, enabling LLM agents to execute Python code across multiple turns with variables that persist between calls.
      12
      21 PyPI
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Async Python REPL + Shell execution for MCP. Provides persistent state, background jobs, interactive input() bridging, and crash isolation in a single server.
      1
      Apache 2.0