v0.1.6·Technical Reference
MCPs Overview
Understanding the Model Context Protocol architecture
MCPs Overview
The Model Context Protocol (MCP) provides a standardized interface for AI models to interact with tools and data sources.
Architecture
Core Components
The MCP architecture consists of:
- Client: The AI model or agent using the protocol
- Protocol: The standardized message format and flow
- Server: The tool or service providing resources
- Transport: The communication layer (HTTP, WebSocket, etc.)
Message Types
Tool Definition
Describes available tools:
Tool Call
Invokes a tool:
Tool Response
Returns tool results:
Protocol Flow
- Discovery: Client requests available tools
- Selection: Client chooses appropriate tool
- Invocation: Client calls tool with parameters
- Execution: Server executes tool
- Response: Server returns result
- Processing: Client processes result
Resource Types
APIs
Access external web services:
Databases
Query structured data:
File Systems
Access files and documents:
Real-Time Data
Stream live information:
Security Considerations
Authentication
Secure tool access:
- API Keys: Simple key-based authentication
- OAuth: Token-based delegation
- mTLS: Mutual TLS certificates
- JWTs: Signed tokens with claims
Authorization
Control what tools can access:
- Scope-based: Limit to specific data
- User-based: Different access per user
- Role-based: Groups of permissions
- Resource-based: Fine-grained control
Input Validation
Prevent injection attacks:
- Type checking: Validate parameter types
- Whitelisting: Allow only known values
- Sanitization: Remove unsafe characters
- Rate limiting: Prevent abuse
Performance Optimization
Caching
Store frequently accessed data:
- Tool Response Cache: Cache tool results
- Time-based Expiration: Auto-invalidate old data
- Conditional Requests: Only fetch if changed
Batching
Group multiple operations:
Streaming
Return results progressively:
Error Handling
Error Types
- Client Error (4xx): Invalid request
- Server Error (5xx): Tool execution failed
- Timeout: Operation took too long
- Rate Limited: Too many requests
Recovery Strategies
- Retry with backoff
- Fallback to alternative tool
- Return cached result
- Inform user of limitation
Next Steps
Learn how to build custom MCPs in Custom MCPs and explore integrations in Integrations.
© 2025 UI Lab • Built for humans and machines