mcp-run-python

Official
by pydantic

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 Run Python

Model Context Protocol -Server zum Ausführen von Python-Code in einer Sandbox.

Der Code wird mit Pyodide in Deno ausgeführt und ist daher vom Rest des Betriebssystems isoliert.

Die vollständige Dokumentation finden Sie unter https://ai.pydantic.dev/mcp/run-python/ .

Der Server kann mit installiertem deno ausgeführt werden, indem Folgendes verwendet wird:

deno run \ -N -R=node_modules -W=node_modules --node-modules-dir=auto \ jsr:@pydantic/mcp-run-python [stdio|sse|warmup]

Wo:

  • -N -R=node_modules -W=node_modules (Alias von --allow-net --allow-read=node_modules --allow-write=node_modules ) ermöglicht Netzwerkzugriff sowie Lese- und Schreibzugriff auf ./node_modules . Diese sind erforderlich, damit pyodide die Python-Standardbibliothek und -Pakete herunterladen und zwischenspeichern kann.
  • --node-modules-dir=auto weist deno an, ein lokales node_modules -Verzeichnis zu verwenden
  • stdio führt den Server mit dem Stdio MCP-Transport aus – geeignet, um den Prozess lokal als Unterprozess auszuführen
  • sse betreibt den Server mit dem SSE MCP-Transport – er betreibt den Server als HTTP-Server für lokale oder Remote-Verbindungen
  • warmup führt ein minimales Python-Skript aus, um die Python-Standardbibliothek herunterzuladen und zwischenzuspeichern. Dies ist auch nützlich, um zu überprüfen, ob der Server korrekt läuft.

Hier ist ein Beispiel für die Verwendung von @pydantic/mcp-run-python mit PydanticAI:

from pydantic_ai import Agent from pydantic_ai.mcp import MCPServerStdio import logfire logfire.configure() logfire.instrument_mcp() logfire.instrument_pydantic_ai() server = MCPServerStdio('deno', args=[ 'run', '-N', '-R=node_modules', '-W=node_modules', '--node-modules-dir=auto', 'jsr:@pydantic/mcp-run-python', 'stdio', ]) agent = Agent('claude-3-5-haiku-latest', mcp_servers=[server]) async def main(): async with agent.run_mcp_servers(): result = await agent.run('How many days between 2000-01-01 and 2025-03-18?') print(result.output) #> There are 9,208 days between January 1, 2000, and March 18, 2025.w if __name__ == '__main__': import asyncio asyncio.run(main())
-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Model Context Protocol-Server zum Ausführen von Python-Code in einer Sandbox.

Related MCP Servers

  • -
    security
    A
    license
    -
    quality
    A Model Context Protocol server that allows execution of Python code within Daytona workspaces, providing a secure and isolated environment for executing and managing Python scripts.
    Last updated -
    1
    8
    Python
    Apache 2.0
    • Apple
  • -
    security
    F
    license
    -
    quality
    A Model Context Protocol server that allows management and execution of Blender Python scripts, enabling users to create, edit and run scripts in a headless Blender environment through natural language interfaces.
    Last updated -
    4
    Python
  • -
    security
    A
    license
    -
    quality
    A Model Context Protocol server that enables seamless execution of commands, Python code, web content fetching, and reusable task management with secure credentials handling.
    Last updated -
    2
    Python
    MIT License
    • Apple
  • -
    security
    A
    license
    -
    quality
    A streamlined foundation for building Model Context Protocol servers in Python, designed to make AI-assisted development of MCP tools easier and more efficient.
    Last updated -
    12
    Python
    MIT License

View all related MCP servers

ID: 2nc0ejepw0