MCP Python 工具箱
模型上下文协议 (MCP) 服务器为 Python 开发提供了一套全面的工具,使像 Claude 这样的 AI 助手能够有效地使用 Python 代码和项目。
概述
MCP Python Toolbox 实现了一个模型上下文协议服务器,使 Claude 能够通过标准化接口执行 Python 开发任务。它使 Claude 能够:
在工作区内读取、写入和管理文件
分析、格式化和 lint Python 代码
管理虚拟环境和依赖项
安全地执行 Python 代码
特征
文件操作( FileOperations
)
工作区目录中的安全文件操作
路径验证以防止工作区外未经授权的访问
使用特定于行的操作来读取和写入文件
创建和删除文件和目录
列出目录内容及其详细元数据(大小、类型、修改时间)
写入文件时自动创建父目录
代码分析( CodeAnalyzer
)
使用 AST 解析和分析 Python 代码结构
提取有关以下内容的详细信息:
导入语句及其别名
带有参数和装饰器的函数定义
具有基类和方法的类定义
全局变量赋值
使用以下格式代码:
黑色(默认)
PEP8(使用 autopep8)
使用 Pylint 进行全面的代码检查,并提供详细的报告
项目管理( ProjectManager
)
使用 pip 支持创建和管理虚拟环境
灵活的依赖管理:
从 requirements.txt 安装
从 pyproject.toml 安装
支持特定软件包版本
高级依赖关系处理:
检查包之间的版本冲突
列出所有已安装的软件包及其版本
将软件包更新至特定版本
从当前环境生成 requirements.txt
代码执行( CodeExecutor
)
在受控环境中执行 Python 代码
使用项目的虚拟环境来实现一致的依赖关系
代码执行的临时文件管理
捕获 stdout、stderr 和退出代码
支持自定义工作目录
安装
克隆存储库:
创建并激活虚拟环境:
以开发模式安装包:
用法
作为 CLI 工具运行
启动服务器的最简单方法是使用 CLI:
使用 Claude Desktop 进行设置
Claude Desktop 可以自动启动并管理 MCP Python Toolbox 服务器。配置方法如下:
按照上述说明安装并设置 MCP Python 工具箱
在 Claude Desktop 的 MCP 工具配置中为 Python 工具箱添加一个配置条目:
自定义路径以匹配您的环境
Claude Desktop 将在需要时自动启动 MCP 服务器
Claude 现在可以通过 MCP 接口访问 Python 开发工具
程序化使用
核心模块示例
文件操作
代码分析
项目管理
代码执行
发展
运行测试
类型检查
代码检查
格式化
贡献
分叉存储库
创建你的功能分支(
git checkout -b feature/amazing-feature
)提交您的更改(
git commit -m 'Add some amazing feature'
)推送到分支(
git push origin feature/amazing-feature
)打开拉取请求
执照
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。
致谢
实现模型上下文协议规范
采用现代 Python 开发工具和最佳实践构建
使用行业标准格式化(Black)和 linting(Pylint)工具
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server that connects Claude and other MCP clients to Aider, enabling AI assistants to efficiently edit files, create new files, and interact with git repositories through natural language.Last updated -34The Unlicense
- AsecurityAlicenseAqualityA Model Context Protocol server that enables AI assistants like Claude to interact directly with Home Assistant, allowing them to query device states, control smart home entities, and perform automation tasks.Last updated -12184MIT License
- -securityFlicense-qualityA Model Context Protocol server that extends AI capabilities by providing file system access and management functionalities to Claude or other AI assistants.Last updated -2096
- AsecurityAlicenseAqualityA Model Context Protocol server that enables AI assistants like Claude to interact with microCMS content management system through six core tools for performing CRUD operations on microCMS list-type APIs.Last updated -1020113MIT License