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:

{
  "name": "get_weather",
  "description": "Get current weather for a location",
  "parameters": {
    "location": { "type": "string" }
  }
}

Tool Call

Invokes a tool:

{
  "type": "tool_call",
  "toolName": "get_weather",
  "parameters": { "location": "New York" }
}

Tool Response

Returns tool results:

{
  "type": "tool_response",
  "result": { "temperature": 72, "condition": "sunny" }
}

Protocol Flow

  1. Discovery: Client requests available tools
  2. Selection: Client chooses appropriate tool
  3. Invocation: Client calls tool with parameters
  4. Execution: Server executes tool
  5. Response: Server returns result
  6. Processing: Client processes result

Resource Types

APIs

Access external web services:

GET https://api.example.com/data
Authorization: Bearer token

Databases

Query structured data:

SELECT * FROM users WHERE active = true

File Systems

Access files and documents:

/documents/reports/2024-q1.pdf

Real-Time Data

Stream live information:

WebSocket: wss://stream.example.com/live

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:

{
  "type": "batch",
  "operations": [
    { "tool": "get_user", "params": { "id": "1" } },
    { "tool": "get_user", "params": { "id": "2" } }
  ]
}

Streaming

Return results progressively:

Send partial results immediately
Continue sending additional data
Complete with final summary

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