Skip to main content

No project description provided

Project description

MCP Run Python

Model Context Protocol server to run Python code in a sandbox.

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

See https://ai.pydantic.dev/mcp/run-python/ for complete documentation.

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.

Here's an example of using 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())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_run_python-0.0.1.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_run_python-0.0.1-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file mcp_run_python-0.0.1.tar.gz.

File metadata

  • Download URL: mcp_run_python-0.0.1.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.20

File hashes

Hashes for mcp_run_python-0.0.1.tar.gz
Algorithm Hash digest
SHA256 4e496a936771b3099bf560e9ba16a0bce4151147bbb2dae72522cdc99d93caa2
MD5 81c63b23054110b314ab8c2417b07c44
BLAKE2b-256 cc4517c6951db5287b000315ce49ed8777df432e504c623560909a4f2b26abef

See more details on using hashes here.

File details

Details for the file mcp_run_python-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_run_python-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7516150bd2a7c9485bf3733b2143918f4197eb66e189c31f0a5793d64ba6d411
MD5 bae804193769a099b47f2bbf78f36686
BLAKE2b-256 08aa84a8a9c6b1ae71ccaed69a8c230f48ae1c5b4ad20f2f7c443f554832897b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page