This repository showcases an end-to-end implementation of the Model Context Protocol (MCP), demonstrating how to build a production-aligned MCP server and client that communicate via JSON-RPC 2.0 over STDIO and leverage Vertex AI Gemini for intelligent tool orchestration.
The system includes:
- An MCP server built using FastMCP, exposing structured tools
- An MCP client that launches the server as a subprocess and interacts with it over STDIO
- LLM-driven tool discovery, execution, and multi-step tool chaining
- Secure, cloud-native integration with Vertex AI Gemini using IAM-based authentication
This project emphasizes protocol correctness, async-safe system design, and real-world LLM tool orchestration patterns, making it suitable a production-quality foundation for MCP-based agent systems.
Important distinction
- Terminal I/O → human interaction
- STDIO transport → machine-to-machine JSON-RPC communication
flowchart LR
User["👤 User<br/>(CLI)"]
subgraph Client["🧠 MCP Client"]
Gemini["✨ Gemini (Vertex AI)<br/>Reasoning Engine"]
Session["🔌 MCP ClientSession<br/>(JSON-RPC)"]
end
subgraph Server["🛠 MCP Server"]
FastMCP["⚙️ FastMCP Runtime"]
Tools["🌦 Weather Tools<br/>• get_forecast<br/>• get_alerts"]
end
User -->|"Query / Response"| Client
Gemini -->|"Tool calls"| Session
Session -->|"JSON-RPC 2.0"| FastMCP
FastMCP --> Tools
sequenceDiagram
participant U as User (CLI)
participant C as MCP Client
participant L as Gemini (Vertex AI)
participant S as MCP Server
participant T as Weather Tools
U->>C: Enter natural language query
C->>L: Send prompt + tool schemas
L->>C: Emit structured tool call
C->>S: JSON-RPC call_tool request
S->>T: Execute weather function
T-->>S: Tool result
S-->>C: JSON-RPC response
C->>L: Provide tool output
L-->>C: Final natural language response
C-->>U: Display result
Key Notes
- STDIO is used only for client ↔ server JSON-RPC
- Terminal I/O is strictly human interaction
- Gemini never calls tools directly — it requests, the client executes
- Tool chaining is handled by a while-loop on the client
End-to-End-MCP-Tooling-System-with-Vertex-AI-Gemini/
├── weather/
│ ├── weather.py # MCP server: FastMCP runtime + weather tools
│ ├── client.py # MCP client: Gemini reasoning + tool loop
│ ├── pyproject.toml # uv project configuration & dependencies
│ ├── uv.lock # Locked, reproducible dependency versions
│ ├── .gitignore # Ignores .env, .venv, caches, OS artifacts
│ └── README.md # Weather MCP module documentation
└── README.md # Root project overview & architecture
- ✅ MCP server built using FastMCP
- ✅ STDIO-based JSON-RPC communication
- ✅ Tool discovery (
list_tools) - ✅ Tool execution (
call_tool) - ✅ Multi-round tool chaining using a proper loop
- ✅ Vertex AI Gemini integration (IAM-based auth)
- ✅ Async-safe lifecycle management with
AsyncExitStack - ✅ Clean dependency management using uv
- Python 3.10+
uvpackage manager- Google Cloud project with:
- Vertex AI enabled
- Gemini model access
- Authenticated locally using:
gcloud auth application-default login
Follow these steps to run the MCP server and client locally.
git clone https://github.com/AvinashBolleddula/End-to-End-MCP-Tooling-System-with-Vertex-AI-Gemini.git
cd End-to-End-MCP-Tooling-System-with-Vertex-AI-Gemini/weatherThis project uses uv for fast and reproducible Python environments.
uv venv
source .venv/bin/activateYou should now see (.venv) in your terminal prompt.
Install all required dependencies exactly as defined in pyproject.toml and uv.lock.
uv syncCreate a .env file inside the weather/ directory:
GOOGLE_CLOUD_PROJECT=your-gcp-project-id
GOOGLE_CLOUD_LOCATION=us-central1
GEMINI_MODEL=gemini-2.0-flashNote Vertex AI uses IAM authentication, not API keys Ensure you are authenticated locally using:
gcloud auth application-default loginFrom inside the weather/ directory:
python client.py weather.pyIf everything is configured correctly, you should see:
Connected to server with tools: ['get_alerts', 'get_forecast']
MCP Client Started!You can now start interacting with the system via the terminal.