check_http_endpoint
Test HTTP/HTTPS endpoint health by checking connectivity, response time, and status codes. Use this tool to monitor APIs, websites, and web services for availability and performance.
Instructions
Check if an HTTP/HTTPS endpoint is healthy and responsive. This tool will test connectivity, measure response time, and validate status codes. Perfect for monitoring APIs, websites, and web services.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The URL to check (e.g., https://google.com) | |
| method | No | HTTP method to use | GET |
| timeout | No | Request timeout in milliseconds | |
| expectedStatus | No | Expected HTTP status code | |
| headers | No | Optional HTTP headers to include |
Implementation Reference
- src/tools/check-http.ts:103-132 (handler)The primary handler method of the CheckHttpEndpointTool class that validates input parameters, performs the HTTP health check using HttpHealthChecker, handles errors, and returns a formatted response.async execute(params: CheckHttpEndpointParams): Promise<string> { try { // Validate the input parameters const validatedParams = CheckHttpEndpointSchema.parse(params); // Convert to the format our health checker expects const checkOptions: HttpCheckOptions = { url: validatedParams.url, method: validatedParams.method, timeout: validatedParams.timeout, expectedStatus: validatedParams.expectedStatus, headers: validatedParams.headers }; // Perform the actual health check const result = await this.healthChecker.checkEndpoint(checkOptions); // Format the response in a way that's helpful for Claude and users return this.formatHealthCheckResponse(result); } catch (error) { // Handle validation errors or unexpected issues if (error instanceof z.ZodError) { const issues = error.errors.map(err => `${err.path.join('.')}: ${err.message}`).join(', '); return `❌ Input validation failed: ${issues}`; } return `❌ Unexpected error: ${error instanceof Error ? error.message : 'Unknown error'}`; } }
- src/tools/check-http.ts:8-34 (schema)Zod schema for input validation of the check_http_endpoint tool parameters including URL, method, timeout, expected status, and headers.const CheckHttpEndpointSchema = z.object({ url: SecureUrlSchema .describe('The URL to check (e.g., https://google.com)'), method: z.enum(['GET', 'POST', 'PUT', 'DELETE']) .optional() .default('GET') .describe('HTTP method to use'), timeout: z.number() .min(1000, 'Timeout must be at least 1 second') .max(30000, 'Timeout cannot exceed 30 seconds') .optional() .default(10000) .describe('Request timeout in milliseconds'), expectedStatus: z.number() .min(100) .max(599) .optional() .default(200) .describe('Expected HTTP status code'), headers: z.record(z.string()) .optional() .describe('Optional HTTP headers to include') });
- src/server.ts:55-64 (registration)MCP server registration of the check_http_endpoint tool via inclusion in the tools/list response using CheckHttpEndpointTool.getDefinition().this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ CheckHttpEndpointTool.getDefinition(), // Future tools will be added here: // - check_database_connection // - check_service_health // - get_health_summary ], };
- src/server.ts:76-85 (registration)Dispatch/execution routing in the MCP tools/call handler for the check_http_endpoint tool, invoking the tool's execute method.case 'check_http_endpoint': const result = await this.checkHttpTool.execute(args as any || {}); return { content: [ { type: 'text', text: result, }, ], };
- src/tools/check-http.ts:138-177 (helper)Helper method that formats the raw health check result into a readable, emoji-enhanced response string for the user.private formatHealthCheckResponse(result: any): string { const statusEmoji: Record<string, string> = { healthy: '✅', warning: '⚠️', unhealthy: '❌' }; const emoji = statusEmoji[result.status] || '❓'; const response = [ `${emoji} **Health Check Result**`, ``, `**URL:** ${result.details?.url}`, `**Status:** ${result.status.toUpperCase()}`, `**Response Time:** ${result.responseTime}ms`, ]; if (result.statusCode) { response.push(`**HTTP Status:** ${result.statusCode}`); } response.push(`**Message:** ${result.message}`); if (result.details?.error) { response.push(`**Error Details:** ${result.details.error}`); } response.push(`**Checked At:** ${result.details?.timestamp}`); // Add interpretation to help users understand the results response.push('', '**Interpretation:**'); if (result.status === 'healthy') { response.push('🎉 The endpoint is working perfectly! No issues detected.'); } else if (result.status === 'warning') { response.push('⚠️ The endpoint is responding but may need attention. Check if this is expected behavior.'); } else { response.push('🚨 The endpoint has issues and may be down or misconfigured. Investigation needed.'); } return response.join('\n'); }