Skip to main content

What is MCP?

MCP (Model Context Protocol) is an open standard for connecting AI assistants to external systems. Think of it as a universal language that lets AI models talk to APIs, databases, and services.

The Protocol

MCP defines how AI systems can:

  1. Discover tools - Ask "what can you do?"
  2. Call tools - Request "do this specific thing"
  3. Access resources - Read data and context
  4. Receive prompts - Get specialized instructions

Core Concepts

Tools

Tools are functions the AI can call. Each tool has:

{
name: "search_orders", // Unique identifier
description: "Search orders...", // Helps AI decide when to use it
inputSchema: { // JSON Schema for parameters
type: "object",
properties: {
query: { type: "string" }
},
required: ["query"]
}
}

The AI reads the description to understand when to use the tool, and the inputSchema to know what arguments to provide.

Resources (Optional)

Resources are read-only data sources:

{
uri: "config://app-settings",
name: "Application Settings",
mimeType: "application/json"
}

Resources are less common than tools. Most integrations only need tools.

Prompts (Optional)

Pre-defined prompt templates for specific tasks:

{
name: "analyze_order",
description: "Analyze an order for issues",
arguments: [
{ name: "orderId", required: true }
]
}

Protocol Messages

Tool Discovery

Client                    MCP Server
│ │
│── tools/list ───────────▶│
│ │
│◀── { tools: [...] } ─────│
│ │

Tool Execution

Client                    MCP Server
│ │
│── tools/call ───────────▶│
│ { name: "search", │
│ arguments: {...} } │
│ │
│◀── { content: [...] } ───│
│ │

Transport Layers

MCP works over different transports:

TransportUse CaseHow It Works
stdioLocal processesstdin/stdout pipes
SSEHTTP serversServer-Sent Events
WebSocketReal-timeBidirectional

Diosc uses SSE because it works well with HTTP infrastructure (load balancers, proxies, etc.).

MCP vs REST APIs

AspectREST APIMCP
ClientAny HTTP clientAI assistant
DiscoveryOpenAPI/Swagger (optional)Built-in tools/list
Input validationCustomJSON Schema
PurposeGeneral CRUDAI-specific actions
SemanticsHTTP verbsTool calls

MCP is designed for AI consumption. The descriptions help the AI understand when to use each tool, not just how.

Example: REST to MCP

Original REST API

GET /api/orders?customer=John&status=pending
Authorization: Bearer <token>

MCP Wrapper

// Tool definition
{
name: "search_orders",
description: "Find orders by customer name or status. Use this when the user asks about orders, order history, or wants to look up specific orders.",
inputSchema: {
type: "object",
properties: {
customer: {
type: "string",
description: "Customer name to search for"
},
status: {
type: "string",
enum: ["pending", "shipped", "delivered"],
description: "Filter by order status"
}
}
}
}

// Tool implementation
async function searchOrders(args, authHeaders) {
const url = new URL('https://api.example.com/orders');
if (args.customer) url.searchParams.set('customer', args.customer);
if (args.status) url.searchParams.set('status', args.status);

const response = await fetch(url, {
headers: authHeaders // Forward user's auth
});

return response.json();
}

The key additions:

  • Description tells AI when to use this tool
  • Parameter descriptions help AI construct valid calls
  • Auth forwarding preserves user permissions

Why MCP Matters

For AI Developers

  • Standard protocol means one integration pattern
  • Tool discovery is automatic
  • Clear contract between AI and services

For API Owners

  • Expose APIs to AI without rewriting
  • Security model unchanged
  • Control what AI can access via tools

For Users

  • AI can do more things
  • Actions are transparent (tool calls are visible)
  • Same permissions as direct access

Learn More