
alec2435/python_mcp 是从 https://github.com/alec2435/python_mcp. 导入的 MCP 服务器候选。
概览
alec2435/python_mcp 是从 https://github.com/alec2435/python_mcp. 导入的 MCP 服务器候选。
概述(AI 翻译)
一个MCP服务器,提供交互式的Python REPL(读取-评估-打印循环)环境。
组成部分
资源
服务器提供访问REPL会话历史:
- 自定义
repl://URI方案用于访问会话历史 - 每个会话的历史可以作为文本/纯资源来看待
- 历史显示每次执行的输入代码及其对应输出
工具
服务器实现了一个工具:
python_repl:在持久会话中执行 Python 代码- 将
code(执行的 Python 代码)和session_id作为必要参数 - 为每个会话维护独立状态
- 支持表达式和语句
- 捕获并返回stdout/stderr输出
配置
安装
克劳德桌面
在MacOS上:~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows版:%APPDATA%/Claude/claude_desktop_config.json
开发/未发布服务器配置
已发布服务器配置
发展
建设与出版
准备分发套餐:
-
同步依赖关系并更新锁文件:
-
构建包发行版:
本页由 AI 翻译,技术细节请以原文为准。
README
python_local MCP Server
An MCP Server that provides an interactive Python REPL (Read-Eval-Print Loop) environment.
Components
Resources
The server provides access to REPL session history:
- Custom
repl://URI scheme for accessing session history - Each session’s history can be viewed as a text/plain resource
- History shows input code and corresponding output for each execution
Tools
The server implements one tool:
python_repl: Executes Python code in a persistent session- Takes
code(Python code to execute) andsession_idas required arguments - Maintains separate state for each session
- Supports both expressions and statements
- Captures and returns stdout/stderr output
- Takes
Configuration
Install
Claude Desktop
On MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%/Claude/claude_desktop_config.json
Development
Building and Publishing
To prepare the package for distribution:
- Sync dependencies and update lockfile:
uv sync
- Build package distributions:
uv build
This will create source and wheel distributions in the dist/ directory.
- Publish to PyPI:
uv publish
Note: You’ll need to set PyPI credentials via environment variables or command flags:
- Token:
--tokenorUV_PUBLISH_TOKEN - Or username/password:
--username/UV_PUBLISH_USERNAMEand--password/UV_PUBLISH_PASSWORD
Debugging
Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the MCP Inspector.
You can launch the MCP Inspector via npm with this command:
npx @modelcontextprotocol/inspector uv --directory /path/to/python_local run python-local
Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.
安装
uvx python_local配置
"mcpServers": {
"python_local": {
"command": "uv",
"args": [
"--directory",
"/path/to/python_local",
"run",
"python_local"
]
}
}