Overview
Model Context Protocol (MCP) is an open standard that enables agents to connect with external tools, APIs, and data sources. The platform provides comprehensive MCP support, allowing agents to access hundreds of integrations including GitHub, Slack, Google Workspace, databases, and custom services.MCP Architecture
MCP Registry
TheMCPRegistry is the central component managing all MCP tools:
backend/core/agentpress/mcp_registry.py:64-78
MCP Tool Info
Each MCP tool is tracked with comprehensive metadata:backend/core/agentpress/mcp_registry.py:33-49
MCP Tool Status
Tools progress through lifecycle states:backend/core/agentpress/mcp_registry.py:25-30
MCP Server Types
The platform supports three types of MCP servers:1. HTTP/Streamable HTTP
HTTP-based MCP servers using the streamable HTTP transport:backend/core/agentpress/mcp_registry.py:487-525
2. SSE (Server-Sent Events)
Server-Sent Events for real-time tool communication:backend/core/agentpress/mcp_registry.py:419-485
3. JSON/stdio (Local Processes)
Local process-based MCP servers:backend/core/agentpress/mcp_registry.py:527-571
Schema Caching
MCP schemas are cached in Redis for fast access:Cache Strategy
- Check Redis first: Look for cached toolkit schemas
- Cache miss: Load from MCP server
- Store in Redis: Cache for 24 hours (configurable)
- Opportunistic caching: Cache all tools from toolkit, not just requested ones
backend/core/agentpress/mcp_registry.py:153-169
Cache TTL
Schemas are cached for 24 hours by default:backend/core/agentpress/mcp_registry.py:65
Tool Discovery
MCP tools are discovered through multiple methods:1. Composio Integration
For Composio-based MCP tools:backend/core/agentpress/mcp_registry.py:304-361
2. Custom MCP Servers
For custom MCP servers:backend/core/agentpress/mcp_registry.py:261-300
MCP Execution Context
MCP tools execute within a context that tracks usage:backend/core/agentpress/mcp_registry.py:52-61
Tool Execution
MCP tools are executed through the registry:backend/core/agentpress/mcp_registry.py:573-619
Auto-Activation
Tools are automatically activated on first use:backend/core/agentpress/mcp_registry.py:621-665
Schema Pre-warming
Schemas can be pre-loaded at startup for faster first use:backend/core/agentpress/mcp_registry.py:671-690
Registry Operations
Register Tool
backend/core/agentpress/mcp_registry.py:80-92
Activate Tool
backend/core/agentpress/mcp_registry.py:94-108
Query Tools
backend/core/agentpress/mcp_registry.py:126-140
Get Statistics
backend/core/agentpress/mcp_registry.py:693-703
Integration with Agent Loader
The MCP registry is initialized from the JIT loader:backend/core/agentpress/mcp_registry.py:719-741
Description Enrichment
Some tools have their descriptions enriched with usage hints:backend/core/agentpress/mcp_registry.py:10-22
Singleton Pattern
The MCP registry uses a singleton pattern:backend/core/agentpress/mcp_registry.py:706-716
Performance Optimizations
Multi-Level Caching
- In-memory cache: Tool schemas cached in registry
- Redis cache: Toolkit schemas cached for 24 hours
- Opportunistic caching: All toolkit tools cached when one is loaded
Batch Loading
When loading multiple MCP tools, schemas are batched by toolkit:backend/core/agentpress/mcp_registry.py:236-300
Lazy Activation
MCP tools are not activated until first use, saving:- Startup time
- Memory usage
- Network calls to MCP servers
Related Concepts
Tools
Learn about the broader tool system
Agents
Understand how agents use MCP tools
Credentials
Manage MCP authentication
Profiles
Configure MCP profiles