Skip to main content
Glama

MCP Run Python

Official
by pydantic

Code is executed using Pyodide in Deno and is therefore isolated from the rest of the operating system.

Features

  • Secure Execution: Run Python code in a sandboxed WebAssembly environment
  • Package Management: Automatically detects and installs required dependencies
  • Complete Results: Captures standard output, standard error, and return values
  • Asynchronous Support: Runs async code properly
  • Error Handling: Provides detailed error reports for debugging

Usage

To use this server, you must have both Python and Deno installed.

The server can be run with deno installed using uvx:

uvx mcp-run-python [stdio|streamable-http|warmup]

where:

  • stdio runs the server with the Stdio MCP transport — suitable for running the process as a subprocess locally
  • streamable-http runs the server with the Streamable HTTP MCP transport - suitable for running the server as an HTTP server to connect locally or remotely. This supports stateful requests, but does not require the client to hold a stateful connection like SSE
  • warmup will run a minimal Python script to download and cache the Python standard library. This is also useful to check the server is running correctly.

Usage in codes

pip install mcp-run-python # or uv add mcp-run-python

Then you can use mcp-run-python with Pydantic AI:

from pydantic_ai import Agent from pydantic_ai.mcp import MCPServerStdio from mcp_run_python import deno_args import logfire logfire.configure() logfire.instrument_mcp() logfire.instrument_pydantic_ai() server = MCPServerStdio('deno', args=deno_args('stdio')) agent = Agent('claude-3-5-haiku-latest', toolsets=[server]) async def main(): async with agent: 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())

Logging

MCP Run Python supports emitting stdout and stderr from the python execution as MCP logging messages.

For logs to be emitted you must set the logging level when connecting to the server. By default, the log level is set to the highest level, emergency.

Currently, it's not possible to demonstrate this due to a bug in the Python MCP Client, see modelcontextprotocol/python-sdk#201.

-
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.

Enables secure execution of Python code in a sandboxed WebAssembly environment using Pyodide and Deno. Automatically handles package management and captures complete execution results including stdout, stderr, and return values.

  1. Usage
    1. Usage in codes
      1. Logging

        Related MCP Servers

        • -
          security
          A
          license
          -
          quality
          An interactive Python code execution environment that allows users and LLMs to safely execute Python code and install packages in isolated Docker containers.
          Last updated -
          24
          Apache 2.0
        • -
          security
          A
          license
          -
          quality
          An interactive Python code execution tool that allows users and LLMs to safely execute Python code and install packages in isolated Docker containers.
          Last updated -
          24
          Apache 2.0
        • -
          security
          F
          license
          -
          quality
          A secure Node.js execution environment that allows coding agents and LLMs to run JavaScript dynamically, install NPM packages, and retrieve results while adhering to the Model Control Protocol.
          Last updated -
          88
          4
        • A
          security
          A
          license
          A
          quality
          A Python code execution sandbox based on IPython and Docker. Stateful code execution, file transfer between host and container, configurable network access.
          Last updated -
          4
          34
          Apache 2.0

        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/mcp-run-python'

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