Skip to content
Back to search

pydantic-ai-multi-mcp-agent

Autonomous ReAct AI Agent orchestrating Multi-MCP Servers (M=3: Time, Weather, Airbnb) with PydanticAI over OpenAI-compatible AMD Token Lab, ROCm vLLM, Ollama, and LM Studio endpoints.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/goldcode1618--pydantic-ai-multi-mcp-agent/badge.svg)](/listings/goldcode1618--pydantic-ai-multi-mcp-agent)

HTML

<a href="/listings/goldcode1618--pydantic-ai-multi-mcp-agent"><img src="/api/listings/goldcode1618--pydantic-ai-multi-mcp-agent/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

1. Prerequisites

- Python `>= 3.10` - Node.js & `npx` available on system `PATH` (required by `@openbnb/mcp-server-airbnb`)

2. Install Dependencies

pip install -r requirements.txt

3. Configure `.env`

cp .env.example .env

Edit `.env` with your target endpoint:

BASE_URL=http://localhost:8000/v1
OPENAI_API_KEY=abc-123
MODEL_NAME=Qwen3-30B-A3B
LOCAL_TIMEZONE=Asia/Jakarta

4. Verify Environment & Endpoint Reachability (`--check`)

Memeriksa ketersediaan `python`, `npx`, modul MCP (`mcp_server_time`, `mcp_weather_server`), validitas konfigurasi, dan keterjangkauan `BASE_URL/models`:

python main.py --check

5. Run One-Shot or Interactive Mode

# One-shot prompt execution
python main.py --prompt "Plan a 3-day trip to Bandung next week for 2 guests based on the best weather window and find Airbnb options."

# Interactive REPL mode (type 'exit' or 'quit' to leave)
python main.py

6. Run Unit Tests

pytest -v

