@indiekitai/pg-dash 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -6
- package/README.zh-CN.md +85 -4
- package/dist/cli.js +894 -22
- package/dist/cli.js.map +1 -1
- package/dist/mcp.js +724 -19
- package/dist/mcp.js.map +1 -1
- package/dist/ui/assets/{index-RQDs_hnz.js → index-BuNkJbnD.js} +6 -6
- package/dist/ui/assets/index-Cpb430iS.css +1 -0
- package/dist/ui/index.html +2 -2
- package/package.json +1 -1
- package/dist/ui/assets/index-D5LMag3w.css +0 -1
package/README.md
CHANGED
|
@@ -94,7 +94,7 @@ The Dashboard is there when you need it. But the real power is in the CLI, MCP,
|
|
|
94
94
|
- Configure via `--slack-webhook` or `--discord-webhook`
|
|
95
95
|
|
|
96
96
|
### 🤖 MCP Server
|
|
97
|
-
-
|
|
97
|
+
- 14 tools for AI agent integration
|
|
98
98
|
- `pg-dash-mcp postgres://...` — works with Claude, Cursor, etc.
|
|
99
99
|
|
|
100
100
|
### 🖥️ CLI
|
|
@@ -148,7 +148,7 @@ Options:
|
|
|
148
148
|
--data-dir <dir> Data directory (default: ~/.pg-dash)
|
|
149
149
|
-i, --interval <sec> Collection interval (default: 30)
|
|
150
150
|
--threshold <score> Score threshold for check command (default: 70)
|
|
151
|
-
-f, --format <fmt> Output format: text|json (default: text)
|
|
151
|
+
-f, --format <fmt> Output format: text|json|md (default: text)
|
|
152
152
|
--query-stats-interval <min> Query stats snapshot interval in minutes (default: 5)
|
|
153
153
|
--slack-webhook <url> Slack webhook URL for alert notifications
|
|
154
154
|
--discord-webhook <url> Discord webhook URL for alert notifications
|
|
@@ -186,6 +186,59 @@ PG_DASH_CONNECTION_STRING=postgres://... pg-dash-mcp
|
|
|
186
186
|
| `pg_dash_export` | Export full health report (JSON or Markdown) |
|
|
187
187
|
| `pg_dash_diff` | Compare current health with last saved snapshot |
|
|
188
188
|
|
|
189
|
+
## MCP Setup
|
|
190
|
+
|
|
191
|
+
Connect pg-dash to Claude Desktop or Cursor for AI-assisted database management.
|
|
192
|
+
|
|
193
|
+
### Claude Desktop
|
|
194
|
+
|
|
195
|
+
Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"mcpServers": {
|
|
200
|
+
"pg-dash": {
|
|
201
|
+
"command": "npx",
|
|
202
|
+
"args": ["-y", "-p", "@indiekitai/pg-dash", "pg-dash-mcp", "postgresql://user:pass@host/db"]
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Cursor
|
|
209
|
+
|
|
210
|
+
Add to `.cursor/mcp.json` in your project:
|
|
211
|
+
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"mcpServers": {
|
|
215
|
+
"pg-dash": {
|
|
216
|
+
"command": "npx",
|
|
217
|
+
"args": ["-y", "-p", "@indiekitai/pg-dash", "pg-dash-mcp", "postgresql://user:pass@host/db"]
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Example Conversations
|
|
224
|
+
|
|
225
|
+
Once connected, you can ask your AI assistant:
|
|
226
|
+
|
|
227
|
+
**Diagnosis:**
|
|
228
|
+
- "What's wrong with my database right now?"
|
|
229
|
+
- "Why is my `users` table slow? Check for missing indexes."
|
|
230
|
+
- "Show me the top 5 slowest queries this week."
|
|
231
|
+
|
|
232
|
+
**Optimization:**
|
|
233
|
+
- "Generate SQL to fix all missing FK indexes in one go."
|
|
234
|
+
- "EXPLAIN this query for me: SELECT * FROM orders WHERE user_id = 123"
|
|
235
|
+
- "Which tables are taking up the most space?"
|
|
236
|
+
|
|
237
|
+
**Pre-migration check:**
|
|
238
|
+
- "Run a health check and tell me if it's safe to deploy."
|
|
239
|
+
- "What changed in the schema since last week?"
|
|
240
|
+
- "Check if there are any idle connections blocking my migration."
|
|
241
|
+
|
|
189
242
|
## CI Integration
|
|
190
243
|
|
|
191
244
|
### GitHub Actions
|
|
@@ -212,17 +265,45 @@ Sample workflow (`.github/workflows/pg-check.yml`):
|
|
|
212
265
|
name: Database Health Check
|
|
213
266
|
on:
|
|
214
267
|
push:
|
|
215
|
-
paths: ['migrations/**', 'prisma/**', 'drizzle/**']
|
|
268
|
+
paths: ['migrations/**', 'prisma/**', 'drizzle/**', 'supabase/migrations/**']
|
|
269
|
+
pull_request:
|
|
270
|
+
paths: ['migrations/**', 'prisma/**', 'drizzle/**', 'supabase/migrations/**']
|
|
216
271
|
schedule:
|
|
217
|
-
- cron: '0 8 * * 1' # Weekly Monday 8am
|
|
272
|
+
- cron: '0 8 * * 1' # Weekly Monday 8am UTC
|
|
218
273
|
jobs:
|
|
219
|
-
|
|
274
|
+
db-health:
|
|
220
275
|
runs-on: ubuntu-latest
|
|
221
276
|
steps:
|
|
222
277
|
- uses: actions/checkout@v4
|
|
223
|
-
|
|
278
|
+
# Cache snapshot across ephemeral runners for --diff to work
|
|
279
|
+
- name: Restore health snapshot
|
|
280
|
+
uses: actions/cache@v4
|
|
281
|
+
with:
|
|
282
|
+
path: .pg-dash-cache
|
|
283
|
+
key: pg-dash-snapshot-${{ github.ref }}
|
|
284
|
+
restore-keys: pg-dash-snapshot-
|
|
285
|
+
- name: Run pg-dash health check
|
|
286
|
+
id: pg-check
|
|
287
|
+
run: |
|
|
288
|
+
mkdir -p .pg-dash-cache
|
|
289
|
+
npx @indiekitai/pg-dash check ${{ secrets.DATABASE_URL }} \
|
|
290
|
+
--ci --diff --snapshot-path ./.pg-dash-cache/last-check.json \
|
|
291
|
+
--format md > pg-dash-report.md
|
|
292
|
+
echo "exit_code=$?" >> $GITHUB_OUTPUT
|
|
293
|
+
continue-on-error: true
|
|
294
|
+
- name: Save health snapshot
|
|
295
|
+
uses: actions/cache/save@v4
|
|
296
|
+
if: always()
|
|
297
|
+
with:
|
|
298
|
+
path: .pg-dash-cache
|
|
299
|
+
key: pg-dash-snapshot-${{ github.ref }}-${{ github.run_id }}
|
|
300
|
+
- name: Fail if unhealthy
|
|
301
|
+
if: steps.pg-check.outputs.exit_code != '0'
|
|
302
|
+
run: exit 1
|
|
224
303
|
```
|
|
225
304
|
|
|
305
|
+
See [`examples/github-actions-pg-check.yml`](examples/github-actions-pg-check.yml) for a full workflow with PR comments.
|
|
306
|
+
|
|
226
307
|
## Health Checks
|
|
227
308
|
|
|
228
309
|
pg-dash runs 46+ automated checks:
|
package/README.zh-CN.md
CHANGED
|
@@ -186,6 +186,59 @@ PG_DASH_CONNECTION_STRING=postgres://... pg-dash-mcp
|
|
|
186
186
|
| `pg_dash_export` | 导出完整健康报告(JSON 或 Markdown) |
|
|
187
187
|
| `pg_dash_diff` | 与上次快照对比当前健康状态 |
|
|
188
188
|
|
|
189
|
+
## MCP 配置
|
|
190
|
+
|
|
191
|
+
将 pg-dash 接入 Claude Desktop 或 Cursor,实现 AI 辅助的数据库管理。
|
|
192
|
+
|
|
193
|
+
### Claude Desktop
|
|
194
|
+
|
|
195
|
+
在 macOS 上编辑 `~/Library/Application Support/Claude/claude_desktop_config.json`,Windows 上编辑 `%APPDATA%\Claude\claude_desktop_config.json`:
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"mcpServers": {
|
|
200
|
+
"pg-dash": {
|
|
201
|
+
"command": "npx",
|
|
202
|
+
"args": ["-y", "-p", "@indiekitai/pg-dash", "pg-dash-mcp", "postgresql://user:pass@host/db"]
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Cursor
|
|
209
|
+
|
|
210
|
+
在项目的 `.cursor/mcp.json` 中添加:
|
|
211
|
+
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"mcpServers": {
|
|
215
|
+
"pg-dash": {
|
|
216
|
+
"command": "npx",
|
|
217
|
+
"args": ["-y", "-p", "@indiekitai/pg-dash", "pg-dash-mcp", "postgresql://user:pass@host/db"]
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### 示例对话
|
|
224
|
+
|
|
225
|
+
连接后,你可以直接问 AI 助手:
|
|
226
|
+
|
|
227
|
+
**诊断问题:**
|
|
228
|
+
- "我的数据库现在有什么问题?"
|
|
229
|
+
- "为什么我的 `users` 表这么慢?检查一下缺失的索引。"
|
|
230
|
+
- "显示本周最慢的 5 条查询。"
|
|
231
|
+
|
|
232
|
+
**性能优化:**
|
|
233
|
+
- "一次性生成 SQL,修复所有缺失的外键索引。"
|
|
234
|
+
- "帮我分析这条查询:SELECT * FROM orders WHERE user_id = 123"
|
|
235
|
+
- "哪些表占用空间最多?"
|
|
236
|
+
|
|
237
|
+
**迁移前检查:**
|
|
238
|
+
- "跑一次健康检查,告诉我现在部署安不安全。"
|
|
239
|
+
- "上周以来 schema 有哪些变化?"
|
|
240
|
+
- "检查是否有空闲连接会阻塞我的迁移。"
|
|
241
|
+
|
|
189
242
|
## CI 集成
|
|
190
243
|
|
|
191
244
|
### GitHub Actions
|
|
@@ -212,17 +265,45 @@ pg-dash check postgres://... --ci --diff --format md
|
|
|
212
265
|
name: Database Health Check
|
|
213
266
|
on:
|
|
214
267
|
push:
|
|
215
|
-
paths: ['migrations/**', 'prisma/**', 'drizzle/**']
|
|
268
|
+
paths: ['migrations/**', 'prisma/**', 'drizzle/**', 'supabase/migrations/**']
|
|
269
|
+
pull_request:
|
|
270
|
+
paths: ['migrations/**', 'prisma/**', 'drizzle/**', 'supabase/migrations/**']
|
|
216
271
|
schedule:
|
|
217
|
-
- cron: '0 8 * * 1' #
|
|
272
|
+
- cron: '0 8 * * 1' # 每周一 UTC 早 8 点
|
|
218
273
|
jobs:
|
|
219
|
-
|
|
274
|
+
db-health:
|
|
220
275
|
runs-on: ubuntu-latest
|
|
221
276
|
steps:
|
|
222
277
|
- uses: actions/checkout@v4
|
|
223
|
-
|
|
278
|
+
# 缓存快照,解决 ephemeral runner 丢失 ~/.pg-dash 的问题
|
|
279
|
+
- name: Restore health snapshot
|
|
280
|
+
uses: actions/cache@v4
|
|
281
|
+
with:
|
|
282
|
+
path: .pg-dash-cache
|
|
283
|
+
key: pg-dash-snapshot-${{ github.ref }}
|
|
284
|
+
restore-keys: pg-dash-snapshot-
|
|
285
|
+
- name: Run pg-dash health check
|
|
286
|
+
id: pg-check
|
|
287
|
+
run: |
|
|
288
|
+
mkdir -p .pg-dash-cache
|
|
289
|
+
npx @indiekitai/pg-dash check ${{ secrets.DATABASE_URL }} \
|
|
290
|
+
--ci --diff --snapshot-path ./.pg-dash-cache/last-check.json \
|
|
291
|
+
--format md > pg-dash-report.md
|
|
292
|
+
echo "exit_code=$?" >> $GITHUB_OUTPUT
|
|
293
|
+
continue-on-error: true
|
|
294
|
+
- name: Save health snapshot
|
|
295
|
+
uses: actions/cache/save@v4
|
|
296
|
+
if: always()
|
|
297
|
+
with:
|
|
298
|
+
path: .pg-dash-cache
|
|
299
|
+
key: pg-dash-snapshot-${{ github.ref }}-${{ github.run_id }}
|
|
300
|
+
- name: Fail if unhealthy
|
|
301
|
+
if: steps.pg-check.outputs.exit_code != '0'
|
|
302
|
+
run: exit 1
|
|
224
303
|
```
|
|
225
304
|
|
|
305
|
+
完整工作流(包含 PR 评论)请参考 [`examples/github-actions-pg-check.yml`](examples/github-actions-pg-check.yml)。
|
|
306
|
+
|
|
226
307
|
## 健康检查
|
|
227
308
|
|
|
228
309
|
pg-dash 运行 46+ 项自动化检查:
|