注意:此仓库已弃用,开发已移至 https://github.com/nhost/nhost/tree/main/cli
一个用于与Nhost Cloud项目和服务交互的模型上下文协议(MCP)服务器实现。
MCP-Nhost旨在通过模型上下文协议提供统一的接口来管理Nhost项目。它能够无缝地与Nhost Cloud服务进行交互,提供了强大的工具集以进行项目管理和配置。
以下工具目前可通过MCP接口访问:
cloud-get-graphql-schema
cloud-graphql-query
local-get-graphql-schema
local-graphql-query
local-config-server-get-schema
local-config-server-query
local-get-management-graphql-schema
local-manage-graphql
project-get-graphql-schema
project-graphql-query
search
您可以在屏幕截图文件中找到当前特性和工具的屏幕截图和示例。
要安装mcp-nhost,您可以使用以下命令:
sudo curl -L https://raw.githubusercontent.com/nhost/mcp-nhost/main/get.sh | bash
安装mcp-nhost后,您需要对其进行配置。您可以通过在终端中运行命令mcp-nhost config来完成此操作。更多详情,请参阅CONFIG.md。
"mcpServers"内添加以下对象: "mcp-nhost": {
"command": "/usr/local/bin/mcp-nhost",
"args": [
"start",
],
}
如需了解如何使用CLI,请运行:
mcp-nhost --help
或者查看USAGE.md获取更多详情。
如果您在使用MCP服务器时遇到问题,可以尝试自己运行这些工具。例如:
# cloud-get-graphql-schema
echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"cloud-get-graphql-schema","arguments":{}},"id":1}' | mcp-nhost start
# cloud-graphql-query
echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"cloud-graphql-query","arguments":{"query":"{ apps { id subdomain name } }"}},"id":1}' | mcp-nhost start
# local-get-graphql-schema
echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"local-get-graphql-schema","arguments":{"role":"user"}},"id":1}' | mcp-nhost start
# local-graphql-query
echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"local-graphql-query","arguments":{"query":"{ users { id } }", "role":"admin"}},"id":1}' | mcp-nhost start
# local-config-server-get-schema
echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"local-config-server-get-schema","arguments":{}},"id":1}' | mcp-nhost start
# local-config-server-query
echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"local-config-server-query","arguments":{"query":"{ config(appID: \"00000000-0000-0000-0000-000000000000\", resolve: true) { postgres { version } } }"}},"id":1}' | mcp-nhost start
# local-get-management-graphql-schema
echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"local-get-management-graphql-schema","arguments":{}},"id":1}' | mcp-nhost start
# local-manage-graphql
echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"local-manage-graphql","arguments":{"body":"{\"type\":\"export_metadata\",\"args\":{}}","endpoint":"https://local.hasura.local.nhost.run/v1/metadata"}},"id":1}' | mcp-nhost start
# project-get-graphql-schema - 将projectSubdomain替换为您自己的项目
echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"project-get-graphql-schema","arguments":{"projectSubdomain":"replaceMe", "role": "user"}},"id":1}' | mcp-nhost start
# project-graphql-query - 将projectSubdomain替换为您自己的项目
echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"project-graphql-query","arguments":{"projectSubdomain":"replaceMe","query":"{ users { id } }", "role":"admin"}},"id":1}' | mcp-nhost start
# search
echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"search","arguments":{"query":"how to enable magic links"}},"id":1}' | mcp-nhost start
如果您有任何建议或功能请求,请随时打开一个议题进行讨论。
MCP服务器设计的核心是安全,提供了超出现有GraphQL权限的额外保护层。关键的安全特性包括:
MCP服务器的一个关键安全优势是可以精确指定哪些操作可以通过,即使对于已认证的用户也是如此:
[[projects]]
subdomain = "my-blog"
region = "eu-central-1"
pat = "nhp_project_specific_pat"
allow_queries = ["getBlogs", "getCommends"]
allow_mutations = ["insertBlog", "insertComment"]
以上配置中,LLM将只能代表用户执行上述查询和变异操作,即使该用户在Nhost项目中有更广泛的权限。
我们欢迎对mcp-nhost的贡献!如果您有建议、错误报告或功能请求,请打开一个议题或提交拉取请求。