Skip to main content
GET
/
tools
/
health_check
Health Check
curl --request GET \
  --url https://api.example.com/tools/health_check
{
  "status": "<string>",
  "server": {
    "version": "<string>",
    "uptime": 123,
    "pylanceVersion": "<string>"
  },
  "workspace": {
    "loaded": true,
    "fileCount": 123,
    "pythonVersion": "<string>",
    "indexingProgress": 123
  },
  "metrics": {
    "requestsPerMinute": 123,
    "avgResponseTime": 123,
    "errorRate": 123
  }
}

Overview

Check the health status of the Pylance MCP server and your workspace. Use this to verify connectivity, monitor performance, and troubleshoot issues.

Request

includeWorkspace
boolean
default:"true"
Include workspace-specific health information
includeMetrics
boolean
default:"false"
Include performance metrics

Response

status
string
Overall health status: healthy, degraded, unhealthy
server
object
Server health information
workspace
object
Workspace health information (if includeWorkspace: true)
metrics
object
Performance metrics (if includeMetrics: true)

Example Request

curl -X POST https://api.pylancemcp.dev/v1/tools/call \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "health_check",
    "arguments": {
      "includeWorkspace": true,
      "includeMetrics": true
    }
  }'

Example Response

{
  "status": "healthy",
  "server": {
    "version": "1.2.3",
    "uptime": 3600,
    "pylanceVersion": "2024.1.1"
  },
  "workspace": {
    "loaded": true,
    "fileCount": 247,
    "pythonVersion": "3.11.5",
    "indexingProgress": 100
  },
  "metrics": {
    "requestsPerMinute": 45,
    "avgResponseTime": 87,
    "errorRate": 0.5
  }
}

Health Status

StatusMeaningAction
healthyAll systems operationalNone needed
degradedPartial functionalityCheck specific issues
unhealthyServer not responding correctlyRestart or contact support

Use Cases

Startup Verification

# Check if server is ready before making requests
def wait_for_server_ready(client, timeout=30):
    import time
    start = time.time()
    
    while time.time() - start < timeout:
        try:
            health = client.health_check()
            
            if health.status == "healthy":
                print("βœ… Server is ready")
                return True
            elif health.status == "degraded":
                print("⚠️  Server is degraded but functional")
                return True
            else:
                print("⏳ Server not ready, waiting...")
        except Exception as e:
            print(f"❌ Connection error: {e}")
        
        time.sleep(2)
    
    print("❌ Timeout waiting for server")
    return False

# Use it
client = Client(api_key="YOUR_API_KEY")
if wait_for_server_ready(client):
    # Proceed with requests
    completions = client.get_completions(...)

Monitor Workspace Loading

# Wait for workspace to finish indexing
def wait_for_workspace_loaded(client):
    import time
    
    while True:
        health = client.health_check(include_workspace=True)
        
        if health.workspace.loaded:
            print(f"βœ… Workspace ready: {health.workspace.file_count} files")
            break
        else:
            progress = health.workspace.indexing_progress
            print(f"⏳ Indexing workspace: {progress}%")
            time.sleep(1)

wait_for_workspace_loaded(client)

Performance Monitoring

# Monitor server performance over time
def monitor_performance(client, duration_minutes=60):
    import time
    
    start_time = time.time()
    samples = []
    
    while time.time() - start_time < duration_minutes * 60:
        health = client.health_check(include_metrics=True)
        
        samples.append({
            "timestamp": time.time(),
            "response_time": health.metrics.avg_response_time,
            "error_rate": health.metrics.error_rate,
            "requests_per_min": health.metrics.requests_per_minute
        })
        
        # Alert if performance degrades
        if health.metrics.avg_response_time > 200:
            print(f"⚠️  Slow responses: {health.metrics.avg_response_time}ms")
        
        if health.metrics.error_rate > 5.0:
            print(f"⚠️  High error rate: {health.metrics.error_rate}%")
        
        time.sleep(60)  # Check every minute
    
    return samples

Troubleshooting Helper

# Diagnose common issues
def diagnose_issues(client):
    print("πŸ” Running diagnostics...\n")
    
    try:
        health = client.health_check(
            include_workspace=True,
            include_metrics=True
        )
    except Exception as e:
        print(f"❌ Cannot connect to server: {e}")
        return
    
    # Check server status
    if health.status != "healthy":
        print(f"❌ Server status: {health.status}")
    else:
        print(f"βœ… Server is healthy")
    
    print(f"   Version: {health.server.version}")
    print(f"   Uptime: {health.server.uptime}s")
    
    # Check workspace
    if not health.workspace.loaded:
        print(f"\n⏳ Workspace still indexing: {health.workspace.indexing_progress}%")
        print("   Wait for indexing to complete")
    else:
        print(f"\nβœ… Workspace loaded")
        print(f"   Files: {health.workspace.file_count}")
        print(f"   Python: {health.workspace.python_version}")
    
    # Check performance
    if health.metrics.avg_response_time > 150:
        print(f"\n⚠️  Slow response times: {health.metrics.avg_response_time}ms")
        print("   Consider reducing request frequency")
    
    if health.metrics.error_rate > 2.0:
        print(f"\n⚠️  Elevated error rate: {health.metrics.error_rate}%")
        print("   Check logs for specific errors")

diagnose_issues(client)

Interpreting Metrics

Response Time

RangeStatusAction
0-100msExcellentNone
100-200msGoodNone
200-500msAcceptableMonitor
>500msSlowInvestigate

Error Rate

RangeStatusAction
0-1%NormalNone
1-5%ElevatedReview errors
5-10%HighCheck logs
>10%CriticalContact support

Requests Per Minute

Monitor to avoid rate limits:
health = client.health_check(include_metrics=True)
rpm = health.metrics.requests_per_minute

# Free tier: 20/hour = 0.33/minute
# Hobby tier: 500/hour = 8.33/minute
# Pro tier: 5000/hour = 83.33/minute

if rpm > (YOUR_TIER_HOURLY_LIMIT / 60) * 0.8:
    print("⚠️  Approaching rate limit")

Performance Tips

Lightweight: Health checks are fast (<10ms) and don’t count against rate limits Cache Status: Cache health status for 30-60 seconds to avoid excessive checks
Startup Only: Use detailed checks (metrics) only during startup/troubleshooting

Error Responses

CodeReasonSolution
SERVER_UNAVAILABLEServer not respondingCheck network connection
AUTHENTICATION_FAILEDInvalid API keyVerify API key
MAINTENANCE_MODEServer under maintenanceWait and retry

Rate Limits

Health checks do not count toward your API rate limits. Check as often as needed.

Get Diagnostics

Check for code errors

List Files

See workspace file count

Workspace Structure

View project structure