这是一个用 TypeScript 实现的、用于 Amazon Redshift 的 Model Context Protocol (MCP) 服务器。它遵循 Anthropic 的实现模式,能为 Cursor IDE 及其他 MCP 兼容客户端提供关于您 Redshift 数据仓库的丰富上下文信息,让 LLM 可以检查数据库架构并执行只读查询。
在项目目录中创建一个 .cursor/mcp.json
文件,内容如下:
{
"mcpServers": {
"redshift-mcp": {
"command": "node",
"args": ["path/to/dist/index.js"],
"env": {
"DATABASE_URL": "redshift://username:password@hostname:port/database?ssl=true"
}
}
}
}
若要在所有项目中使用,可在主目录创建 ~/.cursor/mcp.json
文件,配置与上述相同。
mcp.json
中配置了该服务器,系统会自动检测。使用 stdio 传输配置服务器,配置如下:
{
"servers": [
{
"name": "redshift-mcp",
"transport": {
"kind": "stdio",
"command": ["node", "path/to/dist/index.js"]
}
}
]
}
npm install
npm run build
服务器需要通过 DATABASE_URL
环境变量提供相关信息,启动命令如下:
DATABASE_URL=redshift://username:password@hostname:port/database?ssl=true npm start
其中:
username
:Redshift 用户名password
:Redshift 密码hostname
:Redshift 服务器地址port
:端口(默认为 5432)database
:要连接的数据库名称启动服务器示例:
DATABASE_URL=redshift://myuser:mypassword@redshift-cluster-1.c1234567890.us-east-1.redshift.amazonaws.com:5432/mydb?ssl=true npm start
启动后,可在 http://localhost:4000
访问 API 文档。
在开发时,可使用 npm run dev
命令,该命令使用 ts - node 直接运行 TypeScript 代码,无需预编译。
有关 MCP 协议的更多信息,请参考 MCP Protocol Documentation。