You have a real MCP server. Now the agent uses it.
Same tool-call loop you already know — but each tool run goes across stdio to the server, not to a local Python function.
Use case
Customer: “Can I get a refund on order 4412? It arrived broken.”
The agent should:
get_order→ see amount $12, item laptop standget_refund_policy→ see “under $100 may auto-refund”- Answer clearly (yes for this small order)
Customer question
│
▼
Agent (Gemini)
│ tool call?
▼
MCP client ──stdio──► shoptiny_server
│
▼
Final replyWhat changes vs in-process tools
| In-process | With MCP |
|---|---|
TOOLS["get_order"](…) |
session.call_tool("get_order", …) |
| Same file as the agent | Server can restart / live elsewhere |
| Hard to share across apps | Any MCP client can attach |
The model still only sees tool names and descriptions. MCP is how your code fetches the result.
What you should remember
- Discover tools with
list_tools, then bind them for the model. - On each tool call from the model, call MCP, return the result as the observation.
- Keep dangerous actions behind policy (later chapters) — MCP does not replace guardrails.
See it in Code
Paste your API key. Run the Python or TypeScript agent demo (official MCP + Gemini).
Java / Go are empty on this chapter — framework labs only.