CockroachDB MCP 服务器可连接到 CockroachDB 实例,将数据库和表架构作为资源公开,支持运行 SQL 查询,并能提供查询分析提示,助力用户高效管理和操作数据库。
此 MCP 服务器能连接到 CockroachDB 实例,公开数据库和表架构资源,运行 SQL 查询并提供分析提示。以下是使用前的准备步骤。
postgres://{host}/databases/{database}
- 可获取特定数据库的信息。postgres://{host}/databases/{database}/tables/{table}/schema
- 能够获取特定表的架构。postgres://{host}/cluster-metadata/{resource}
- 用于获取集群元数据(需要身份验证令牌),当前支持 nodes
,可获取集群节点信息。query
- 执行 SQL 查询,还带有执行计划分析选项。pnpm install
npx tsc
⚠️ 重要提示
在本地使用 MCP 服务器之前必须用
tsc
构建项目。
服务器需要一个数据库 URL 作为命令行参数,并可选接受身份验证令牌以访问管理界面端点:
node dist/server.js postgres://user:password@host:port/database [auth_token]
身份验证令牌用于访问集群元数据资源。
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"cockroachdb": {
"command": "node",
"args": [
"/path/to/cockroachdb-mcp-server/dist/server.js",
"postgres://user:password@host:port/database",
"your_auth_token"
]
}
}
}
{
"mcpServers": {
"crdb": {
"command": "node",
"args": [
"/path/to/cockroachdb-mcp-server/dist/server.js",
"postgres://root@127.0.0.1:26257/testdb",
"your_auth_token"
]
}
}
}
以下是你可以让 Claude 执行的一些示例查询: