Pydantic RPC
PydanticRPC is a Python library for rapidly exposing Pydantic models as gRPC, ConnectRPC, and MCP services without protobuf files.
What is Pydantic RPC?
Pydantic RPC is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to pydanticrpc is a python library for rapidly exposing pydantic models as grpc, connectrpc, and mcp services without protobuf files.
PydanticRPC is a Python library for rapidly exposing Pydantic models as gRPC, ConnectRPC, and MCP services without protobuf files.
This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- PydanticRPC is a Python library for rapidly exposing Pydanti
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx pydantic-rpcConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Pydantic RPC
PydanticRPC is a Python library that lets you expose Pydantic model-based services as gRPC, ConnectRPC, and Model Context Protocol (MCP) endpoints without writing a single .proto file. It auto-generates protobuf definitions from Python type hints at runtime, supports unary and streaming patterns, and includes built-in health checks and server reflection. Developers use it to rapidly turn existing Python classes into production-grade RPC services or MCP tool servers with minimal boilerplate.
Prerequisites
- Python 3.9 or higher
- pip install pydantic-rpc (or pydantic-rpc-cli for CLI support and Hypercorn/Gunicorn servers)
- Pydantic v2 installed (pulled in automatically as a dependency)
- An MCP-compatible client such as Claude Desktop or Claude Code if using the MCP transport
- For gRPC: grpcio and grpcio-tools available in the environment
Install PydanticRPC
Install the core library. Add the CLI extra if you want the pydantic-rpc command for generating protos and running servers from the terminal.
pip install pydantic-rpc
# Or with CLI tools:
pip install pydantic-rpc-cliDefine your service with Pydantic models
Create a Python class whose methods accept and return Pydantic BaseModel instances. PydanticRPC will auto-generate the protobuf schema from these type hints.
from pydantic import BaseModel
from pydantic_rpc import AsyncIOServer
class EchoRequest(BaseModel):
message: str
class EchoResponse(BaseModel):
reply: str
class EchoService:
async def echo(self, req: EchoRequest) -> EchoResponse:
return EchoResponse(reply=f"You said: {req.message}")Run as a gRPC server
Wrap your service class in AsyncIOServer and run it. The server will auto-generate the .proto file and start listening on the specified port.
import asyncio
from pydantic_rpc import AsyncIOServer
async def main():
server = AsyncIOServer(service=EchoService(), port=50051)
await server.run()
asyncio.run(main())Run as a ConnectRPC ASGI application
Expose the same service over HTTP/1.1 and HTTP/2 using the ASGI adapter, suitable for deployment behind any ASGI server.
from pydantic_rpc import ASGIApp
app = ASGIApp(service=EchoService(), package_name="my.service")
# Run with: uvicorn script:app --port 8000Expose as an MCP tool server
Use the CLI to serve your service over the MCP transport so AI assistants can call its methods as structured tools.
pydantic-rpc serve myapp.services.EchoService --mcp --port 8000Configure your MCP client
Point Claude Desktop or another MCP client at the running server using the streamable-HTTP transport URL.
{
"mcpServers": {
"pydantic-rpc": {
"command": "python",
"args": ["-m", "pydantic_rpc.cli", "serve", "myapp.services.EchoService", "--mcp"]
}
}
}Pydantic RPC Examples
Client configuration
Configure Claude Desktop to launch your PydanticRPC MCP service directly as a subprocess.
{
"mcpServers": {
"pydantic-rpc": {
"command": "python",
"args": ["-m", "pydantic_rpc.cli", "serve", "myapp.services.EchoService", "--mcp"]
}
}
}Prompts to try
Once connected, Claude can call your service methods as MCP tools by their Python method names.
- "Call the echo method with the message 'Hello from Claude'"
- "Generate a protobuf file for the UserService class and show me the output"
- "Run the EchoService and send it ten messages, then summarize the responses"
- "Explain what tools are available from this MCP server and what each one does"Troubleshooting Pydantic RPC
Protobuf generation fails with field number conflicts after adding new fields
Set PYDANTIC_RPC_RESERVED_FIELDS=1 to reserve field numbers for backward compatibility. You can also set PYDANTIC_RPC_PROTO_PATH to a custom directory to inspect the generated .proto files.
Slow startup because protobuf is regenerated on every launch in production
Set PYDANTIC_RPC_SKIP_GENERATION=true to skip runtime protobuf generation. Pre-generate the files during your build step with 'pydantic-rpc generate myapp.services.MyService --output ./proto/'.
Nested Pydantic models are not serialized correctly in gRPC responses
Adjust PYDANTIC_RPC_SERIALIZER_STRATEGY to 'deep' or 'shallow' depending on how deeply nested models should be resolved. The default 'none' strategy may skip nested model serialization.
Frequently Asked Questions about Pydantic RPC
What is Pydantic RPC?
Pydantic RPC is a Model Context Protocol (MCP) server that pydanticrpc is a python library for rapidly exposing pydantic models as grpc, connectrpc, and mcp services without protobuf files. It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Pydantic RPC?
Follow the installation instructions on the Pydantic RPC GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with Pydantic RPC?
Pydantic RPC works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Pydantic RPC free to use?
Yes, Pydantic RPC is open source and available under the MIT license. You can use it freely in both personal and commercial projects.
Pydantic RPC Alternatives — Similar Developer Tools Servers
Looking for alternatives to Pydantic RPC? Here are other popular developer tools servers you can use with Claude, Cursor, and VS Code.
Ecc
★ 188.2kThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Javaguide
★ 155.8kJava 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发
Gemini CLI
★ 104.5kA secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
Awesome MCP Servers
★ 87.3k⭐ Curated list of Model Context Protocol (MCP) servers - tools that extend Claude Desktop, Cursor, Windsurf, and other MCP clients with custom capabilities.
MCP Servers
★ 86.0kModel Context Protocol Servers
CC Switch
★ 77.5kA cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
Browse More Developer Tools MCP Servers
Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Pydantic RPC in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Pydantic RPC?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.