---

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 122 lines
  1. # PydanticAI Multi-MCP ReAct Agent (`M = 3`)
  2. [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](./LICENSE)
  3. [![Python](https://img.shields.io/badge/Python-3.10%2B-3776AB?logo=python&logoColor=white)](https://www.python.org/)
  4. [![PydanticAI](https://img.shields.io/badge/PydanticAI-1.66.0-E92063)](https://ai.pydantic.dev/)
  5. [![MCP](https://img.shields.io/badge/MCP_Servers-M%3D3-00897B)](https://modelcontextprotocol.io/)
  6. [![AMD Ecosystem](https://img.shields.io/badge/AMD-Token_Lab_%7C_ROCm_vLLM-ED1C24?logo=amd)](https://github.com/Goldcode1618/amd-heterogeneous-ai-lab)
  7. A standalone, portable, and production-hardened **ReAct AI Agent** built with **PydanticAI** (`pydantic-ai-slim[mcp]==1.66.0`) that orchestrates **$M = 3$ Model Context Protocol (MCP) servers** simultaneously over any OpenAI-compatible inference endpoint — including **AMD Token Lab** (`Gemma-4-31B-IT`), **ROCm `vLLM` on AMD Instinct MI300X** (`Qwen3-30B-A3B`), **Ollama**, and **LM Studio**.
  8. Developed as the reference agentic architecture for **AMD AI Academy (`ACAD-B05` AI Agents 101 & `ACAD-B06` AI Agents 201)** and part of the [`Goldcode1618/amd-heterogeneous-ai-lab`](https://github.com/Goldcode1618/amd-heterogeneous-ai-lab) research ecosystem.
  9. ---
  10. ## Architecture & ReAct Orchestration Flow
  11. The agent binds three independent `MCPServerStdio` toolsets into a unified PydanticAI `Agent` and resolves tool-name collisions deterministically by applying `tool_prefix="weather"` to `mcp-weather-server` (preventing `convert_time` collision with `mcp-server-time`).
  12. ```mermaid
  13. flowchart LR
  14. U["User Prompt / CLI"] --> A["PydanticAI ReAct Agent\n(OpenAIChatModel)"]
  15. A <-->|"OpenAI-Compatible API\n(Token Lab / ROCm vLLM / Ollama)"| LLM["Hosted / Local LLM"]
  16. A -->|"1. get_current_time"| T["Time MCP Server\n(mcp-server-time)"]
  17. A -->|"2. weather_get_weather_byDateTimeRange"| W["Weather MCP Server\n(mcp-weather-server, prefix='weather')"]
  18. A -->|"3. airbnb_search & airbnb_listing_details"| B["Airbnb MCP Server\n(@openbnb/mcp-server-airbnb via npx)"]
  19. ```
  20. ### Orchestrated MCP Servers ($M = 3$)
  21. | # | Server | Transport / Runtime | Tool Prefix | Role in ReAct Cycle |
  22. |---|---|---|---|---|
  23. | 1 | **Time MCP Server** | `python -m mcp_server_time --local-timezone=...` (`stdio`) | *None* | Grounding current date, day-of-week, and local IANA timezone (`get_current_time`). |
  24. | 2 | **Weather MCP Server** | `python -m mcp_weather_server` (`stdio`) | `"weather"` | Keyless forecast lookup (`weather_get_weather_byDateTimeRange`) without `convert_time` collision. |
  25. | 3 | **Airbnb MCP Server** | `npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt` (`stdio`) | *None* | Accommodation search (`airbnb_search`) and listing inspection (`airbnb_listing_details`). |
  26. ---
  27. ## Repository Structure
  28. ```text
  29. .
  30. ├── .github/workflows/ci.yml # Automated pytest CI (Python 3.12 + Node.js 20)
  31. ├── .env.example # Template for endpoint, key, model, and timezone
  32. ├── .gitignore
  33. ├── LICENSE # Apache-2.0
  34. ├── main.py # CLI entrypoint (--check, --prompt, interactive REPL)
  35. ├── pyproject.toml # Package & pytest configuration
  36. ├── requirements.txt # Pinned runtime & test dependencies
  37. ├── README.md
  38. ├── src/
  39. │ ├── __init__.py
  40. │ ├── agent.py # ReAct system prompt, OpenAIChatModel wiring & diagnostics
  41. │ ├── config.py # Pydantic v2 AgentConfig validator & npx PATH verification
  42. │ └── mcp_servers.py # Factory helpers for Time, Airbnb, and prefixed Weather MCPs
  43. └── tests/
  44. └── test_agent_setup.py # Unit tests covering config validation, M=3 factories & prefixing
  45. ```
  46. ---
  47. ## Multi-Backend Endpoint Matrix
  48. Switch between **AMD Token Lab**, **ROCm `vLLM` (MI300X)**, **Ollama**, and **LM Studio** purely via `.env` without modifying Python code:
  49. | Backend / Runtime | Example `BASE_URL` | Example `OPENAI_API_KEY` | Example `MODEL_NAME` | Notes |
  50. |---|---|---|---|---|
  51. | **AMD Token Lab** | `https://api.tokenlab.amd.com/v1` | `<YOUR_TOKEN_LAB_KEY>` | `Gemma-4-31B-IT` | Hosted AMD open-weights inference; verify tool-calling support. |
  52. | **ROCm `vLLM` (MI300X)** | `http://localhost:8000/v1` | `abc-123` | `Qwen3-30B-A3B` | Launch vLLM with `--enable-auto-tool-choice` & appropriate tool parser. |
  53. | **Ollama** | `http://localhost:11434/v1` | `ollama` | `qwen3:30b` | Use an Ollama model tag with native function/tool calling. |
  54. | **LM Studio** | `http://localhost:1234/v1` | `lm-studio` | `qwen2.5-coder-32b-instruct` | Enable **Local Server** on port `1234` with a tool-capable model. |
  55. ---
  56. ## Installation & Quick Start (English & Panduan Operator Indonesia)
  57. ### 1. Prerequisites
  58. - Python `>= 3.10`
  59. - Node.js & `npx` available on system `PATH` (required by `@openbnb/mcp-server-airbnb`)
  60. ### 2. Install Dependencies
  61. ```bash
  62. pip install -r requirements.txt
  63. ```
  64. ### 3. Configure `.env`
  65. ```bash
  66. cp .env.example .env
  67. ```
  68. Edit `.env` with your target endpoint:
  69. ```dotenv
  70. BASE_URL=http://localhost:8000/v1
  71. OPENAI_API_KEY=abc-123
  72. MODEL_NAME=Qwen3-30B-A3B
  73. LOCAL_TIMEZONE=Asia/Jakarta
  74. ```
  75. ### 4. Verify Environment & Endpoint Reachability (`--check`)
  76. Memeriksa ketersediaan `python`, `npx`, modul MCP (`mcp_server_time`, `mcp_weather_server`), validitas konfigurasi, dan keterjangkauan `BASE_URL/models`:
  77. ```bash
  78. python main.py --check
  79. ```
  80. ### 5. Run One-Shot or Interactive Mode
  81. ```bash
  82. # One-shot prompt execution
  83. python main.py --prompt "Plan a 3-day trip to Bandung next week for 2 guests based on the best weather window and find Airbnb options."
  84. # Interactive REPL mode (type 'exit' or 'quit' to leave)
  85. python main.py
  86. ```
  87. ### 6. Run Unit Tests
  88. ```bash
  89. pytest -v
  90. ```
  91. ---
  92. ## Author & License
  93. - **Author:** Ahmad Rifa'i Wibisono ([`Goldcode1618`](https://github.com/Goldcode1618)) — Electrical Engineering Researcher & System Architect, UHAMKA
  94. - **License:** [Apache License 2.0](./LICENSE)

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.