CockroachDB MCP Server

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Used for package management when installing the MCP server dependencies.

CockroachDB MCP 服务器

该 MCP 服务器连接到 CockroachDB 实例,将数据库和表模式作为资源公开,将 SQL 查询作为工具运行,并提供查询分析的提示。

特征

资源

  • postgres://{host}/databases/{database} - 获取有关特定数据库的信息
  • postgres://{host}/databases/{database}/tables/{table}/schema - 获取特定表的架构
  • postgres://{host}/cluster-metadata/{resource} - 获取集群元数据(需要身份验证令牌)
    • 目前支持: nodes ——有关集群节点的信息

工具

  • query - 使用执行计划分析选项执行 SQL 查询

安装

  1. 克隆此存储库
  2. 安装依赖项:
    pnpm install
  3. 构建项目:
    npx tsc

**注意:**在本地使用 MCP 服务器之前,必须使用tsc构建项目。

配置

服务器需要数据库 URL 作为命令行参数,并可选择接受用于访问管理 UI 端点的身份验证令牌:

node dist/server.js postgres://user:password@host:port/database [auth_token]

访问集群元数据资源需要身份验证令牌。

与 Claude for Desktop 一起使用

  1. 打开您的 Claude for Desktop App 配置:
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. 添加您的服务器配置:
{ "mcpServers": { "cockroachdb": { "command": "node", "args": [ "/path/to/cockroachdb-mcp-server/dist/server.js", "postgres://user:password@host:port/database", "your_auth_token" ] } } }
  1. 重启 Claude 桌面版

与 Cline 一起使用

  1. 在“MCP 服务器”下的扩展设置中打开 Cline 配置文件。选择“配置 MCP 服务器”。
  2. 添加您的服务器配置:
{ "mcpServers": { "crdb": { "command": "node", "args": [ "/path/to/cockroachdb-mcp-server/dist/server.js", "postgres://root@127.0.0.1:26257/testdb", "your_auth_token" ] } } }
  1. 重新启动 Cline 或开始新的会话

示例查询

以下是您可以向 Claude 询问的一些示例问题:

  1. “我的 CockroachDB 实例中有哪些数据库可用?”
  2. “您能向我展示一下‘testdb’数据库中‘users’表的架构吗?”
  3. “在我的数据库上运行此查询:SELECT * FROM users LIMIT 10”
  4. “调试此查询并提出改进建议:SELECT * FROM orders WHERE customer_id = 123”
  5. “显示有关我的 CockroachDB 集群中所有节点的信息”

安全注意事项

  • 配置数据库访问时请务必小心。如果您只需要查询数据,请考虑使用只读用户进行连接。
  • 授权令牌用于访问 CockroachDB 管理界面 API。请务必妥善保管此令牌。

故障排除

  • 如果遇到连接问题,请验证您的数据库凭据并确保可以从您的机器访问 CockroachDB 实例。
  • 对于 SQL 错误,请检查服务器日志以获取详细的错误消息。
  • 如果 Claude 看不到服务器,请验证配置文件的格式是否正确以及 server.js 文件的路径是否正确。
  • 对于集群元数据资源,请确保您提供了有效的身份验证令牌,并且管理 UI 可以在端口 8080 上访问。
-
security - not tested
F
license - not found
-
quality - not tested

连接到 CockroachDB 实例并将数据库结构公开为资源,从而通过 Claude 的界面实现 SQL 查询执行和分析。

  1. Features
    1. Resources
    2. Tools
  2. Installation
    1. Configuration
      1. Using with Claude for Desktop
        1. Using with Cline
          1. Example Queries
            1. Security Considerations
              1. Troubleshooting
                ID: 69wju8loq2