Overview
Thehealth_check tool provides diagnostic information about the Grok Search MCP server’s operational status, API connectivity, and performance metrics. Use this tool to verify server health, diagnose configuration issues, and monitor performance.
Parameters
This tool requires no parameters.Request Example
Response Format
Healthy Server Response
Unhealthy Server Response (Missing API Key)
Server with Recent Errors
Response Fields
Server Health Indicators
Overall server health status. Returns
true if the MCP server is running and operational.Interpretation:true- Server is running and responding to requestsfalse- Server has encountered critical errors
API connectivity and configuration status. Returns
true if the xAI API key is configured and API is accessible.Interpretation:true- API key is configured and API is accessiblefalse- API key missing or API connectivity issues
false:- Missing
XAI_API_KEYenvironment variable - Invalid API key format
- Network connectivity issues
Performance Metrics
Server uptime in milliseconds since the last restart.Example Values:
60000- 1 minute uptime3600000- 1 hour uptime86400000- 24 hours uptime
Total number of tool execution requests processed since server start.Includes: All tool calls (grok_search, grok_web_search, grok_news_search, grok_twitter, health_check)
Total number of failed requests since server start.Common Error Causes:
- Invalid input parameters
- API rate limiting
- Network timeouts
- Malformed queries
Percentage of successful requests calculated as
((total_requests - error_count) / total_requests) * 100.Format: Percentage string with two decimal places (e.g., “97.89%”)Interpretation:100%- Perfect success rate95%+- Excellent performance90-95%- Good performance with some errors<90%- Investigation recommended0%- Critical issue (likely missing API key)
API Details
Indicates whether the
XAI_API_KEY environment variable is configured.Values:true- API key is setfalse- API key is missing (configure in environment)
Number of comprehensive analysis results currently cached in memory.Cache Behavior:
- Maximum size: 100 items
- TTL (Time To Live): 30 minutes
- Eviction policy: LRU (Least Recently Used)
- Only comprehensive analyses are cached
0- No cached analyses (new server or no comprehensive searches)1-50- Normal cache usage50-100- Heavy cache usage100- Cache is full (oldest items will be evicted)
The most recent error message encountered by the server, or
null if no errors have occurred.Common Error Messages:null- No errors"API service is not healthy - missing XAI_API_KEY"- API key not configured"Request timeout after 30000ms"- Network or API timeout"Search query must be a non-empty string"- Input validation error"API request failed: 429 - Rate limit exceeded"- API rate limiting
Diagnostic Use Cases
1. Initial Configuration Verification
After installing and configuring the server, runhealth_check to verify setup:
api_healthy is false:
- Verify
XAI_API_KEYis set in Claude Desktop configuration - Check API key format (should start with “xai-”)
- Restart Claude Desktop after configuration changes
2. Performance Monitoring
Regularly check health to monitor server performance:- Success rate below 90% suggests recurring issues
- High error count may indicate input validation problems or API issues
- Monitor
lastErrorfor common error patterns
3. Cache Performance
Monitor cache utilization for comprehensive searches:- Cache near full (100) indicates frequent comprehensive analyses
- Empty cache (0) with comprehensive searches may indicate cache issues
- Cache size helps predict performance (cached queries are instant)
4. Troubleshooting Errors
When experiencing issues, checklastError for diagnostics:
| Last Error | Cause | Solution |
|---|---|---|
missing XAI_API_KEY | API key not configured | Add XAI_API_KEY to environment variables |
Request timeout | Network or API slow | Increase GROK_TIMEOUT env variable (default: 30000ms) |
Rate limit exceeded | Too many API requests | Wait for rate limit reset, implement request throttling |
Search query too long | Input validation | Ensure queries are under 1000 characters |
Invalid date format | Parameter validation | Use ISO8601 format (YYYY-MM-DD) for dates |
Integration Examples
Automated Health Monitoring
Periodically callhealth_check to monitor server health:
Pre-Request Validation
Check server health before making search requests:Cache Performance Analysis
Health Status Interpretation
Optimal Health
Configuration Issue
XAI_API_KEY environment variable
Degraded Performance
Usage Notes
- No Parameters Required: Always call with empty arguments object
- Instant Response: Health check executes immediately without API calls
- Does Not Count: Health check calls do not increment the error_count
- Cache Visibility: Shows current cache size for performance monitoring
- Error History: Only shows most recent error, not full history
- Uptime Tracking: Resets to 0 when server restarts
- Thread Safe: Safe to call concurrently with other operations
- Best Practice: Call health_check after initial configuration and when troubleshooting issues