article

Example MCP

Understanding the Model Context Protocol

MCP README Summary Server

MCP README Summary Server

What is MCP?

So, have you ever heard of MCPs? Well if you're anywhere near the technology, specifically AI, it's all the rage. MCP stands for Model Context Protocol. A protocol is a set of established rules, standards, or procedures that govern how data, systems, or entities communicate and interact, ensuring consistent and effective exchange—according to Google's AI Overview.

So this is a way to establish some rules and standards on how models can interact with other systems.

The Three Primitives

MCPs have three primitives: tools, resources, and prompts. In Example MCP we exhibit all primitives.

Tools

Starting with tools, we have readme_summary and readme_from_git. Tools are actions—the LLM can call them to do something and get a result back.

If you are integrating this into an AI application where you have built your own AI, you will need to ensure that you are using an LLM that is capable of calling tools (tool calling). The Llama 3.1 and 3.2 families are two such models that have this capability.

Resources

Resources, another primitive, is something stateful that the LLM can read from and ingest as context. In this example we use the README.md in the root dir. However, it can be whatever you want it to be.

Resources are not limited to one type. They can be of almost any data type. They can be static or dynamic. That means they can be generated and then accessed by a template later (e.g., resource://logs/{date}).

Prompts

And then there are Prompts. They differ in that they are user-initiated. The user explicitly selects them, usually through a UI or command. The prompt then provides a pre-filled template that gets sent to the LLM.

MCP Prompt example in Claude

MCP Prompt selection in Claude

Architecture

In our example, we've hooked the MCP up to Claude. Here Claude is the MCP Host which has an MCP Client which talks to my MCP server. The information that the server sends the client, the client uses when talking to the Claude LLM.

MCP Architecture diagram showing Claude Code as MCP Host

MCP Architecture Overview

JSON-RPC 2.0

MCPs use JSON-RPC 2.0. If you want to learn more about it visit https://www.jsonrpc.org. Its core is JSON. So if you are familiar with JSON and JavaScript, you've got this one figured out too. It is specifically used for MCP-model communications.

Getting Started

Great! You've made it this far. This will give you a basic understanding of how MCPs work. If you understand this and understand how general web servers work, you're in great shape to begin engineering.

It is important to mention that this example is an example of Retrieval-Augmented Generation (RAG). While this is not Embedding-based RAG it still is retreiving information and from what is retreived we get a modified output. We'll cover embedding in our next article.

The rest is foundational, fundamental coding and DevOps best practices, mostly. In this example we show how to use the Example MCP with Claude. Stay tuned as I build more AI systems. Go view the repo for Example MCP; click here. Try it for yourself.

Thanks for dropping by! Make sure to repost.

MCP
Model Context Protocol
AI
Claude
LLM
JSON-RPC
RAG
Example MCP