Bridging AI and the real world with MCP Mar 08
You’re likely here because you’re curious about MCP — what it is and how it works. In this guide, I’ll break down the Model Context Protocol (MCP) and show how it connects AI to real-world systems, making complex integrations simpler and more efficient.
Key takeaways
- MCP is a standardized framework that connects AI models to real-world systems using JSON-RPC 2.0.
- It simplifies complex integrations by providing structured access to resources, tools, and prompts.
- Organizations can use MCP to streamline AI interactions with external data, enabling scalable and context-aware applications.
What is MCP?
The Model Context Protocol (MCP) sets up a client-server handshake where an AI-powered client—like a travel app—communicates with a server providing resources, tools, or prompts. It addresses the challenge of language models that lack native access to external data or actions by providing a clean, standardized API. Built on JSON-RPC 2.0, MCP ensures lightweight and interoperable communication. Key methods include mcp.discover
, mcp.get_resource
, and mcp.execute
. MCP is typically communicated over HTTP or WebSockets, and errors follow JSON-RPC conventions.
MCP is structured around three main components:
- Prompts: Templates or instructions, such as “find hotels matching user criteria.”
- Resources: JSON-formatted external data, like travel dates or budget.
- Tools: Functions or APIs, such as a hotel search endpoint.
The open-source November 2024 specification enables organizations to adapt MCP for diverse use cases, streamlining how context flows into AI models for real-world applications.
Why MCP matters
Without a protocol like MCP, integrating AI with external systems often involves fragile, custom code that is difficult to reuse. MCP provides a standardized approach, similar to REST for HTTP APIs, reducing complexity and enabling scalable, context-aware AI systems. For organizations prioritizing structured data, MCP offers a seamless way to connect systems to AI models.
Use case: Booking a hotel
Imagine a travel website with a widget that allows users to book a hotel in Copenhagen for March 15-18, 2025, with a €200/night budget and preferences for a quiet room with a city view. The widget uses MCP to facilitate this interaction between the client (widget), a hotel service (server), and an AI model, potentially enhanced by structured data expertise.
Step 1: Client initiates the process
The widget sends a discovery request to the server to determine the available prompts, resources, and tools:
{
"jsonrpc": "2.0",
"method": "mcp.discover",
"id": 1
}
The server responds with the available prompts, resources, and tools:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"prompts": ["suggest_hotels"],
"resources": ["user_profile", "calendar"],
"tools": ["search_hotels"]
}
}
Step 2: Retrieve resources
The widget requests user profile data, which may be enhanced by structured data practices:
{
"jsonrpc": "2.0",
"method": "mcp.get_resource",
"params": {
"resource": "user_profile"
},
"id": 2
}
The server responds with the user profile data:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"budget": 200,
"currency": "EUR",
"preferences": {
"room_type": "quiet",
"view": "city"
}
}
}
Next, the widget requests calendar data:
{
"jsonrpc": "2.0",
"method": "mcp.get_resource",
"params": {
"resource": "calendar"
},
"id": 3
}
The server responds with the calendar data:
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"dates": {
"start": "2025-03-15",
"end": "2025-03-18"
},
"location": "Copenhagen"
}
}
Step 3: Execute the prompt with tools
The widget bundles the user profile and calendar data and sends an execution request to the server:
{
"jsonrpc": "2.0",
"method": "mcp.execute",
"params": {
"prompt": "suggest_hotels",
"resources": {
"user_profile": {
"budget": 200,
"currency": "EUR",
"preferences": {
"room_type": "quiet",
"view": "city"
}
},
"calendar": {
"dates": {
"start": "2025-03-15",
"end": "2025-03-18"
},
"location": "Copenhagen"
}
},
"tools": ["search_hotels"]
},
"id": 4
}
The server processes the request and returns a hotel suggestion:
{
"jsonrpc": "2.0",
"id": 4,
"result": {
"suggestion": "The Hotel d'Angleterre: €175/night, quiet room, city view. Available March 15-18, 2025."
}
}
Structured data integration
Organizations with expertise in structured data can enhance this process by ensuring resources like user_profile
and calendar
adhere to well-defined schemas. This aligns with MCP’s resource-driven approach and can improve server-side data flow.
Companies focusing on highly structured data, such as Zublime, are doing extensive work around MCP to enhance the user experience. Their efforts demonstrate how structured data can be leveraged to create more intuitive and efficient systems.
That’s a wrap
MCP provides a robust framework for connecting AI models to real-world systems using JSON-RPC 2.0. By standardizing interactions between clients, servers, and AI, it reduces complexity and enables scalable, context-aware applications. Organizations leveraging structured data, like Zublime, can further enhance MCP’s capabilities, ensuring cleaner inputs and more precise AI outputs. As AI continues to evolve, MCP stands as a powerful tool for building systems that are not only practical and effective but also adaptable to the ever-changing demands of real-world integration.