check_http_endpoint
Monitor HTTP/HTTPS endpoint health by testing connectivity, measuring response time, and validating status codes. Ideal for ensuring APIs, websites, and web services are responsive and operational.
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 |
|---|---|---|---|
| expectedStatus | No | Expected HTTP status code | |
| headers | No | Optional HTTP headers to include | |
| method | No | HTTP method to use | GET |
| timeout | No | Request timeout in milliseconds | |
| url | Yes | The URL to check (e.g., https://google.com) |
Implementation Reference
- src/tools/check-http.ts:103-132 (handler)The core handler function that executes the tool: validates input using Zod schema, converts parameters, calls HttpHealthChecker.checkEndpoint, formats the result, and handles errors.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 used for runtime validation of tool input parameters.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/tools/check-http.ts:54-97 (schema)Static method providing the MCP tool definition, including name, description, and JSON inputSchema.static getDefinition() { console.error('🔧 DEBUG: getDefinition() called!'); return { name: 'check_http_endpoint', description: '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.', inputSchema: { type: 'object', properties: { url: { type: 'string', format: 'uri', description: 'The URL to check (e.g., https://google.com)' }, method: { type: 'string', enum: ['GET', 'POST', 'PUT', 'DELETE'], default: 'GET', description: 'HTTP method to use' }, timeout: { type: 'number', minimum: 1000, maximum: 30000, default: 10000, description: 'Request timeout in milliseconds' }, expectedStatus: { type: 'number', minimum: 100, maximum: 599, default: 200, description: 'Expected HTTP status code' }, headers: { type: 'object', additionalProperties: { type: 'string' }, description: 'Optional HTTP headers to include' } }, required: ['url'] } };
- src/server.ts:55-65 (registration)Registers the check_http_endpoint tool in the MCP listTools request handler.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:75-85 (registration)Dispatches calls to 'check_http_endpoint' in the MCP tools/call request handler by invoking the tool's execute method.switch (name) { case 'check_http_endpoint': const result = await this.checkHttpTool.execute(args as any || {}); return { content: [ { type: 'text', text: result, }, ], };