Skip to main content
Glama

mcp-run-python

Official
by pydantic

Ejecutar Python en MCP

Servidor de protocolo de contexto de modelo para ejecutar código Python en un entorno sandbox.

El código se ejecuta utilizando Pyodide en Deno y, por lo tanto, está aislado del resto del sistema operativo.

Consulte https://ai.pydantic.dev/mcp/run-python/ para obtener la documentación completa.

El servidor se puede ejecutar con deno instalado usando:

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

dónde:

  • -N -R=node_modules -W=node_modules (alias de --allow-net --allow-read=node_modules --allow-write=node_modules ) permite el acceso de red y de lectura y escritura a ./node_modules . Estos son necesarios para que pyodide pueda descargar y almacenar en caché la biblioteca estándar y los paquetes de Python.
  • --node-modules-dir=auto le dice a deno que use un directorio node_modules local
  • stdio ejecuta el servidor con el transporte MCP de Stdio , adecuado para ejecutar el proceso como un subproceso localmente
  • sse ejecuta el servidor con el transporte SSE MCP , ejecutando el servidor como un servidor HTTP para conectarse local o remotamente
  • warmup ejecutará un script mínimo de Python para descargar y almacenar en caché la biblioteca estándar de Python. Esto también es útil para comprobar el correcto funcionamiento del servidor.

Aquí hay un ejemplo del uso de @pydantic/mcp-run-python con 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.

Servidor de protocolo de contexto de modelo para ejecutar código Python en un entorno sandbox.

Related MCP Servers

  • -
    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 -
    14
    Python
    MIT License
  • -
    security
    F
    license
    -
    quality
    A Python-based implementation of the Model Context Protocol that enables communication between a model context management server and client through a request-response architecture.
    Last updated -
    Python
    • Linux
    • Apple

View all related MCP servers

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pydantic/pydantic-ai'

If you have feedback or need assistance with the MCP directory API, please join our Discord server