Skip to main content
Glama

Advanced Hasura GraphQL MCP Server

by husamabusafa

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...

Input Schema

NameRequiredDescriptionDefault
healthEndpointUrlNoOptional. A specific HTTP health check URL...

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "healthEndpointUrl": { "description": "Optional. A specific HTTP health check URL...", "format": "uri", "type": "string" } }, "type": "object" }

Implementation Reference

  • 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 }; } }
  • 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 }; } } );

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/husamabusafa/hasura_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server