Problems without Model Context Protcol
AI models like Claude know a lot about general topics but can't see your personal data or systems. They're cut off from your world.
Without MCP, linking AI to your data means creating custom links for each source. Want Claude to access your Google Drive? You need a custom link. Your GitHub? Another custom link. Your database? Yet another one. This method:
Creates separate connections → each one is different and isolated
Doesn't grow well → you have to manage many different links
Lacks consistency → every company makes its own way
Raises security concerns → each link has its own security setup
Imagine before USB, every device had its own unique connector. Printers, keyboards, and cameras all had different ports, making things complicated.
MCP fixes this by creating a standard way for AI models to connect to any data source.
This means:
Build once, connect to many → make your data "MCP-compatible," and any MCP-enabled AI can use it.
Better security → with standardized authentication and permissions.
Scalability → easily add new data sources as needed.
Flexibility → switch between different AI providers without changing your data connections.
Basically, MCP connects "AI that knows general stuff" with "AI that can use your specific info." It turns AI from a standalone tool into a system that can interact with your digital world.
MCP Architecture: The Complete Picture
MCP uses a client-host-server setup that lets AI systems connect with different data sources and tools.
Key Components
Host → This is the main application (like Claude Desktop) that:
Contains and coordinates multiple client instances
Handles user interactions and security permissions
Manages the AI/LLM integration
Controls which servers can be connected
Clients → Each client is a connector that:
Establishes a 1:1 relationship with a specific server
Handles communication between the host and that server
Maintains isolation between different servers
Negotiates capabilities with the server
Servers → These are specialized programs that:
Provide access to specific data sources or tools
Focus on a single responsibility (like "weather data" or "database access")
Expose their capabilities through resources, tools, and prompts
Know nothing about other servers or the full conversation
How Information Flows
When you ask a question in Claude Desktop:
The host (Claude Desktop) looks at your question.
It figures out which connected servers can help answer it.
Relevant clients talk to their servers to get data or run tools.
The servers send back information or tool results.
The host gathers all this information.
The AI uses this gathered context to create a response.
Communication Protocol
All communication uses JSON-RPC 2.0 with three message types:
Requests: Messages that expect a response
Responses: Answers to specific requests
Notifications: One-way messages (no response needed)
Security Model
Security is built into the architecture:
Servers only receive the information they need
Servers can't access the full conversation history
Servers are isolated from each other
The host enforces security boundaries
Users must approve tool usage
Capability Negotiation
When a client connects to a server, they exchange information about their capabilities:
Client: "I can handle these features..."
Server: "I support these resources and tools..."
Both agree on which capabilities will be used
This negotiation makes sure everything works well together and allows for future updates.
The Big Picture Benefit
This setup solves a big problem: it lets AI systems securely and easily access your data and tools without needing custom solutions for each case.
Here's how it works:
Developers can create servers for specific data sources.
Users can mix and match servers as needed.
Security is kept tight.
New features can be added over time.
Different AI systems can use the same servers.
By standardizing these connections, this system allows AI to safely and efficiently use the data and tools they need to be really helpful.
Chronological Guide to Building an MCP Server in TypeScript
Set up project
mkdir my-mcp-server cd my-mcp-server npm init -y npm install @modelcontextprotocol/sdk zod npm install -D typescript @types/node
Configure TypeScript
# Create tsconfig.json with ES2022 target and Node16 module
Update package.json
{ "type": "module", "scripts": { "build": "tsc" } }
Create basic server structure
// src/index.ts import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; const server = new McpServer({ name: "my-server", version: "1.0.0", });
Add capabilities
Register tools with schema validation
Add resources if needed
Add prompts if needed
Implement tool handlers
server.tool( "tool-name", "Tool description", { param1: z.string().describe("Parameter description"), }, async ({ param1 }) => { // Tool implementation return { content: [{ type: "text", text: "Result" }], }; } );
Start the server
async function main() { const transport = new StdioServerTransport(); await server.connect(transport); console.error("Server running"); } main().catch(console.error);
Build the server
npm run build
Your main concern will be building MCP servers
Existing clients like Claude Desktop already manage the client side, so you don't need to build that part.
The real value comes from creating MCP servers that share your specific data, APIs, or features.
Building servers is easier → they focus on one main task instead of managing multiple connections.
Most developers will want to expand AI capabilities by linking it to their own systems → this means building servers.
The server is where you'll add your business logic or special features.
For example, if you want Claude to access your company's internal API or database, or use a specific SDK like imgly, you'd build an MCP server for that. Then you can connect it to Claude Desktop or other MCP-compatible clients.
How AI Models Choose Which Tools to Call
When you ask a question, the AI goes through these steps to pick the right tools:
Tool Registration: All tools are listed with names, descriptions, and what they need to work.
Context Analysis: The AI looks at your question to figure out what you want.
Tool Matching: The AI checks your intent against the tool descriptions.
Parameter Extraction: If a tool fits, the AI finds out what details it needs from your question.
Decision: The AI decides to:
Answer directly without tools
Use a tool to get more info
Use several tools in order
For instance, if you ask "What's the weather in Paris?" and there's a weather tool described as "Get weather data for a location," the AI sees the match, pulls "Paris" as the location, and chooses to use that tool.
The AI bases this choice on how well the tool descriptions match your question → clear, specific tool descriptions are key for picking the right tool.