Article · MCP (Model Context Protocol) · Tool use (function calling)
MCP (Model Context Protocol): one standard for connecting AI to tools and data
What the Model Context Protocol is, how the host–client–server architecture works, how tools, resources and prompts differ, how the stdio and Streamable HTTP transports work and how to write your own MCP server in Python, TypeScript and C# – and connect it to Claude.
The Model Context Protocol (MCP) is an open standard that describes how AI applications connect to external tools and data. Instead of writing a separate integration between every application and every system, you write an MCP server once – and every compatible host can use it: Claude Desktop, an IDE with an assistant, a coding agent in the terminal or your own application. Anthropic published MCP in November 2024; today it is the shared language of the whole industry, developed under the Linux Foundation.
- 3
- roles in the architecture – host, client, server
- 3
- server primitives – tools, resources, prompts
- 2
- standard transports – stdio and Streamable HTTP
The problem: the same integration written five times
Halina's Pierogi has several places in the company where access to orders and the menu would help: the customer chat, an assistant in Claude Desktop for the manager, a coding agent that helps the team debug the ordering system, and an internal bot in the team messenger. Each of them needs "check order status" and "show today's menu with allergens".
Without a standard, every application gets its own implementation of the tools, its own result format and its own bugs. When the order API changes, fixes have to go into five places. It is the classic N×M problem: N applications times M data sources.
| No standard (N×M) | With MCP (N+M) | |
|---|---|---|
| 1 application | 6 integrations | 7 integrations |
| 2 applications | 12 integrations | 8 integrations |
| 3 applications | 18 integrations | 9 integrations |
| 4 applications | 24 integrations | 10 integrations |
| 5 applications | 30 integrations | 11 integrations |
Intuition: USB-C for AI applications
Before USB, every device had its own plug. A USB-C port does not know whether you are connecting a drive, a monitor or a charger – it only knows the protocol. MCP does the same for AI: the host does not need to know how the pierogi ordering system works; it is enough for the MCP server to describe its tools and data in an agreed format. A new application? Plug in the existing server. A new data source? Write one server and it works in every host straight away.
Architecture: host, client, server
| Role | Who it is | Responsibility |
|---|---|---|
| Host | the application the model runs in: Claude Desktop, an IDE, a terminal agent, your backend | manages clients, asks the user for consent, decides what goes into the model's context |
| Client | a host component, one per connection | maintains the connection to one server, passes requests and responses |
| Server | a program exposing capabilities: a local process or an HTTP service | exposes tools, resources and prompts; connects to the real system (database, API) |
Three server primitives
| Primitive | Controlled by | What for | Pierogi example |
|---|---|---|---|
| Tools | the model – it decides to call them | actions and queries with arguments | get_order_status(order_id) |
| Resources | the application – the host decides what to attach to the context | read-only data identified by a URI | menu://today – the menu with allergens |
| Prompts | the user – picks a template, e.g. from a "/" menu | ready-made, parameterized task templates | answer_complaint(order_id) |
This split matters in practice. Tools are the model's "hands", so they need the most care. Resources are context the host can attach without asking the model. Prompts are shortcuts for people – instead of typing a long instruction every time, the manager picks "Answer a complaint" and enters the order number.
The protocol underneath
All messages are JSON-RPC 2.0: requests with method and params, responses with result or error, plus notifications without a response. The key methods are tools/list and tools/call, resources/list and resources/read, prompts/list and prompts/get.
Transports. With stdio the host starts the server as a subprocess and exchanges messages through standard input and output – ideal for local tools (files, git, a local database). With Streamable HTTP the server runs as a network service, often behind OAuth – this is how company systems are exposed to many users. The older HTTP+SSE transport is being phased out.
Specification versions. The specification has dated versions. Up to version 2025-11-25 a connection started with an initialize exchange in which client and server negotiated the protocol version and capabilities. Version 2026-07-28 moves MCP to a stateless model: every request carries the protocol version and client capabilities in _meta, sessions are no longer needed, and any server instance can sit behind an ordinary load balancer. The SDKs hide most of these differences – but when you write your own gateways and proxies, it is worth knowing which version you support.
Your own MCP server
Official SDKs exist for many languages, including Python, TypeScript, C#, Java, Kotlin and Go. The pattern is the same everywhere: create a server, register tools, resources and prompts (the SDK generates descriptions and argument schemas from signatures and annotations), and finally pick a transport.
The pierogi MCP server: a tool, a resource and a prompt
# pip install "mcp>=2" (in mcp 1.x the class was called FastMCP)
from mcp.server.mcpserver import MCPServer
server = MCPServer("halina-pierogi", instructions="Orders and menu of Halina's Pierogi.")
MENU = {"ruskie pierogi": ["gluten", "milk"], "spinach pierogi": ["gluten", "milk", "walnuts"]}
@server.tool()
def get_order_status(order_id: str) -> str:
"""Returns status and ETA of an order. Use it when the user asks where an order is."""
# A real server calls the order service with the user's own credentials.
return "status=in_delivery, eta=12 min" if order_id == "1042" else f"No order {order_id}."
@server.resource("menu://today", mime_type="text/markdown")
def todays_menu() -> str:
"""Today's menu with allergens."""
return "\n".join(f"- {dish}: {', '.join(allergens)}" for dish, allergens in MENU.items())
@server.prompt()
def answer_complaint(order_id: str) -> str:
"""Template for handling a delivery complaint."""
return f"Check order {order_id} with get_order_status, then draft a short apology."
if __name__ == "__main__":
server.run() # stdio by default; server.run("streamable-http") for remote clientsimport { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
const server = new McpServer({ name: "halina-pierogi", version: "1.0.0" });
const MENU = "- ruskie pierogi: gluten, milk\n- spinach pierogi: gluten, milk, walnuts";
server.registerTool(
"get_order_status",
{
title: "Order status",
description: "Returns status and ETA of an order. Use it when the user asks where an order is.",
inputSchema: { order_id: z.string().describe("Order number without '#'") },
annotations: { readOnlyHint: true }, // hint for hosts: no side effects
},
async ({ order_id }) => ({
content: [{ type: "text", text: order_id === "1042" ? "status=in_delivery, eta=12 min" : `No order ${order_id}.` }],
}),
);
server.registerResource(
"todays-menu",
"menu://today",
{ title: "Today's menu", description: "Menu with allergens", mimeType: "text/markdown" },
async (uri) => ({ contents: [{ uri: uri.href, text: MENU }] }),
);
server.registerPrompt(
"answer_complaint",
{ description: "Template for handling a delivery complaint.", argsSchema: { order_id: z.string() } },
({ order_id }) => ({
messages: [{ role: "user", content: { type: "text", text: `Check order ${order_id}, then draft a short apology.` } }],
}),
);
// stdout carries JSON-RPC messages - log to stderr only.
await server.connect(new StdioServerTransport());
console.error("halina-pierogi MCP server running on stdio");// dotnet add package ModelContextProtocol && dotnet add package Microsoft.Extensions.Hosting
using System.ComponentModel;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using ModelContextProtocol.Server;
var builder = Host.CreateApplicationBuilder(args);
// stdout belongs to the MCP protocol - send logs to stderr.
builder.Logging.AddConsole(o => o.LogToStandardErrorThreshold = LogLevel.Trace);
builder.Services
.AddMcpServer()
.WithStdioServerTransport()
.WithToolsFromAssembly()
.WithResourcesFromAssembly()
.WithPromptsFromAssembly();
await builder.Build().RunAsync();
[McpServerToolType]
public static class OrderTools
{
[McpServerTool, Description("Returns status and ETA of an order. Use it when the user asks where an order is.")]
public static string GetOrderStatus([Description("Order number without '#'")] string orderId) =>
orderId == "1042" ? "status=in_delivery, eta=12 min" : $"No order {orderId}.";
}
[McpServerResourceType]
public static class MenuResources
{
[McpServerResource(UriTemplate = "menu://today", Name = "Today's menu", MimeType = "text/markdown")]
[Description("Today's menu with allergens.")]
public static string TodaysMenu() => "- ruskie pierogi: gluten, milk\n- spinach pierogi: gluten, milk, walnuts";
}
[McpServerPromptType]
public static class ComplaintPrompts
{
[McpServerPrompt, Description("Template for handling a delivery complaint.")]
public static string AnswerComplaint(string orderId) =>
$"Check order {orderId} with get_order_status, then draft a short apology.";
}The rest of this article is for members
Create a free account or sign in to read it all. Still ahead:
- Connecting the server to Claude
- Security: an MCP server is code with access to your data
- How MCP became a standard
- When MCP, and when plain tools
- MCP server checklist
- Test yourself
- What's next