mcpField
P
PydanticAI MCP Experiment

PydanticAI MCP Experiment

Local
github.com/eschmidt42Developer Tools1Updated 73w ago

About PydanticAI MCP Experiment

PydanticAI MCP Experiment is a collection of small examples for experimenting with MCP clients and servers using pydantic_ai and local models such as Ollama.

Key features

  1. 01Examples of stdio and HTTP servers
  2. 02FastAPI and Starlette server examples
  3. 03Client and server scripts per example
  4. 04Local model and Ollama configurations

Use cases

  1. 01Explore different ways to run an MCP server
  2. 02Try an MCP client with a local model
  3. 03Modify examples while learning pydantic_ai MCP

MCP support

The project contains MCP client and server examples, including local stdio and HTTP server configurations.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

PydanticAI MCP Experiment

Minimalist examples to provide your own MCP servers to your local llm models.

Under examples/ are different configurations providing an MCP client and server using pydantic_ai and local models / ollama to get your hands dirty and tinker.

Setup

This project is uv managed. So to set up run

uv sync

Examples

There are 4 different examples for running a MCP server (locally) via:

  • Stdio -> examples/0_subprocess
  • HTTP
    • mcp.run -> examples/1_http_mcp_run
    • FastAPI -> examples/2_http_fastapi
    • Starlette -> examples/3_http_starlette

Each folder contains a client.py and server.py file.

The servers should be started before running the client.py file.

The scripts are set up such that when you change into the respective example folder you can run each simply using

python server.py

and

python client.py

Logging

Since pydantic_ai is used here the natural choice for logging is logfire. Hence upon running the client.py files you will be asked to authenticate with logfire. You can change the backend to something like otel-tui, but I tried and failed to find the prompt and response messages I wanted to see.

References

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.