MCP Integration
Connect external tools and services to ChatRAG using the Model Context Protocol (MCP). Integrate with Zapier for Gmail, Calendar, Drive, and add custom MCP servers.
What is MCP?
What MCP Enables
Tool Execution
Execute actions in external services directly from chat conversations
Data Access
Retrieve information from connected services in real-time
Approval Flows
User approval required before executing sensitive operations
Multi-Step Workflows
Chain multiple tool calls to handle complex tasks
Zapier MCP (Pre-configured)
ChatRAG comes with Zapier MCP already configured! You just need to add your Zapier MCP endpoint URL to start using it.
What's Already Set Up
- Pattern-based intent detection for Zapier tools
- Gmail, Google Calendar, and Google Drive integrations
- Query classification and routing
- Tool caching for 15-minute sessions
- Approval flow UI
Setup Steps:
Get Your Zapier MCP Endpoint
Visit Zapier and navigate to the MCP integrations section to get your endpoint URL.
Your endpoint will look like:
https://mcp.zapier.com/api/mcp/s/[YOUR-TOKEN]/mcpConfigure in ChatRAG
Open the Config UI and add your Zapier MCP endpoint:
npm run config
# Navigate to: MCP → Zapier Configuration
# Paste your endpoint URL
# Click SaveOr set directly in .env.local:
MCP_ZAPIER_ENDPOINT=https://mcp.zapier.com/api/mcp/s/[YOUR-TOKEN]/mcpEnable MCP System
Enable MCP in your configuration:
NEXT_PUBLIC_MCP_SYSTEM_ENABLED=true
NEXT_PUBLIC_MCP_TOOLS_LIST_ENABLED=trueTest Your Integration
Restart your dev server and try these queries:
Example queries:
- "Fetch my last 5 emails"
- "Check my calendar for tomorrow"
- "Upload this image to Google Drive"
- "Draft a reply to the last email"
Pre-configured Zapier Tools
ChatRAG has pattern-based detection for these Zapier MCP tools:
Gmail - Find Email
High ConfidenceSearch and retrieve emails from Gmail
Example queries:
- "fetch my last 5 emails"
- "show recent emails from john@example.com"
- "check my inbox"
Gmail - Create Draft
Medium ConfidenceCreate email drafts in Gmail
Example queries:
- "draft an email to john@example.com"
- "create a gmail draft about meeting"
Gmail - Reply to Email
High ConfidenceSend replies to emails
Example queries:
- "reply to john's email saying yes"
- "send a reply to the last email"
Google Calendar - Find Event
Medium ConfidenceSearch calendar events
Example queries:
- "check my calendar for Monday"
- "what's scheduled for tomorrow?"
- "show my meetings this week"
Google Drive - Upload File
High ConfidenceUpload files to Google Drive
Example queries:
- "upload this image to drive"
- "save to google drive"
Adding Custom MCP Servers
Beyond Zapier, you can connect any MCP-compatible server to ChatRAG.
Step-by-Step Guide:
1. Open Config UI
npm run configNavigate to: MCP → Custom Servers
2. Click "Add Server"
Fill in the server details:
3. Configure Availability
Choose where the server is available:
- Chat: Enable in main chat interface
- Embed: Enable in embedded widget
4. Discover Tools
Click "Discover Tools" to enumerate available tools from the server
5. Test Connection
Use the "Test Connection" button to verify your server is accessible and responding correctly
Configuration Options
YOLO Mode
Auto-approve tool execution without user confirmation
NEXT_PUBLIC_MCP_YOLO_MODE_ENABLED=trueTools List
Show available MCP tools in the UI
NEXT_PUBLIC_MCP_TOOLS_LIST_ENABLED=trueCustom Servers
Configure multiple custom servers via environment
MCP_CUSTOM_SERVERS=[
{
"name": "My Custom Server",
"transport": "http",
"endpoint": "https://my-server.com/mcp",
"auth": "bearer",
"token": "..."
}
]Best Practices
Start with Approval Flow
Keep YOLO mode disabled initially to review tool executions before trusting them
Test Tools Individually
Verify each tool works correctly before combining them in workflows
Monitor Tool Usage
Check logs and approval prompts to understand tool behavior
Secure Credentials
Keep API tokens and auth credentials in environment variables, never in code
Health Monitoring
Use the health check endpoints to monitor MCP server availability
Troubleshooting
Tools not appearing
Solutions:
- Verify
NEXT_PUBLIC_MCP_SYSTEM_ENABLED=true - Check that your endpoint URL is correct
- Click "Discover Tools" in Config UI
- Check browser console for connection errors
Tool execution fails
Solutions:
- Verify authentication credentials are correct
- Check the server health endpoint
- Review approval prompt for parameter issues
- Check MCP server logs for errors
Connection timeout
Solutions:
- Verify the endpoint URL is accessible
- Check firewall and network settings
- Ensure the MCP server is running
- Try increasing timeout settings if needed
MCP Architecture
ChatRAG's MCP implementation includes:
- Production Router: Combines discovery, routing, and error handling
- Universal Client: Handles tool execution and protocol communication
- Smart Router: Intelligent tool selection and context-aware routing
- Query Classifier: Pattern-based intent detection
- Session Caching: 15-minute tool cache for performance