Skip to content

Repository files navigation

Hasura MCP Server

Model Context Protocol server for Hasura GraphQL Engine - enables natural language interaction with Hasura instances.

Docker Hub: sanjay3290/hasura-mcp Author: Sanjay Ramadugu License: Apache 2.0

What is This?

An MCP server that enables AI assistants (Claude Desktop, etc.) to interact with Hasura GraphQL Engine for:

  • Metadata management (export, apply, reload, clear)
  • SQL query execution
  • Schema introspection
  • Interactive debugging and setup

Quick Start

# Pull the Docker image
docker pull sanjay3290/hasura-mcp:latest

# Run with your Hasura instance
docker run -i --rm \
  --network host \
  sanjay3290/hasura-mcp:latest \
  --endpoint http://localhost:8080 \
  --admin-secret your-secret

For remote Hasura instances, omit --network host:

docker run -i --rm \
  sanjay3290/hasura-mcp:latest \
  --endpoint https://your-hasura.com \
  --admin-secret your-secret

Features

Tools (9)

  • export_metadata - Export current Hasura metadata
  • apply_metadata - Apply metadata changes
  • reload_metadata - Reload metadata from database
  • clear_metadata - Clear all metadata (read-only mode blocks this)
  • get_inconsistent_metadata - List metadata inconsistencies
  • drop_inconsistent_metadata - Drop inconsistent metadata objects
  • run_sql - Execute SQL queries
  • get_version - Get Hasura version information
  • get_schema - Get database schema information

Resources (4)

  • hasura://metadata - Current metadata as JSON
  • hasura://version - Hasura version details
  • hasura://schema - Database schema information
  • hasura://inconsistent-metadata - Current inconsistencies

Prompts (4)

  • setup_table - Interactive table setup wizard
  • debug_metadata - Metadata debugging assistant
  • create_migration - Migration creation helper
  • setup_permissions - Permission configuration guide

Source Code

The source code is maintained in the Hasura GraphQL Engine fork:

Repository: https://github.com/sanjay3290/graphql-engine Location: cli/cmd/mcp-server/

This allows building from source while keeping the full Hasura CLI context available.

Documentation

Docker Image Details

  • Base: Alpine Linux 3.19
  • Size: ~41MB compressed
  • User: Non-root (hasura:1000)
  • Architecture: linux/amd64
  • Tags: latest, 1.0.0

Configuration

Command Line Flags

--endpoint, -e      Hasura endpoint URL (required)
--admin-secret, -s  Hasura admin secret (optional but recommended)
--read-only, -r     Enable read-only mode (disables destructive operations)
--name, -n          MCP server name (default: "hasura-mcp-server")
--version, -v       Print version information

Environment Variables

HASURA_GRAPHQL_ENDPOINT       # Hasura endpoint URL
HASURA_GRAPHQL_ADMIN_SECRET   # Admin secret

Command line flags take precedence over environment variables.

Read-Only Mode

Enable read-only mode for production safety:

docker run -i --rm \
  sanjay3290/hasura-mcp:latest \
  --endpoint https://prod-hasura.com \
  --admin-secret secret \
  --read-only

In read-only mode, these operations are blocked:

  • apply_metadata
  • clear_metadata
  • drop_inconsistent_metadata

Example Use Cases

Metadata Management

"Export the current metadata and show me the tables configuration"

Schema Exploration

"What tables exist in the database and what are their relationships?"

Debugging

"Check for any metadata inconsistencies and explain what they mean"

SQL Operations

"Run a query to count users created in the last 7 days"

Setup Assistance

"Help me set up permissions for the users table with select access for user role"

Community

License

Licensed under the Apache License 2.0 - see LICENSE file for details.

Attribution

This MCP server is built using Hasura GraphQL Engine internal libraries:

  • Hasura GraphQL Engine: Copyright (c) Hasura Inc. - Apache 2.0
  • MCP-Go SDK: Copyright (c) 2024 Anthropic, PBC - MIT

This is a derivative work based on Hasura's open source code. All trademarks and product names are the property of their respective owners.

This is an independent community project, not officially affiliated with or endorsed by Hasura Inc.

Changelog

See CHANGELOG.md for version history and updates.

About

Documentation and community resources for Hasura MCP Server - Model Context Protocol integration for Hasura GraphQL Engine

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors