Introduction to MCP
What is the Model Context Protocol?
The Model Context Protocol (MCP) is an open standard created by Anthropic that lets AI models like Claude connect to external tools, data sources, and services. Think of it as a USB port for AI — a universal way to plug any tool into any AI model.
Before MCP, every AI integration was custom-built. If you wanted Claude to access your database, you'd write custom code. If you wanted it to use GitHub, more custom code. MCP standardizes this so you build a server once and it works with any MCP-compatible AI client.
typescript
// The idea: Build once, connect to any AI
// Without MCP:
// Claude <-> Custom GitHub code
// Claude <-> Custom Database code
// Claude <-> Custom Slack code
// With MCP:
// Claude <-> MCP <-> GitHub Server
// Claude <-> MCP <-> Database Server
// Claude <-> MCP <-> Slack Server
// Any AI <-> MCP <-> Any ServerTip:MCP has over 7 million server downloads per month and is supported by 70% of major SaaS platforms. It's quickly becoming the industry standard for AI-tool integration.
How Does MCP Work?
MCP follows a client-server architecture. The AI application (like Claude Desktop) is the client, and your code that provides tools/data is the server. The client discovers what the server can do, then calls those capabilities when needed.
typescript
// A simple MCP server exposes "tools" that AI can call
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
const server = new McpServer({
name: "weather-server",
version: "1.0.0",
});
// Define a tool the AI can use
server.tool(
"get_weather",
"Get current weather for a city",
{ city: z.string() },
async ({ city }) => {
const weather = await fetchWeather(city);
return {
content: [{ type: "text", text: `Weather in ${city}: ${weather}` }],
};
}
);When a user asks Claude "What's the weather in Tokyo?", Claude sees the
get_weather tool is available, calls it with city: "Tokyo", gets the result, and responds naturally.PreviewTypeScriptRead Only
Copy this code and run it locally with
npx tsx server.ts