26. The simplest MCP demo (Includes Sample provider app, MCP Server and Agent 🤖 code and explanation!)

This is where you should start for MCP - No complex tooling needed

While I worked at Google during the publishing of this post / video, the views expressed here are my own and may not reflect those of my employer. Only publicly available material is used to put together the content of this article and video. The website and the Youtube videos are NOT monetized.


It’s been almost 2.5 years since I used generative AI for the first time and now, I am hooked (which means I use AI for most of my work 🤗).

At the Next 25, Google unveiled the amazing Agent Development Kit and I was exploring Model Context Protocol viz. MCP for a use case at work. So, Over the weekend I delved deep in both.

I am going to keep this simple (The demo has everything - you need).

Why?


To understand anything, we must know the why

Why is it needed ? Why MCP?

The following table is going to (overly simplisticly) explain how we got here (till MCP)

Sr.No.WhoDoes whatExampleWhat can we improve? /comments
1Gen AI ModelGenerates Next TokenInput - Who is Virat Kohli, Output - ?Generates a ? which is right but not very useful
2A Fine tuned Gen AI Model (with questions and answers data)Still generates next token but now can generate proper responsesInput - Who is Virat Kohli, Output - Virat Kohli is an Indian Cricketer …At this point the model can only answer from its own knowledge base, we want it to use external data (static). So for example it cannot answer properly “How many centuries has Virat Scored in ODIs?”
3Retrieval Augmented Generation (RAG)Retrieval brings relevant latest data into Model’s context and Model then can respond using that informationInput - How many centuries has Virat Scored in ODIs ?, Output - 51But now the AI cannot answer questions like “Is he batting now?”
4AI + function callingCan call external API (e.g. espncricinfo) and fetch the informationInput - Is he batting now? Output - yes for RCB, on 23 N.O.You have to write the function that does the API call, explain how to use the response to the AI of your choice. Moreover, different people will use the API differently - no standardization
5AI/Agent + MCPespncricinfo provides the MCP server which your agent calls and receives all the latest information(same as above)All agents use the same MCP server provided by espncricinfo - no duplicate efforts, standardization across agents. No explicit connection management between Agent and MCP (and hence the target API)

Example


Now let’s see this with an example -

alt

  1. We have a business that provides equipment repairs (AC, TV etc) for hotel owners - It’s called Repair World
  2. Generally the hotel manager logs into the Repair World and creates and tracks their repair requests
  3. But now with the advent of AI
    1. The hotels want to use an Agent that can automatically create and track repair requests and create reports about faulty equipment etc.
    2. Repair World wants as many hotels as possible to use their service and their application but in a standardized way
  4. Before MCP, every hotel would create their own API caller implementation for repair world’s API. Now with MCP -
    1. Repair World creates an MCP server which is basically a pluggable implementation of their customer facing functionality. They expose readily usable Tools through MCP.
    2. The hotels' AI agents (Google ADK/ Claude/ crew.ai based) use these tools to automate repair request creation and tracking (and a lot more - as you’ll see in the demo).
    3. Any updates/ fixes made to the repair world functionality are done by Repair World and are provided to all the hotels.

MCP servers not only expose tools but also resources and prompts. But for now, let’s check out the demo to cement our understanding.


Demo


The demo covers the following -

  1. The setup needed (needs python and nodejs installed)
  2. Deployment
  3. Demo Run
  4. Code explanation

The links to the code are provided below.

Demo Video

Please watch in full screen or on youtube directly



Setup steps


You can run the demo locally or on the Google Cloud Shell (Recommended).

Make sure you have the Gemini API Key before you run the demo.

If you plan to run this locally make sure that you have both python (11 or later) and nodejs (and npx) installed. Cloud shell comes installed with both.

On windows please check

where npx
# one of the following 2. make sure using the command that is available then after
where python
where python

On linux (or on Google cloud shell)

which npx
# one of the following 2. make sure using the command that is available then after
which python
which python
# open 2 command prompt or terminal windows.

# command prompt or terminal window 1
git clone https://github.com/nikhilpurwant/repair_world_application.git


git clone https://github.com/nikhilpurwant/google-adk-mcp.git

# window 1 - run the application 
cd repair_world_application

python -m venv .venv
. .venv/bin/activate # for windows use .venv\Scripts\activate
pip install -r requirements.txt

python app.py

# window 2 - run the adk agent with the mcp server
cd google-adk-mcp

# 🤖 update the .env file with the Gemini API key and save the file
# install the dependencies run the agent

python -m venv .venv
. .venv/bin/activate # for windows use .venv\Scripts\activate

pip install -r requirements.txt

python agent-repairworld.py



  1. Repair World Application - git
  2. Google ADK based Agent using the MCP server - git
  3. MCP server created for the Repair World application - git / pypi

Do take it for a spin. The goal of this demo is to provide the basic understanding of MCP with minimal setup and with a real world application.

MCP is great for service providers as they can expect predictable use of their APIs and for Agent creators because it reduces the duplication of efforts and standardizes the agent implementation.

Thank you for reading through, Please like 👍, share with your network 🔗 and comment ✍ if you found it useful.

Thank you!

-Nikhil

Further reading / listening