learning-it by example

Back to the video

Build an MCP Client That Uses Many Servers in Python

I gave two MCP servers a tool called search each. Merge their tools by name, and one of them vanishes.

Video #28 ยท AI agents and MCP

Steps in the video

  1. 0:00 Two servers each had a tool called search
  2. 0:35 The idea
  3. 1:09 Setup
  4. 1:32 Two servers
  5. 1:56 The hub
  6. 2:24 The test
  7. 3:17 What this does not show
  8. 3:51 Mistakes to avoid
  9. 4:19 My take and next steps
  10. 4:47 Recap

Files

  • compare.py (44 lines)
  • flights_server.py (28 lines)
  • hub.py (36 lines)
  • shop_server.py (28 lines)

Download the code (zip)

Tested with

Python 3.12.15 | mcp==2.3.0, ollama==0.6.3

What this does not show

Two made up servers and six easy questions with tool names that explain themselves. Only the first tool the model chose was checked, not its arguments. The hub has no approval step, no timeouts and no call log.

Sources

Learning IT by Example.