Skip to content

Commit d016923

Browse files
committed
docs: Better reference the individual parts of the repo
1 parent 563e212 commit d016923

File tree

1 file changed

+171
-28
lines changed

1 file changed

+171
-28
lines changed

README.md

Lines changed: 171 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Model Context Protocol (MCP) Agent Frameworks Demo
22

33
This repository demonstrates the usage of Model Context Protocol (MCP) servers with several frameworks:
4-
- Google Agent Development Toolkit (ADK)
4+
- Google Agent Development Kit (ADK)
55
- LangGraph Agents
66
- OpenAI Agents
77
- Pydantic-AI Agents
@@ -18,15 +18,15 @@ Tracing is done through Pydantic Logfire.
1818
`cp .env.example .env`
1919
- Add `GEMINI_API_KEY` and/or `OPENAI_API_KEY`
2020
- Individual scripts can be adjusted to use models from any provider supported by the specific framework
21-
- By default only [basic_mcp_use/oai-agent_mcp.py](basic_mcp_use/oai-agent_mcp.py) requires `OPENAI_API_KEY`
21+
- By default only [basic_mcp_use/oai-agent_mcp.py](agents_mcp_usage/basic_mcp/basic_mcp_use/oai-agent_mcp.py) requires `OPENAI_API_KEY`
2222
- All other scripts require `GEMINI_API_KEY` (Free tier key can be created at https://aistudio.google.com/apikey)
2323
- [Optional] Add `LOGFIRE_TOKEN` to visualise evaluations in Logfire web ui
2424

2525
Run an Agent framework script e.g.:
26-
- `uv run basic_mcp_use/pydantic_mcp.py`
26+
- `uv run agents_mcp_usage/basic_mcp/basic_mcp_use/pydantic_mcp.py`
2727
- Requires `GEMINI_API_KEY` by default
2828

29-
- `uv run basic_mcp_use/oai-agent_mcp.py`
29+
- `uv run agents_mcp_usage/basic_mcp/basic_mcp_use/oai-agent_mcp.py`
3030
- Requires `OPENAI_API_KEY` by default
3131

3232
Check console or Logfire for output
@@ -35,34 +35,185 @@ Check console or Logfire for output
3535

3636
This project aims to teach:
3737
1. How to use MCP with multiple LLM Agent frameworks
38-
- Agent using a single MCP server
39-
- Agent using multi-MCP servers
38+
- Agent using a single MCP server ([basic_mcp](#basic-mcp-single-server-usage))
39+
- Agent using multiple MCP servers ([multi_mcp](#multi-mcp-advanced-usage))
4040
2. How to see traces LLM Agents with Logfire
4141
3. How to evaluate LLMs with PydanticAI evals
4242

4343
![Logfire UI](docs/images/logfire_ui.png)
4444

4545
## Repository Structure
4646

47-
- **agents_mcp_usage/basic_mcp/basic_mcp_use/** - Contains basic examples of single MCP usage:
48-
- `adk_mcp.py` - Example of using MCP with Google's Agent Development Kit (ADK)
49-
- `langgraph_mcp.py` - Example of using MCP with LangGraph
50-
- `oai-agent_mcp.py` - Example of using MCP with OpenAI Agents
51-
- `pydantic_mcp.py` - Example of using MCP with Pydantic-AI
47+
- **[agents_mcp_usage/basic_mcp/](agents_mcp_usage/basic_mcp/)** - Single MCP server integration examples
48+
- **basic_mcp_use/** - Contains basic examples of single MCP usage:
49+
- `adk_mcp.py` - Example of using MCP with Google's Agent Development Kit (ADK)
50+
- `langgraph_mcp.py` - Example of using MCP with LangGraph
51+
- `oai-agent_mcp.py` - Example of using MCP with OpenAI Agents
52+
- `pydantic_mcp.py` - Example of using MCP with Pydantic-AI
5253

53-
- **agents_mcp_usage/basic_mcp/eval_basic_mcp_use/** - Contains evaluation examples for single MCP usage:
54-
- `evals_adk_mcp.py` - Evaluation of MCP with Google's ADK
55-
- `evals_langchain_mcp.py` - Evaluation of MCP with LangGraph
56-
- `evals_pydantic_mcp.py` - Evaluation of MCP with Pydantic-AI
54+
- **eval_basic_mcp_use/** - Contains evaluation examples for single MCP usage:
55+
- `evals_adk_mcp.py` - Evaluation of MCP with Google's ADK
56+
- `evals_langchain_mcp.py` - Evaluation of MCP with LangGraph
57+
- `evals_pydantic_mcp.py` - Evaluation of MCP with Pydantic-AI
5758

58-
- **agents_mcp_usage/multi_mcp/** - Contains advanced examples of multi-MCP usage:
59-
- `multi_mcp_use/pydantic_mcp.py` - Example of using multiple MCP servers with Pydantic-AI
60-
- `eval_multi_mcp/evals_pydantic_mcp.py` - Example of evaluating the use of multiple MCP servers with Pydantic-AI
61-
- `mermaid_diagrams.py` - Generates Mermaid diagrams for visualizing MCP architecture
59+
- **[agents_mcp_usage/multi_mcp/](agents_mcp_usage/multi_mcp/)** - Advanced multi-MCP server integration examples
60+
- **multi_mcp_use/** - Contains examples of using multiple MCP servers simultaneously:
61+
- `pydantic_mcp.py` - Example of using multiple MCP servers with Pydantic-AI Agent
62+
- **eval_multi_mcp/** - Contains evaluation examples for multi-MCP usage:
63+
- `evals_pydantic_mcp.py` - Example of evaluating the use of multiple MCP servers with Pydantic-AI
6264

6365
- **Demo Python MCP Server**
6466
- `run_server.py` - Simple MCP server that runs locally, implemented in Python
6567

68+
## Basic MCP: Single Server Usage
69+
70+
The `basic_mcp` module demonstrates how to integrate a single MCP server with different agent frameworks. Each example follows a similar pattern:
71+
72+
1. **Environment Setup**: Loading environment variables and configuring logging
73+
2. **Server Connection**: Establishing a connection to the local MCP server
74+
3. **Agent Configuration**: Setting up an agent with the appropriate model
75+
4. **Execution**: Running the agent with a query and handling the response
76+
77+
The MCP server in these examples provides:
78+
- An addition tool (`add(a, b)`)
79+
- A time tool (`get_current_time()`)
80+
- A dynamic greeting resource (`greeting://{name}`)
81+
82+
### Basic MCP Architecture
83+
84+
```mermaid
85+
graph LR
86+
User((User)) --> |"Run script<br>(e.g., pydantic_mcp.py)"| Agent
87+
88+
subgraph "Agent Frameworks"
89+
Agent[Agent]
90+
ADK["Google ADK<br>(adk_mcp.py)"]
91+
LG["LangGraph<br>(langgraph_mcp.py)"]
92+
OAI["OpenAI Agents<br>(oai-agent_mcp.py)"]
93+
PYD["Pydantic-AI<br>(pydantic_mcp.py)"]
94+
95+
Agent --> ADK
96+
Agent --> LG
97+
Agent --> OAI
98+
Agent --> PYD
99+
end
100+
101+
subgraph "Python MCP Server"
102+
MCP["Model Context Protocol Server<br>(run_server.py)"]
103+
Tools["Tools<br>- add(a, b)<br>- get_current_time()"]
104+
Resources["Resources<br>- greeting://{name}"]
105+
MCP --- Tools
106+
MCP --- Resources
107+
end
108+
109+
subgraph "LLM Providers"
110+
OAI_LLM["OpenAI Models"]
111+
GEM["Google Gemini Models"]
112+
OTHER["Other LLM Providers..."]
113+
end
114+
115+
Logfire[("Logfire<br>Tracing")]
116+
117+
ADK --> MCP
118+
LG --> MCP
119+
OAI --> MCP
120+
PYD --> MCP
121+
122+
MCP --> OAI_LLM
123+
MCP --> GEM
124+
MCP --> OTHER
125+
126+
ADK --> Logfire
127+
LG --> Logfire
128+
OAI --> Logfire
129+
PYD --> Logfire
130+
131+
LLM_Response[("Response")] --> User
132+
OAI_LLM --> LLM_Response
133+
GEM --> LLM_Response
134+
OTHER --> LLM_Response
135+
```
136+
137+
#### Try the Basic MCP Examples:
138+
139+
```bash
140+
# Google ADK example
141+
uv run agents_mcp_usage/basic_mcp/basic_mcp_use/adk_mcp.py
142+
143+
# LangGraph example
144+
uv run agents_mcp_usage/basic_mcp/basic_mcp_use/langgraph_mcp.py
145+
146+
# OpenAI Agents example
147+
uv run agents_mcp_usage/basic_mcp/basic_mcp_use/oai-agent_mcp.py
148+
149+
# Pydantic-AI example
150+
uv run agents_mcp_usage/basic_mcp/basic_mcp_use/pydantic_mcp.py
151+
```
152+
153+
More details on basic MCP implementation can be found in the [basic_mcp README](agents_mcp_usage/basic_mcp/README.md).
154+
155+
## Multi-MCP: Advanced Usage
156+
157+
The `multi_mcp` module demonstrates advanced techniques for connecting to and coordinating between multiple specialized MCP servers simultaneously. This approach offers several advantages:
158+
159+
1. **Domain Separation**: Each MCP server can focus on a specific domain or set of capabilities
160+
2. **Modularity**: Add, remove, or update capabilities without disrupting the entire system
161+
3. **Scalability**: Distribute load across multiple servers for better performance
162+
4. **Specialization**: Optimize each MCP server for its specific use case
163+
164+
### Multi-MCP Architecture
165+
166+
```mermaid
167+
graph LR
168+
User((User)) --> |"Run script<br>(e.g., pydantic_mcp.py)"| Agent
169+
170+
subgraph "Agent Framework"
171+
Agent["Pydantic-AI Agent<br>(pydantic_mcp.py)"]
172+
end
173+
174+
subgraph "MCP Servers"
175+
PythonMCP["Python MCP Server<br>(run_server.py)"]
176+
NodeMCP["Node.js MCP Server<br>(mermaid-validator)"]
177+
178+
Tools["Tools<br>- add(a, b)<br>- get_current_time()"]
179+
Resources["Resources<br>- greeting://{name}"]
180+
MermaidValidator["Mermaid Diagram<br>Validation Tools"]
181+
182+
PythonMCP --- Tools
183+
PythonMCP --- Resources
184+
NodeMCP --- MermaidValidator
185+
end
186+
187+
subgraph "LLM Providers"
188+
LLMs["PydanticAI LLM call"]
189+
end
190+
191+
Logfire[("Logfire<br>Tracing")]
192+
193+
Agent --> PythonMCP
194+
Agent --> NodeMCP
195+
196+
PythonMCP --> LLMs
197+
NodeMCP --> LLMs
198+
199+
Agent --> Logfire
200+
201+
LLM_Response[("Response")] --> User
202+
LLMs --> LLM_Response
203+
```
204+
205+
#### Try the Multi-MCP Examples:
206+
207+
```bash
208+
# Run the Pydantic-AI multi-MCP example
209+
uv run agents_mcp_usage/multi_mcp/multi_mcp_use/pydantic_mcp.py
210+
211+
# Run the multi-MCP evaluation
212+
uv run agents_mcp_usage/multi_mcp/eval_multi_mcp/evals_pydantic_mcp.py
213+
```
214+
215+
More details on multi-MCP implementation can be found in the [multi_mcp README](agents_mcp_usage/multi_mcp/README.md).
216+
66217
## What is MCP?
67218

68219
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.
@@ -88,15 +239,7 @@ A key advantage highlighted is flexibility; MCP allows developers to more easily
88239
GEMINI_API_KEY=your_gemini_api_key
89240
OPENAI_API_KEY=your_openai_api_key
90241
```
91-
4. Run any of the sample scripts to see a simple MCP server being used via an Agent framework
92-
- Google Agent Development Kit (ADK)
93-
- [basic_mcp_use/adk_mcp.py](basic_mcp_use/adk_mcp.py)
94-
- LangGraph Agents
95-
- [basic_mcp_use/langgraph_mcp.py](basic_mcp_use/langgraph_mcp.py)
96-
- OpenAI Agents
97-
- [basic_mcp_use/oai-agent_mcp.py](basic_mcp_use/oai-agent_mcp.py)
98-
- Pydantic-AI Agents
99-
- [basic_mcp_use/pydantic_mcp.py](basic_mcp_use/pydantic_mcp.py)
242+
4. Run any of the sample scripts as shown in the examples above
100243

101244
## About Logfire
102245

0 commit comments

Comments
 (0)