Loading languages...
@P

@pydantic/mcp-run-python

@pydantic13792

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.

python
sandbox
deno
pyodide
mcp-server

Markdown Content: pydantic-ai/mcp-run-python at main · pydantic/pydantic-ai · GitHub

===============

Skip to content Navigation Menu

Toggle navigation

Sign in

Appearance settings

  • Product
*   [GitHub Copilot Write better code with AI](https://github.com/features/copilot)
*   [GitHub Spark New Build and deploy intelligent apps](https://github.com/features/spark)
*   [GitHub Models New Manage and compare prompts](https://github.com/features/models)
*   [GitHub Advanced Security Find and fix vulnerabilities](https://github.com/security/advanced-security)
*   [Actions Automate any workflow](https://github.com/features/actions)

*   [Codespaces Instant dev environments](https://github.com/features/codespaces)
*   [Issues Plan and track work](https://github.com/features/issues)
*   [Code Review Manage code changes](https://github.com/features/code-review)
*   [Discussions Collaborate outside of code](https://github.com/features/discussions)
*   [Code Search Find more, search less](https://github.com/features/code-search)

Explore * Why GitHub * All features * Documentation * GitHub Skills * Blog

  • Solutions

By company size * Enterprises * Small and medium teams * Startups * Nonprofits

By use case * DevSecOps * DevOps * CI/CD * View all use cases

By industry * Healthcare * Financial services * Manufacturing * Government * View all industries

View all solutions

  • Resources

Topics * AI * DevOps * Security * Software Development * View all

Explore * Learning Pathways * Events & Webinars * Ebooks & Whitepapers * Customer Stories * Partners * Executive Insights

  • Open Source
*   [GitHub Sponsors Fund open source developers](https://github.com/sponsors)

*   [The ReadME Project GitHub community articles](https://github.com/readme)

Repositories * Topics * Trending * Collections

  • Enterprise
*   [Enterprise platform AI-powered developer platform](https://github.com/enterprise)

Available add-ons * GitHub Advanced Security Enterprise-grade security features * Copilot for business Enterprise-grade AI features * Premium Support Enterprise-grade 24/7 support

Search or jump to...

Search code, repositories, users, issues, pull requests...

Search

Clear

Search syntax tips

Provide feedback

We read every piece of feedback, and take your input very seriously.

  • [x] Include my email address so I can be contacted

Cancel Submit feedback

Saved searches

Use saved searches to filter your results more quickly

Name

Query

To see all available qualifiers, see our documentation.

Cancel Create saved search

Sign in

Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert

{{ message }}

pydantic/**pydantic-ai**Public

Additional navigation options

Collapse file tree

Files

main

Search this repository

  •     .github  
    
  •     .hyperlint  
    
  •     clai  
    
  •     docs-site  
    
  •     docs  
    
  •     examples  
    
  •     mcp-run-python  
    
    •      .zed  
      
    •      src  
      
    •      stubs  
      
    •    .gitignore  
      
    •    LICENSE  
      
    •    README.md  
      
    •    build.ts  
      
    •    deno.json  
      
    •    deno.lock  
      
    •    pyproject.toml  
      
    •    test_mcp_servers.py  
      
  •     pydantic_ai_slim  
    
  •     pydantic_evals  
    
  •     pydantic_graph  
    
  •     tests  
    
  •   .gitignore  
    
  •   .pre-commit-config.yaml  
    
  •   .python-version  
    
  •   CLAUDE.md  
    
  •   LICENSE  
    
  •   Makefile  
    
  •   README.md  
    
  •   mkdocs.insiders.yml  
    
  •   mkdocs.yml  
    
  •   pyproject.toml  
    
  •   uv.lock  
    

Breadcrumbs

  1. pydantic-ai

/ mcp-run-python

/

Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

Image 1: KludexKludex

Bump mcp-run-python (#2470)

success

Aug 7, 2025

5460470·Aug 7, 2025

History

History

Open commit details

Breadcrumbs

  1. pydantic-ai

/ mcp-run-python

/

Top

Folders and files

Name Name Last commit message Last commit date
### parent directory ..
.zed .zed Revert pyodide to a version that doesn't print to stdout when install… Jun 8, 2025
src src Support streamable HTTP in mcp-run-python (#2230) Jul 21, 2025
stubs stubs MCP server to run Python code in a sandbox (#1140) Mar 17, 2025
.gitignore .gitignore moveprepare_env.pyto Python file inmcp-run-python(#1461) Apr 17, 2025
LICENSE LICENSE Add licenses to all packages (#1775) May 20, 2025
README.md README.md update logos, favicon and brand names (#2193) Jul 17, 2025
build.ts build.ts moveprepare_env.pyto Python file inmcp-run-python(#1461) Apr 17, 2025
deno.json deno.json Bump mcp-run-python (#2470) Aug 7, 2025
deno.lock deno.lock Support streamable HTTP in mcp-run-python (#2230) Jul 21, 2025
pyproject.toml pyproject.toml Switchmcp-run-pythonserver to use deno (#1340) Apr 3, 2025
test_mcp_servers.py test_mcp_servers.py Support streamable HTTP in mcp-run-python (#2230) Jul 21, 2025
View all files

README.md

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.

The server can be run with deno installed using:

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

where:

  • -N -R=node_modules -W=node_modules (alias of --allow-net --allow-read=node_modules --allow-write=node_modules) allows network access and read+write access to ./node_modules. These are required so pyodide can download and cache the Python standard library and packages
  • --node-modules-dir=auto tells deno to use a local node_modules directory
  • stdio runs the server with the Stdio MCP transport — suitable for running the process as a subprocess locally
  • sse runs the server with the SSE MCP transport — running the server as an HTTP server to connect locally or remotely
  • 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 @pydantic/mcp-run-python with Pydantic AI:

undefinedpython 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', 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()) undefined

Footer

© 2025 GitHub,Inc.

Footer navigation

You can’t perform that action at this time.

# mcpServer Config

No mcpServer Config instructions provided.

# stdio

deno run -N -R=node_modules -W=node_modules --node-modules-dir=auto jsr:@pydantic/mcp-run-python stdio
Transport:
stdio
sse
streamable
Language:
typescript
Created: 6/21/2024
Updated: 12/16/2025