health_check
Verify the reachability of a Hasura GraphQL endpoint by testing its health status using a specific HTTP URL to ensure operational reliability.
Instructions
Checks if the configured Hasura GraphQL endpoint is reachable...
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "health_check"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| healthEndpointUrl | No | Optional. A specific HTTP health check URL... |
Implementation Reference
- src/index.ts:444-464 (handler)The asynchronous handler function that executes the health_check tool. It checks the Hasura GraphQL endpoint reachability using a simple GraphQL query or an optional HTTP health endpoint via fetch.
async ({ healthEndpointUrl }) => { console.log(`[INFO] Executing tool 'health_check'...`); try { let resultText = ""; if (healthEndpointUrl) { console.log(`[DEBUG] Performing HTTP GET to: ${healthEndpointUrl}`); const response = await fetch(healthEndpointUrl, { method: 'GET' }); resultText = `Health endpoint ${healthEndpointUrl} status: ${response.status} ${response.statusText}`; if (!response.ok) throw new Error(resultText); } else { console.log(`[DEBUG] Performing GraphQL query { __typename } to: ${HASURA_ENDPOINT}`); const query = gql`query HealthCheck { __typename }`; const result = await makeGqlRequest(query); resultText = `GraphQL endpoint ${HASURA_ENDPOINT} is responsive. Result: ${JSON.stringify(result)}`; } return { content: [{ type: "text", text: `Health check successful. ${resultText}` }] }; } catch (error: any) { console.error(`[ERROR] Tool 'health_check' failed: ${error.message}`); return { content: [{ type: "text", text: `Health check failed: ${error.message}` }], isError: false }; } } - src/index.ts:441-443 (schema)Zod schema defining the input parameters for the health_check tool: an optional URL for a specific health endpoint.
{ healthEndpointUrl: z.string().url().optional().describe("Optional. A specific HTTP health check URL...") }, - src/index.ts:438-465 (registration)The server.tool() call that registers the 'health_check' tool, including its name, description, input schema, and handler function.
server.tool( "health_check", "Checks if the configured Hasura GraphQL endpoint is reachable...", { healthEndpointUrl: z.string().url().optional().describe("Optional. A specific HTTP health check URL...") }, async ({ healthEndpointUrl }) => { console.log(`[INFO] Executing tool 'health_check'...`); try { let resultText = ""; if (healthEndpointUrl) { console.log(`[DEBUG] Performing HTTP GET to: ${healthEndpointUrl}`); const response = await fetch(healthEndpointUrl, { method: 'GET' }); resultText = `Health endpoint ${healthEndpointUrl} status: ${response.status} ${response.statusText}`; if (!response.ok) throw new Error(resultText); } else { console.log(`[DEBUG] Performing GraphQL query { __typename } to: ${HASURA_ENDPOINT}`); const query = gql`query HealthCheck { __typename }`; const result = await makeGqlRequest(query); resultText = `GraphQL endpoint ${HASURA_ENDPOINT} is responsive. Result: ${JSON.stringify(result)}`; } return { content: [{ type: "text", text: `Health check successful. ${resultText}` }] }; } catch (error: any) { console.error(`[ERROR] Tool 'health_check' failed: ${error.message}`); return { content: [{ type: "text", text: `Health check failed: ${error.message}` }], isError: false }; } } );