This comprehensive troubleshooting guide helps you resolve common issues with Model Context Protocol (MCP) integration in Consultia.
Symptoms:
Diagnostic Steps:
Check Server URL
# Test server connectivity
curl -I https://your-domain.com/api/mcp
# Expected response:
# HTTP/2 200
# Content-Type: application/json
Verify Network Connectivity
# Test basic connectivity
ping your-domain.com
# Test DNS resolution
nslookup your-domain.com
# Test port connectivity
telnet your-domain.com 443
Check Firewall Settings
Solutions:
Correct Server URL
✅ Production: https://your-domain.com/api/mcp
✅ Development: http://localhost:3000/api/mcp
❌ Wrong: https://your-domain.com/mcp
❌ Wrong: http://your-domain.com/api/mcp (no HTTPS)
Network Configuration
# Add to /etc/hosts for local testing
127.0.0.1 localhost
# Configure proxy if needed
export HTTP_PROXY=http://proxy.company.com:8080
export HTTPS_PROXY=http://proxy.company.com:8080
VPN Configuration
Symptoms:
Diagnostic Steps:
Verify API Key Format
# API key should start with 'ck_' and be 64 characters
echo "ck_1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" | wc -c
# Expected: 67 (including newline)
Check API Key Validity
Test API Key
# Test with curl
curl -X POST https://your-domain.com/api/mcp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ck_your_api_key_here" \
-d '{"method": "tools/list"}'
Solutions:
Regenerate API Key
Check Key Permissions
Update Configuration
Symptoms:
Common Error Messages:
{
"success": false,
"error": "Insufficient permissions to access customer data",
"error_code": "PERMISSION_DENIED",
"execution_time_ms": 12
}
Diagnostic Steps:
Check API Key Permissions
# List required permissions for each tool
- query_crm_data: READ_CUSTOMERS, READ_INVOICES, READ_PAYMENTS
- get_crm_analytics: READ_CUSTOMERS, READ_INVOICES, READ_PAYMENTS
- execute_crm_action: EXECUTE_ACTIONS
Verify User Permissions
Solutions:
Update API Key Permissions
Create New API Key with Correct Permissions
Symptoms:
Diagnostic Steps:
Check Data Existence
// Test with minimal filters
{
"method": "tools/call",
"params": {
"name": "query_crm_data",
"arguments": {
"entity": "customers",
"filters": {},
"limit": 10
}
}
}
Verify Tenant Isolation
Check Filter Logic
// Common filter issues
{
"filters": {
"isArchived": false, // ✅ Correct
"status": "ACTIVE" // ❌ Wrong field name
}
}
Solutions:
Use Correct Entity Names
// Supported entities
"entity": "customers" // ✅ Correct
"entity": "invoices" // ✅ Correct
"entity": "payments" // ✅ Correct
"entity": "resources" // ✅ Correct
"entity": "products" // ✅ Correct
Remove Restrictive Filters
// Start with no filters
{
"entity": "customers",
"filters": {},
"limit": 5
}
// Then add filters gradually
{
"entity": "customers",
"filters": {
"isArchived": false
},
"limit": 5
}
Check Data Status
Symptoms:
Diagnostic Steps:
Check Network Latency
# Test network latency
ping your-domain.com
# Test HTTP latency
curl -w "@curl-format.txt" -o /dev/null -s https://your-domain.com/api/mcp
Monitor Query Complexity
// Simple query (fast)
{
"entity": "customers",
"limit": 10
}
// Complex query (slower)
{
"entity": "customers",
"filters": {
"purchaseOrders": {
"some": {
"invoices": {
"some": {
"status": "PAID"
}
}
}
}
},
"include": {
"purchaseOrders": {
"include": {
"invoices": true
}
}
}
}
Solutions:
Optimize Queries
// Use pagination for large datasets
{
"entity": "customers",
"limit": 20,
"offset": 0
}
// Use specific filters
{
"entity": "customers",
"filters": {
"createdAt": {
"gte": "2024-01-01T00:00:00Z"
}
}
}
Network Optimization
Server Performance
Symptoms:
Error Message:
{
"success": false,
"error": "Rate limit exceeded. Please try again later.",
"error_code": "RATE_LIMIT_EXCEEDED",
"retry_after": 60
}
Solutions:
Respect Rate Limits
Optimize Request Frequency
// Example: Implement rate limiting
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
async function makeRequest() {
try {
const response = await fetch('/api/mcp', options);
if (response.status === 429) {
const retryAfter = response.headers.get('Retry-After');
await delay(retryAfter * 1000);
return makeRequest(); // Retry
}
return response;
} catch (error) {
console.error('Request failed:', error);
}
}
Use Caching
Symptoms:
Diagnostic Steps:
Check Key Format
# API key should be exactly 64 characters after 'ck_' prefix
echo "ck_1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" | wc -c
# Should be 67 (including newline and 'ck_' prefix)
Verify Key Structure
# Check for valid characters (hexadecimal)
echo "ck_1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" | grep -E "^ck_[a-f0-9]{64}$"
Solutions:
Regenerate API Key
Update Configuration
Symptoms:
Diagnostic Steps:
Check Required Permissions
// Tools and their required permissions
{
"list_tools": [],
"call_tool": [],
"query_crm_data": ["READ_CUSTOMERS", "READ_INVOICES", "READ_PAYMENTS"],
"get_crm_analytics": ["READ_CUSTOMERS", "READ_INVOICES", "READ_PAYMENTS"],
"execute_crm_action": ["EXECUTE_ACTIONS"]
}
Verify Current Permissions
Solutions:
Add Missing Permissions
Create New Key with Full Permissions
Error Code | Description | Solution |
---|---|---|
PERMISSION_DENIED |
Insufficient permissions | Add required permissions to API key |
INVALID_PARAMETERS |
Invalid or missing parameters | Check parameter format and requirements |
ENTITY_NOT_FOUND |
Requested entity not found | Verify entity name and existence |
VALIDATION_ERROR |
Data validation failed | Check input data format and constraints |
RATE_LIMIT_EXCEEDED |
API rate limit exceeded | Wait and retry with exponential backoff |
INTERNAL_ERROR |
Internal server error | Contact support with error details |
AUTHENTICATION_FAILED |
Invalid API key or authentication | Regenerate and update API key |
NETWORK_ERROR |
Network connectivity issue | Check network connection and firewall |
Status Code | Meaning | Action |
---|---|---|
200 | Success | Continue normal operation |
400 | Bad Request | Check request parameters |
401 | Unauthorized | Verify API key and authentication |
403 | Forbidden | Check API key permissions |
404 | Not Found | Verify endpoint URL and entity names |
429 | Too Many Requests | Implement rate limiting and retry |
500 | Internal Server Error | Contact support |
502 | Bad Gateway | Check server connectivity |
503 | Service Unavailable | Wait and retry later |
Use Connection Tester
Test with curl
# Test basic connectivity
curl -I https://your-domain.com/api/mcp
# Test with API key
curl -X POST https://your-domain.com/api/mcp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ck_your_api_key" \
-d '{"method": "tools/list"}'
Check Audit Logs
Usage Dashboard
Network Diagnostics
# Test network performance
traceroute your-domain.com
# Check DNS resolution
dig your-domain.com
# Test SSL connection
openssl s_client -connect your-domain.com:443
Documentation
Community Support
When contacting support, provide:
Error Details
Environment Information
Steps to Reproduce
Logs and Screenshots
API Key Management
Network Monitoring
Software Updates
Set Up Alerts
Regular Testing
Documentation Updates
Manual
Consultia Documentation