pydantic/pydantic-ai/mcp-run-python

pydantic/pydantic-ai/mcp-run-python

Run Python code in a secure sandbox via MCP tool calls, powered by Deno and Pyodide

13,524
Stars
1,429
Forks
20
Releases

Overview

Purpose-built to support the Model Context Protocol (MCP) in Pydantic AI, this MCP server enables agents to access external tools and data, interoperate with other agents via Agent2Agent (A2A), and drive interactive applications through streaming UI event streams. It leverages MCP alongside A2A and UI standards to empower tool calls, dynamic instructions, and structured outputs, while supporting dependency injection, human-in-the-loop tool approvals, and real-time observability through Pydantic Logfire. Key capabilities include seamless tool invocation via the tool decorator, strict type safety with RunContext-based dependencies, and durable execution to handle long-running workflows and transient errors. It also supports streamed outputs for real-time data, graph-based modeling with type hints, and a holistic approach to observability and performance monitoring. This MCP server complements Pydantic AI's emphasis on production-grade reliability, enabling developers to build agents that can access external data, collaborate across agents, and respond to users with streaming, validated results.

Details

Owner
pydantic
Language
Python
License
MIT License
Updated
2025-12-07

Features

MCP-A2A-UI Integration

Integrates MCP with Agent2Agent and UI event streams to enable external tool access, inter-agent communication, and streaming UI workflows.

Tooling and Dependency Injection

Uses the tool decorator and RunContext to register LLM-callable tools with type-safe dependencies.

Human-in-the-Loop Tool Approval

Supports flagging certain tool calls for approval before execution, with context-aware gating.

Durable Execution

Supports long-running, asynchronous workflows with progress preservation across failures and restarts.

Streamed Outputs

Provides real-time streaming of structured outputs with immediate validation.

Graph Support

Allows defining complex graphs using type hints to manage sophisticated workflows.

Observability

Tight integration with Pydantic Logfire and OpenTelemetry for real-time debugging, evals-based performance monitoring, tracing, and cost tracking.

Fully Type-Safe

Emphasizes static type checking to catch errors early and ensure consistent outputs.

Audience

DevelopersBuild GenAI agents with MCP-A2A integration and streaming UI capabilities.
Data scientistsExperiment with tools and dependencies injected into agents for rapid prototyping.

Tags

MCPModel Context ProtocolA2AUI event streamtoolsdynamic instructionsstructured outputsstreamingdurable execution