# Hasura MCP for AI Agents AI Agent Connect

> Hasura MCP lets your AI agent talk directly to your Hasura engine. It handles GraphQL queries, metadata updates, SQL performance checks, and health monitoring without you having to switch tabs or manually configure every endpoint. Connect your engine to your AI client to manage your data layer through natural language and automate your backend workflows.

## Overview
- **Category:** developer-tools
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_Q19k5WrSMOV2zDZs6DlIbmRJGyWfSnbLHJlhJLmt/ai-agent-connect
- **Tags:** graphql, hasura, postgres, api-engine, sql-analysis

## Description

This Connector connects your engine to your AI agent to automate database management and API orchestration through natural language. Managing a complex database layer usually means jumping between a dashboard, a SQL editor, and your IDE. This connection changes that by giving your agent a direct line to your engine. You can ask your agent to run specific GraphQL mutations, check if your metadata is consistent, or find out why a particular query is lagging. It handles the heavy lifting of interacting with your /v1/graphql endpoint while keeping your configuration secure. Since Vinkius hosts this Connector, you can plug it into your existing workflow and start managing your data layer through plain English. You can stop worrying about manual schema updates or hunting down slow queries. It's about moving from manual configuration to just telling your agent what needs to happen.

## Tools

### execute_metadata
Run specific Hasura Metadata API operations to manage your schema. This helps you automate permission and relationship updates.

### get_config
Pull your current Hasura configuration for quick reference. It's the fastest way to check environment settings.

### get_version
Quickly find out which version and type of Hasura engine you're running. This is great for debugging environment mismatches.

### pg_dump
Trigger a pg_dump on your connected Postgres source for schema exports. Use this to quickly grab your current data structure.

### explain_graphql
See the generated SQL and execution plans to find performance bottlenecks. Use this to optimize slow queries instantly.

### check_health
Monitor your engine health and verify that metadata stays consistent. Use strict mode to ensure your environment is perfectly synced.

### execute_graphql
Run queries, mutations, or batched requests against your GraphQL endpoint. It lets your agent interact with your data directly.

## Prompt Examples

**Prompt:** 
```
Check if my Hasura engine is healthy and tell me the version.
```

**Response:** 
```
I've checked your engine status. It's currently running version 2.x.x and the health check passed. Metadata consistency is verified.
```

**Prompt:** 
```
Run a GraphQL query to get all active users.
```

**Response:** 
```
I've executed that for you. Here are the active users:

| ID | Username | Status |
|---|---|---|
| 101 | admin_user | Active |
| 105 | dev_test | Active |
| 110 | guest_01 | Inactive |
```

**Prompt:** 
```
Explain why this query is taking so long: { users { id } }
```

**Response:** 
```
The execution plan shows a full table scan. It's costing 15.40. You might want to add an index on the users table to improve performance.
```

## Capabilities

### Run GraphQL queries and mutations
Execute complex requests against your GraphQL endpoint with full variable support.

### Update table relationships and permissions
Manage your schema metadata programmatically through the Metadata API.

### Inspect SQL execution plans for optimization
Analyze generated SQL to find performance bottlenecks and optimize your database.

### Verify engine health and metadata consistency
Monitor your environment's health and ensure your metadata remains consistent.

### Trigger Postgres database backups
Run pg_dump operations on connected Postgres sources for quick schema exports.

### Fetch current engine configuration details
Retrieve your current configuration for quick reference during development.

### Check the current version of your engine
Get the specific version and type of your Hasura engine in one command.

## Use Cases

### Fixing a slow query
A developer needs to see why a specific query is slow. They ask the agent to explain the GraphQL query, and it uses explain_graphql to show the index scan cost.

### Exporting schema for migration
A data engineer needs to export a schema for a migration. They tell the agent to trigger a pg_dump on the Postgres source.

### Testing new mutations
A backend dev is testing a new mutation. They ask the agent to run a batched request using execute_graphql to verify the response.

### Verifying environment health
A DevOps engineer wants to ensure the staging environment is healthy. They ask the agent to check health with strict mode enabled.

## Benefits

- Stop context switching between your IDE and the Hasura dashboard by using execute_graphql to run queries directly.
- Identify and fix slow queries faster by using explain_graphql to see the underlying SQL execution plans.
- Automate schema updates and permission changes through execute_metadata instead of manual configuration clicks.
- Keep your production environment stable by using check_health to verify metadata consistency automatically.
- Simplify your backup routine by using pg_dump to trigger exports on your connected Postgres sources.
- Get instant visibility into your environment by using get_config and get_version to check engine details.

## How It Works

The bottom line is your AI agent becomes a functional extension of your Hasura management dashboard.

1. Connect your Hasura GraphQL Endpoint URL and Admin Secret to the Connector.
2. Link the Connector to your preferred AI client like Claude or Cursor.
3. Ask your agent to perform tasks like running queries, checking health, or analyzing SQL.

## Frequently Asked Questions

**What can the Hasura MCP do for my GraphQL queries?**
It lets your AI agent run queries and mutations directly. You can ask it to fetch data or update records without leaving your editor.

**How does the Hasura MCP help with database performance?**
It uses the explain tool to analyze your SQL execution plans. Your agent can tell you exactly why a query is slow and what needs fixing.

**Can I use the Hasura MCP to manage my metadata?**
Yes, your agent can use it to track tables, define relationships, and manage permissions programmatically.

**Does the Hasura MCP support Postgres backups?**
It can trigger pg_dump on your connected Postgres sources. This makes it easy to export schemas or perform quick backups via your agent.

**How do I use the Hasura MCP to check engine health?**
You can ask your agent to check the engine's health. It can even use a strict mode to verify that your metadata is consistent.

**Can the Hasura MCP show me my current engine configuration?**
Yes, your agent can retrieve your full Hasura configuration and version details whenever you need them.

**Is the Hasura MCP safe for production use?**
Yes, it uses your existing Admin Secret to interact with your engine. It provides a secure way for your AI agent to perform authorized tasks like health checks and query execution.

**Can I see the actual SQL query that Hasura generates for my GraphQL request?**
Yes! Use the `explain_graphql` tool. It will return the generated SQL and the execution plan from the database, helping you debug performance issues.

**How do I check if my metadata is inconsistent or if the server is down?**
You can use the `check_health` tool. If you set the `strict` parameter to true, it will specifically check for metadata consistency in addition to basic connectivity.

**Is it possible to export my database schema through this server?**
Yes, the `pg_dump` tool allows you to execute a schema dump on your connected Postgres source, which is useful for migrations or backups.