|
| 1 | +# Pydantic AI Evaluations with MCP |
| 2 | + |
| 3 | +This repository demonstrates the usage of a simple Model Context Protocol (MCP) server with several frameworks: |
| 4 | +- Google Agent Development Toolkit (ADK) |
| 5 | +- LangGraph Agents |
| 6 | +- OpenAI Agents |
| 7 | +- Pydantic-AI Agents |
| 8 | + |
| 9 | +Tracing is done through Pydantic Logfire. |
| 10 | + |
| 11 | +# Quickstart |
| 12 | + |
| 13 | +`cp .env.example .env` |
| 14 | +- Add `GEMINI_API_KEY` and/or `OPENAI_API_KEY` |
| 15 | + - Individual scripts can be adjusted to use models from any provider supported by the specifi framework |
| 16 | + - By default only [basic_mcp_use/oai-agent_mcp.py](basic_mcp_use/oai-agent_mcp.py) requires `OPENAI_API_KEY` |
| 17 | + - All other scripts require `GEMINI_API_KEY` |
| 18 | +- Add `LOGFIRE_TOKEN` to visualise evaluations in Logfire web ui |
| 19 | + |
| 20 | +## Project Overview |
| 21 | + |
| 22 | +This project aims to teach: |
| 23 | +1. How to use MCP with multiple LLM Agent frameworks |
| 24 | + - Example MCP tools for adding numbers, getting current time |
| 25 | +2. How to see traces LLM Agents with Logfire |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | +## Repository Structure |
| 31 | + |
| 32 | +- **basic_mcp_use/** - Contains basic examples of MCP usage: |
| 33 | + - `adk_mcp.py` - Example of using MCP with Google's Agent Development Kit (ADK) |
| 34 | + - `langgraph_mcp.py` - Example of using MCP with LangGraph |
| 35 | + - `oai-agent_mcp.py` - Examoke of using MCP with OpenAI Agents |
| 36 | + - `pydantic_mcp.py` - Example of using MCP with Pydantic-AI |
| 37 | + |
| 38 | + |
| 39 | +## What is MCP? |
| 40 | + |
| 41 | +The Model Context Protocol allows applications to provide context for LLMs in a standardised way, separating the concerns of providing context from the actual LLM interaction. |
| 42 | + |
| 43 | +Learn more: https://modelcontextprotocol.io/introduction |
| 44 | + |
| 45 | +## Setup Instructions |
| 46 | + |
| 47 | +1. Clone this repository |
| 48 | +2. Install required packages: |
| 49 | + ```bash |
| 50 | + uv sync |
| 51 | + ``` |
| 52 | +3. Set up your environment variables in a `.env` file: |
| 53 | + ``` |
| 54 | + LOGFIRE_TOKEN=your_logfire_token |
| 55 | + GEMINI_API_KEY=your_gemini_api_key |
| 56 | + OPENAI_API_KEY=your_openai_api_key |
| 57 | + ``` |
| 58 | +4. Run any of the sample scripts to see a simple MCP server being used via an Agent framework |
| 59 | +- Google Agent Development Toolkit (ADK) |
| 60 | + - [basic_mcp_use/adk_mcp.py](basic_mcp_use/adk_mcp.py) |
| 61 | +- LangGraph Agents |
| 62 | + - [basic_mcp_use/langgraph_mcp.py](basic_mcp_use/langgraph_mcp.py) |
| 63 | +- OpenAI Agents |
| 64 | + - [basic_mcp_use/oai-agent_mcp.py](basic_mcp_use/oai-agent_mcp.py) |
| 65 | +- Pydantic-AI Agents |
| 66 | + - [basic_mcp_use/pydantic_mcp.py](basic_mcp_use/pydantic_mcp.py) |
| 67 | + |
| 68 | +## About Logfire |
| 69 | + |
| 70 | +[Logfire](https://github.com/pydantic/logfire) is an observability platform from the team behind Pydantic that makes monitoring AI applications straightforward. Features include: |
| 71 | + |
| 72 | +- Simple yet powerful dashboard |
| 73 | +- Python-centric insights, including rich display of Python objects |
| 74 | +- SQL-based querying of your application data |
| 75 | +- OpenTelemetry support for leveraging existing tooling |
| 76 | +- Pydantic integration for analytics on validations |
| 77 | + |
| 78 | +Logfire gives you visibility into how your code is running, which is especially valuable for LLM applications where understanding model behavior is critical. |
0 commit comments