Blog
Using Model Context Protocol to Build a Seamless Agent
If the AI space wasn’t already too crowded with inscrutable terminology for you, buckle up, because this week we are talking about Model Context Protocol, or MCP for short.
MCP was introduced back in November of 2024 by Anthropic. MCP’s importance to building context-aware, agentic AI apps makes it critical to understand.
So let’s dive in.
So, what is MCP?
As the name indicates, it’s a “protocol” between client software and server software. MCP turbocharges AI app, empowering them to be more contextual and capable of taking action.
An MCP “client” is an application, often end-user facing, that uses AI as part of its feature set.
Extending the capabilities of AI apps has generally relied upon the app developer to build custom integrations, and users of client apps had no way to do this on their own for bespoke integrations.
An MCP “server” provides MCP clients with three things:
- Resources
- Tools
- Prompts
Resources provide useful contextual information, while tools enable client apps to act as agents, executing tasks as directed by an AI model.
Finally, prompts are convenient pre-defined workflows that servers provide to enable important repeatable interactions.
How does MCP work?
To help understand how MCP works, I’ve spent a few hours creating an MCP server of my own.
As you know by now, I’m a big fan of home automation.
Siri on the other hand? Not so much.
Apple’s oft-maligned “assistant” has lagged behind the market, contributing to subpar, frustrating experiences.
So, the goal of my MCP server will be to provide information about the smart devices in my home and the tools that can manipulate them in an effort to surpass Siri.
As a first step for my MCP server, I added the ability for MCP clients to ask for a list of available “resources” and to ask for details on a particular resource.
In our case, resources are the smart devices in my home, which are identified with unique names like “light.ceiling_fan_light” or “cover.office_blinds.” Detailed information about a resource may include state (the light is on, or the fan is at 33% speed, etc.) or other useful information.
The next step was to enable MCP clients to take action with my devices using MCP’s “tools” concept. I created tools for controlling various devices, including lights, fans, and smart blinds.
Because my server complies with the MCP protocol, any MCP Client app should be able to connect to it. Thankfully I have two MCP Clients installed on my primary computer — Claude Desktop and Amazon Q CLI.
With a few quick configuration file changes, both of the apps were instantly able to connect to my MCP server for testing.
What does the experience look like?
Well, it’s as simple as sending prompts, but with the added benefit of additional knowledge and capabilities. In Claude Desktop, I wrote a simple prompt - “Turn on my office lights.”
Claude Desktop sprung into action, identifying the resources I was referring to, and then calling the “light control tool” to turn on the lights. Magic!
Did I just make… Siri?
While it may look like I have just reinvented Siri, the reality is much more interesting.
Siri does one thing at a time, and is very poor at complex requests. Modern AI models, on the other hand, are well-suited for step by step reasoning and planning.
As a result, the following prompt, which would immediately stump Siri, works exactly as expected:
“Check if the lights are on in the garage. If they are, then turn off the lights in the kitchen and open the blinds in the family room, otherwise turn my office fan on.”
Eat your heart out, Siri!
Hopefully this brief exploration of MCP has inspired you to learn more. There are countless projects showing up on GitHub that use MCP in some truly stunning ways.
Do yourself a favor and set aside a few hours to tinker with MCP.
Author Spotlight:
Jonathan LaCour
Keep Up To Date With AWS News
Stay up to date with the latest AWS services, latest architecture, cloud-native solutions and more.
Related Blog Posts
Category:
Category:
Category: