mcp-pyodide
一个 Pyodide 服务器,用于通过模型上下文协议 (MCP) 执行大型语言模型 (LLM) 的 Python 代码。
Tools
read-image
Read an image from a mounted directory
execute-python
Execute Python code using Pyodide with output capture. When generating images, they will be automatically saved to the output directory instead of being displayed. Images can be accessed from the saved file paths that will be included in the output.
install-python-packages
Install Python packages using Pyodide
get-mount-points
List mounted directories
list-mounted-directory
List contents of a mounted directory
README
mcp-pyodide
一个用于模型上下文协议 (MCP) 的 Pyodide 服务器实现。该服务器使大型语言模型 (LLM) 能够通过 MCP 接口执行 Python 代码。
<a href="https://glama.ai/mcp/servers/pxls43joly"> <img width="380" height="200" src="https://glama.ai/mcp/servers/pxls43joly/badge" alt="mcp-pyodide MCP server" /> </a>
特性
- 使用 Pyodide 为 LLM 提供 Python 代码执行能力
- 符合 MCP 协议的服务器实现
- 支持 stdio 和 SSE 传输模式
- 使用 TypeScript 编写的健壮实现
- 可作为命令行工具使用
安装
npm install mcp-pyodide
用法
作为服务器
import { runServer } from "mcp-pyodide";
// 启动服务器
runServer().catch((error: unknown) => {
console.error("Error starting server:", error);
process.exit(1);
});
作为命令行工具
以 stdio 模式启动(默认):
mcp-pyodide
以 SSE 模式启动:
mcp-pyodide --sse
SSE 模式
在 SSE 模式下运行时,服务器提供以下端点:
- SSE 连接:
http://localhost:3020/sse - 消息处理程序:
http://localhost:3020/messages
客户端连接示例:
const eventSource = new EventSource("http://localhost:3020/sse");
eventSource.onmessage = (event) => {
console.log("Received:", JSON.parse(event.data));
};
项目结构
mcp-pyodide/
├── src/
│ ├── formatters/ # 数据格式化处理程序
│ ├── handlers/ # 请求处理程序
│ ├── lib/ # 库代码
│ ├── tools/ # 实用工具
│ ├── utils/ # 实用函数
│ └── index.ts # 主入口点
├── build/ # 构建产物
├── pyodide-packages/ # Pyodide 相关包
└── package.json
依赖项
@modelcontextprotocol/sdk: MCP SDK (^1.4.0)pyodide: Python 运行时环境 (^0.27.1)arktype: 类型验证库 (^2.0.1)express: 用于 SSE 支持的 Web 框架cors: 用于 SSE 支持的 CORS 中间件
开发
要求
- Node.js 18 或更高版本
- npm 9 或更高版本
设置
# 克隆仓库
git clone <repository-url>
# 安装依赖
npm install
# 构建
npm run build
脚本
npm run build: 编译 TypeScript 并设置执行权限npm start: 以 stdio 模式运行服务器npm run start:sse: 以 SSE 模式运行服务器
环境变量
PYODIDE_CACHE_DIR: Pyodide 缓存目录(默认:"./cache")PYODIDE_DATA_DIR: 挂载数据目录(默认:"./data")PORT: SSE 服务器端口(默认:3020)
许可证
MIT
贡献
- Fork 仓库
- 创建一个特性分支 (
git checkout -b feature/amazing-feature) - 提交你的更改 (
git commit -am 'Add some amazing feature') - 推送到分支 (
git push origin feature/amazing-feature) - 创建一个 Pull Request
重要提示
- 该项目正在开发中,API 可能会发生变化
- 在生产环境中使用前请彻底测试
- 出于安全原因,执行不受信任的代码时请谨慎
- 使用 SSE 模式时,请确保根据需要进行正确的 CORS 配置
支持
请使用 Issue 跟踪器来报告问题和提问。
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。