health
Verify the operational status of the Headlesshost API to ensure system connectivity and functionality.
Instructions
Check the health status of the Headlesshost API
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:205-236 (registration)Registration of the 'health' MCP tool, including empty input schema and inline handler that fetches health status from the Headlesshost API (/tools/health) and returns the JSON response or error.server.registerTool( "health", { title: "Health Check", description: "Check the health status of the Headlesshost API", inputSchema: {}, }, async () => { try { const response: AxiosResponse<ApiResponse> = await apiClient.get("/tools/health"); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: handleApiError(error), }, ], isError: true, }; } } );
- src/index.ts:212-235 (handler)The handler function for the 'health' tool: performs a GET request to the API's /tools/health endpoint, returns the response as formatted JSON text, or an error message using handleApiError if the request fails.async () => { try { const response: AxiosResponse<ApiResponse> = await apiClient.get("/tools/health"); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: handleApiError(error), }, ], isError: true, }; } }
- src/index.ts:158-166 (helper)Utility helper function used by the health tool handler (and others) to format and return API error messages as strings.function handleApiError(error: any): string { if (error.response) { return `API Error ${error.response.status}: ${error.response.data?.message || error.response.statusText}`; } else if (error.request) { return "Network Error: Unable to reach API server"; } else { return `Error: ${error.message}`; } }