A Model Context Protocol server that enables AI agents to dynamically interact with Hasura GraphQL endpoints through natural language, supporting schema discovery, data querying/manipulation, and aggregations.
Version: 1.1.0
This Model Context Protocol (MCP) server provides an advanced interface for AI agents (like those in Cursor or Claude Desktop) to interact with a Hasura GraphQL endpoint. It enables agents to discover the API structure, execute both read-only queries and mutations (with caution), preview data, perform aggregations, and check service health.
This server enhances LLM capabilities by allowing them to leverage your Hasura API dynamically based on natural language requests.
This server exposes the following MCP capabilities:
Resources:
hasura:/schema
)
application/json
Tools:
run_graphql_query
query { users { id name } }
{ query: string, variables?: object }
mutation
. Primarily relies on the query itself being read-only.run_graphql_mutation
mutation { insert_users_one(object: {name: "Test"}) { id } }
{ mutation: string, variables?: object }
list_tables
{ schemaName?: string }
(Optional schema name, attempts to infer from field descriptions if possible, defaults to 'public' conceptually)describe_table
{ tableName: string, schemaName?: string }
list_root_fields
{ fieldType?: 'QUERY' | 'MUTATION' | 'SUBSCRIPTION' }
(Optional filter)describe_graphql_type
{ typeName: string }
(Case-sensitive type name)preview_table_data
{ tableName: string, limit?: number }
aggregate_data
{ tableName: string, aggregateFunction: 'count'|'sum'|'avg'|'min'|'max', field?: string, filter?: object }
health_check
{ __typename }
). Can optionally check a specific HTTP health endpoint URL if known.{ healthEndpointUrl?: string }
(Optional specific health URL).nvmrc
or package.json engines
if specified)pnpm
(or npm
/yarn
, adjust commands accordingly)# git clone # cd mcp-hasura-advanced
pnpm install
This compiles the TypeScript code into thepnpm run build
dist
directory.Execute the compiled script from your terminal, providing the Hasura endpoint URL and optionally the admin secret:
# Using pnpm start script (defined in package.json) pnpm start [ADMIN_SECRET] # Or using Node directly node dist/index.js [ADMIN_SECRET]
Example:
pnpm start https://my-hasura.cloud/v1/graphql mysecretkey123
or
node dist/index.js https://my-hasura.cloud/v1/graphql mysecretkey123
If no admin secret is needed (using default role permissions):
pnpm start https://my-hasura.cloud/v1/graphql
The server will start, attempt an initial schema introspection, connect to the STDIO transport, and log status messages to stderr
. It listens for MCP JSON-RPC requests on stdin
and sends responses to stdout
.
To connect this server to an MCP client like Cursor:
which node
in your terminal.mcp-hasura-advanced
directory and run pwd
. Append /dist/index.js
to the result.pwd
.settings.json
for Cursor, claude_desktop_config.json
for Claude Desktop).cursor.customMcpServers
array for Cursor, mcpServers
object for Claude Desktop).Example Cursor settings.json
:
{ // ... other settings ... "cursor.customMcpServers": [ // ... other servers ... { "name": "My Advanced Hasura Server", // Name shown in Cursor UI "command": "/path/to/your/node", // [SECRET]` to run the server directly with `ts-node` for faster iteration (no build step needed). * **Testing:** Test individual tools by running the server manually (`pnpm start ...`) and piping JSON-RPC requests to its `stdin`.
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!