这是一个用TypeScript实现的Amazon Redshift模型上下文协议(MCP)服务器。它遵循Anthropic的实现模式,并为Cursor IDE和其他兼容MCP的客户端提供关于您的Redshift数据仓库的丰富上下文信息。此服务器使LLMs能够检查数据库模式并执行只读查询。
在您的项目目录中创建一个.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环境变量提供Redshift连接URL:
export DATABASE_URL="redshift://username:password@hostname:port/database?ssl=true"
npm start
或者您可以直接运行:
DATABASE_URL="redshift://username:password@hostname:port/database?ssl=true" node dist/index.js
对于开发,您可以使用:
DATABASE_URL="redshift://username:password@hostname:port/database?ssl=true" npm run dev
redshift://username:password@hostname:port/database?ssl=true
额外的连接参数:
ssl=true: 建立安全连接所需(推荐)timeout=10: 连接超时时间(秒)keepalives=1: 启用TCP保活keepalives_idle=130: TCP保活空闲时间src/index.ts: 主要的TypeScript实现dist/: 编译后的JavaScript输出package.json: 项目依赖项和脚本tsconfig.json: TypeScript配置query
describe_table
find_column
服务器提供Cursor可以使用的模式信息:
模式列表 (redshift://<host>/schema/<schema_name>)
表模式 (redshift://<host>/<schema>/<table>/schema)
样本数据 (redshift://<host>/<schema>/<table>/sample)
统计信息 (redshift://<host>/<schema>/<table>/statistics)
此服务器:
一旦连接,您可以向Cursor询问以下一些问题:
您可以通过以下方式扩展此服务器:
ListResourcesRequestSchema和ReadResourceRequestSchema处理器中添加新的资源类型ListToolsRequestSchema和CallToolRequestSchema处理器中添加新的工具对于开发,您可以使用npm run dev命令,该命令使用ts-node直接运行TypeScript代码而无需预编译。
MIT