這是一個基於 Model Context Protocol (MCP) 的 Amazon Redshift 資料庫探索工具,專為 AI 語言模型設計,提供結構化的資料庫探索功能。
- 引導式資料探索:遵循 Schema → Table → Column 的探索流程
- 穩健連線管理:採用每次使用時建立/切斷連線的模式確保最高穩定性
- MCP 標準協定:使用 FastMCP 框架實作,符合 MCP 協定標準
- 多種工具:提供 schema、table、column 列表查詢及 SQL 執行功能
pip install redshift-comment-mcpgit clone https://github.com/kouko/redshift-comment-mcp.git
cd redshift-comment-mcp
pip install -e ".[dev]"系統需求:本專案需要 Python 3.10 或更高版本。
redshift-comment-mcp --host your-cluster.region.redshift.amazonaws.com \
--port 5439 \
--user your_username \
--password your_password \
--dbname your_database您可以將密碼存放在環境變數中:
export REDSHIFT_PASSWORD=your_password
redshift-comment-mcp --host your-cluster.region.redshift.amazonaws.com \
--port 5439 \
--user your_username \
--dbname your_database在 MCP Client 的設定檔中加入以下設定:
{
"mcpServers": {
"redshift-comment-mcp": {
"command": "uvx",
"args": [
"redshift-comment-mcp@latest",
"--host", "your-cluster.region.redshift.amazonaws.com",
"--port", "5439",
"--user", "your_username",
"--password", "your_password",
"--dbname", "your_database"
]
}
}
}對於本地開發,需要使用 Python 的完整路徑,否則 MCP Client 可能會找不到 Python 執行檔。
# 如果使用 conda 環境
which python
# 例如輸出:/Users/username/opt/miniconda3/envs/redshift-comment-mcp/bin/python
# 如果使用 venv
# 例如:/path/to/project/.venv/bin/pythoncd /path/to/redshift-comment-mcp
pip install -e ".[dev]"在 ~/.claude.json(Claude Code)或 claude_desktop_config.json(Claude Desktop)中加入:
{
"mcpServers": {
"redshift-local": {
"command": "/Users/username/opt/miniconda3/envs/redshift-comment-mcp/bin/python",
"args": [
"-m", "redshift_comment_mcp.server",
"--host", "your-cluster.region.redshift.amazonaws.com",
"--port", "5439",
"--user", "your_username",
"--password", "your_password",
"--dbname", "your_database"
]
}
}
}
⚠️ 重要:command必須使用 Python 的完整絕對路徑(如/Users/username/opt/miniconda3/envs/xxx/bin/python),不能只寫python,否則會出現executable file not found in $PATH錯誤。
{
"mcpServers": {
"redshift-local": {
"command": "/Users/username/opt/miniconda3/envs/redshift-comment-mcp/bin/python",
"args": [
"-m", "redshift_comment_mcp.server",
"--host", "your-cluster.region.redshift.amazonaws.com",
"--port", "5439",
"--user", "your_username",
"--dbname", "your_database"
],
"env": {
"REDSHIFT_PASSWORD": "your_password"
}
}
}
}如果套件是用 editable 模式安裝(pip install -e .),更新原始碼後不需要重新安裝,只需要重啟 MCP Server(重啟 Claude Code / Claude Desktop)即可載入最新程式碼。
列出資料庫中所有可用的 schema 及其註解。這是探索流程的第一步。
列出指定 schema 中的所有資料表、視圖及其註解。
列出指定資料表的所有欄位、資料型態及其註解。
執行 SQL 查詢以獲取資料。僅支援 SELECT 查詢。
pytest tests/python -m build本專案使用 GitHub Actions 自動化發佈流程:
- 更新
pyproject.toml中的版本號 - 建立 GitHub Release
- GitHub Actions 自動執行測試、建置並發佈到 PyPI
詳細設定請參考 .github/DEPLOYMENT.md
python -m twine upload dist/*為了讓 AI 更好地理解您的資料庫結構,建議在資料庫中新增結構化的註解:
COMMENT ON SCHEMA sales IS '[用途] 儲存所有與線上零售相關的銷售數據。 [主要實體] 訂單, 客戶, 產品';COMMENT ON TABLE sales.orders IS '[實體] 訂單 [內容] 包含每一筆客戶訂單的詳細記錄。 [PK] order_id [FK] customer_id -> customers.customer_id';COMMENT ON COLUMN sales.orders.revenue IS '[定義] 該筆訂單的總銷售金額。 [語意類型] Metric [單位] 新台幣 [計算方式] 未稅商品總價 + 稅金 - 折扣。';MIT License
歡迎提交 Issue 和 Pull Request。