Part 2 of Getting Started with MCPs
Understanding MCP (Model Context Protocol) architecture is crucial before building your first integration. Let's break down the core components and see how they work together to create powerful AI-enhanced applications.
The Big Picture: MCP's Three-Layer Architecture
MCP follows a clean client-server architecture with three main components:
[MCP Client] ←→ [MCP Server] ←→ [External Resources/Tools]
Think of it like a restaurant: the client (customer) makes requests, the server (waiter) handles those requests, and the tools/resources (kitchen) provide the actual functionality.
MCP Clients: The Request Makers
MCP clients are applications that want to use external tools and data. They initiate connections and make requests to MCP servers.
Popular MCP Clients
- Claude Desktop - Anthropic's desktop app with built-in MCP support
- Custom Applications - Your own apps using MCP client libraries
- IDE Extensions - Code editors that integrate MCP functionality
- Browser Extensions - Web-based tools using MCP protocols
What Clients Do
javascript
// Pseudo-code: Client requesting a tool
const client = new MCPClient();
await client.connect('file-system-server');
// Discover available tools
const tools = await client.listTools();
// Result: ['read_file', 'write_file', 'list_directory']
// Use a tool
const content = await client.callTool('read_file', {
path: '/project/config.json'
});
Clients handle connection management, tool discovery, and request formatting—they're the user-facing interface of the MCP ecosystem.
MCP Servers: The Smart Middlewares
MCP servers are the workhorses that expose tools and resources to clients. They act as intelligent adapters between your AI client and external systems.
Server Responsibilities
- Tool Execution: Process client requests and execute the appropriate functions
- Resource Management: Provide access to data sources like databases, files, or APIs
- Security: Handle authentication and validate requests
- Protocol Translation: Convert MCP protocol messages to system-specific operations
Real-World Server Examples
python
# File system MCP server example
class FileSystemServer:
def list_tools(self):
return [
{
"name": "read_file",
"description": "Read contents of a file",
"input_schema": {
"type": "object",
"properties": {
"path": {"type": "string"}
}
}
}
]
def call_tool(self, name, arguments):
if name == "read_file":
with open(arguments["path"], "r") as f:
return f.read()
Servers can be specialized (file operations only) or general-purpose (multiple integrations in one server).
Tools vs Resources: The Core Distinction
Understanding the difference between tools and resources is essential for MCP mastery.
Tools: Active Functions
Tools perform actions—they do things.
json
{
"name": "send_email",
"description": "Send an email message",
"input_schema": {
"type": "object",
"properties": {
"to": {"type": "string"},
"subject": {"type": "string"},
"body": {"type": "string"}
}
}
}
Common Tool Categories:
- File Operations - create, read, update, delete files
- API Integrations - call external services
- Database Queries - execute SQL or NoSQL operations
- System Commands - run shell scripts or system utilities
Resources: Static Information
Resources provide data—they contain information.
json
{
"uri": "file://project/README.md",
"name": "Project Documentation",
"description": "Main project documentation file",
"mimeType": "text/markdown"
}
Common Resource Types:
- Documentation - README files, API docs, user manuals
- Configuration - Settings, environment variables, schemas
- Data Sets - CSV files, JSON data, database exports
- Templates - Code templates, document templates
Communication Flow: How It All Works Together
Here's what happens when a client wants to use MCP functionality:
1. Connection Establishment
Client → Server: "Hello, I want to connect"
Server → Client: "Connected! Here are my capabilities"
2. Discovery Phase
Client → Server: "What tools and resources do you have?"
Server → Client: "I have tools: [read_file, write_file] and resources: [project_docs]"
3. Request Execution
Client → Server: "Use read_file tool with path=/config.json"
Server → External System: Read file from filesystem
External System → Server: File contents
Server → Client: "Here's the file content: {...}"
Transport Layers: How Data Moves
MCP supports multiple transport mechanisms:
Standard I/O (stdio)
bash
# Server runs as a subprocess
mcp-server --stdio
Best for: Local development, simple integrations
HTTP/HTTPS
javascript
// Server runs as web service
const server = new MCPServer();
server.listen(3000);
Best for: Remote servers, production deployments
WebSockets
javascript
// Real-time bidirectional communication
const ws = new WebSocket('ws://localhost:8080/mcp');
Best for: Real-time applications, streaming data
Security and Authentication
MCP architecture includes built-in security considerations:
Authentication Methods
- API Keys for simple server access
- OAuth 2.0 for third-party service integration
- Certificate-based authentication for enterprise environments
- Local file permissions for filesystem access
Security Best Practices
javascript
// Server-side validation
function validateRequest(request) {
// Check authentication
if (!request.headers.authorization) {
throw new Error('Authentication required');
}
// Validate input schema
if (!validateSchema(request.params, toolSchema)) {
throw new Error('Invalid parameters');
}
}
Scaling Patterns: From Simple to Complex
Single-Server Pattern
[Client] ←→ [Single MCP Server] ←→ [Database]
Good for: Small projects, prototypes
Multi-Server Pattern
[Client] ←→ [File Server]
←→ [Database Server]
←→ [API Server]
Good for: Separation of concerns, specialized functionality
Gateway Pattern
[Client] ←→ [MCP Gateway] ←→ [Server 1]
←→ [Server 2]
←→ [Server 3]
Good for: Large applications, centralized management
Next Steps: Putting It Into Practice
Now that you understand MCP architecture, you're ready to:
- Choose your client - Claude Desktop for testing, or build custom
- Plan your server - What tools/resources will you expose?
- Select transport - stdio for local, HTTP for remote
- Design security - Authentication and validation strategy
This is Part 2 of our Getting Started with MCPs series. Missed Part 1? Check out MCP Servers Explained: How to Connect AI to Everything in 2025. Ready for hands-on development? Try connecting and building your own MCP server gateways on Storm MCP for free! Coming up in Part 3: MCP Gateways: Connecting Multiple Servers Like a Pro.
Top comments (0)