HH

husamabusafa/hasura_mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

25 stars 12 forks 质量 55 趋势 0

该模型上下文协议(MCP)服务器为 AI 代理(如 Cursor 或 Claude Desktop 中的代理)提供了与 Hasura GraphQL 端点交互的高级接口。

概览

该模型上下文协议(MCP)服务器为 AI 代理(如 Cursor 或 Claude Desktop 中的代理)提供了与 Hasura GraphQL 端点交互的高级接口。它使代理能够发现 API 结构,执行只读查询和变异(需谨慎),预览数据,执行聚合,并检查服务健康状况。 该服务器通过允许它们基于自然语言请求动态利用您的 Hasura API 来增强 LLM 能力。 该服务器提供以下MCP功能: * * 提供通过标准内省获得的完整 GraphQL 模式定义。* application/json * 代理可以阅读此资源以理解 API 的完整结构,包括类型、字段、参数、指令等。 * * 对Hasura端点执行只读GraphQL查询。当没有特定工具时,用它获取数据。确保查询不修改数据。

概述(AI 翻译)

版本: 1.1.0

该模型上下文协议(MCP)服务器为 AI 代理(如 Cursor 或 Claude Desktop 中的代理)提供了与 Hasura GraphQL 端点交互的高级接口。它使代理能够发现 API 结构,执行只读查询和变异(需谨慎),预览数据,执行聚合,并检查服务健康状况。

该服务器通过允许它们基于自然语言请求动态利用您的 Hasura API 来增强 LLM 能力。

特色

该服务器提供以下MCP功能:

资源:

  • Hasura GraphQL 架构 (hasura:/schema)
  • 提供通过标准内省获得的完整 GraphQL 模式定义。
  • 哑剧类型: application/json
  • 代理可以阅读本资源以理解API的完整结构,包括类型、字段、参数、指令等。

工具:

  • run_graphql_query
  • Description: 对 Hasura 端点执行只读 GraphQL 查询。当没有特定工具时,利用此查询获取数据。确保查询不修改数据。示例:query { users { id name } }

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Advanced Hasura GraphQL MCP Server

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.

Features

This server exposes the following MCP capabilities:

Resources:

  • Hasura GraphQL Schema (hasura:/schema)
    • Provides the full GraphQL schema definition obtained via standard introspection.
    • MIME Type: application/json
    • Agents can read this resource to understand the complete structure of the API, including types, fields, arguments, directives, etc.

Tools:

  • run_graphql_query

    • Description: Executes a read-only GraphQL query against the Hasura endpoint. Use this for fetching data when a specific tool isn’t available. Ensure the query does not modify data. Example: query { users { id name } }
    • Input: { query: string, variables?: object }
    • Note: Performs a basic check to prevent execution of strings starting with mutation. Primarily relies on the query itself being read-only.
  • run_graphql_mutation

    • Description: Executes a GraphQL mutation to insert, update, or delete data. Use with caution, ensure the operation is intended and safe. Relies on Hasura permissions configured for the provided Admin Secret or default role. Example: mutation { insert_users_one(object: {name: "Test"}) { id } }
    • Input: { mutation: string, variables?: object }
    • Security: Allows any mutation permitted by the Hasura role. Ensure appropriate Hasura permissions are configured.
  • list_tables

    • Description: Lists available data tables (or collections) managed by Hasura, organized by schema with descriptions, based on introspection heuristics (looks for object types with an ‘id’ field, excluding internal/aggregate types). Useful for discovering available data sources.
    • Input: { schemaName?: string } (Optional schema name, attempts to infer from field descriptions if possible, defaults to ‘public’ conceptually)
  • describe_table

    • Description: Shows the structure of a specific table including all its columns (fields) with their GraphQL types and descriptions.
    • Input: { tableName: string, schemaName?: string }
  • list_root_fields

    • Description: Lists the available top-level query, mutation, or subscription fields from the GraphQL schema. Useful for understanding the primary entry points for operations.
    • Input: { fieldType?: 'QUERY' | 'MUTATION' | 'SUBSCRIPTION' } (Optional filter)
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { // ... other servers ... "hasura-advanced": { // Key used internally by Claude "command": "/path/to/your/node", // <<< Absolute path from 'which node' "args": [ "/absolute/path/to/mcp-hasura-advanced/dist/index.js", // <<< Absolute path to compiled script "https://YOUR_HASURA_ENDPOINT.com/v1/graphql", // <<< Your endpoint "YOUR_ADMIN_SECRET" // <<< Your secret (REMOVE if no secret) ], // Optional: // "cwd": "/absolute/path/to/mcp-hasura-advanced" } } }