hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Integrations
Provides the ability to execute Python code in a sandboxed environment using pyodide, allowing safe Python code execution isolated from the operating system.
MCP 运行 Python
模型上下文协议服务器在沙箱中运行 Python 代码。
该代码使用Deno中的Pyodide执行,因此与操作系统的其余部分隔离。
请参阅https://ai.pydantic.dev/mcp/run-python/以获取完整文档。
可以使用以下命令安装deno
来运行服务器:
Copy
在哪里:
-N -R=node_modules -W=node_modules
(--allow-net --allow-read=node_modules --allow-write=node_modules
的别名)允许网络访问以及对./node_modules
的读写访问。这些是 pyodide 下载和缓存 Python 标准库和软件包所必需的。--node-modules-dir=auto
告诉 deno 使用本地node_modules
目录stdio
使用Stdio MCP 传输运行服务器 - 适合在本地将进程作为子进程运行sse
使用SSE MCP 传输运行服务器 — 将服务器作为 HTTP 服务器运行,以便进行本地或远程连接warmup
将运行一个精简的 Python 脚本来下载并缓存 Python 标准库。这对于检查服务器是否正常运行也很有用。
以下是使用@pydantic/mcp-run-python
与 PydanticAI 的示例:
Copy
This server cannot be installed
模型上下文协议服务器在沙箱中运行 Python 代码。