pgops-mcp
pgops-mcp
本番環境向けのMCPサーバー。AIエージェントに、実際のPostgreSQLデータベースとその周辺のDockerスタックに対する、安全で監査可能なエキスパートレベルの制御を提供します。シェルコマンドもPythonスクリプトも不要で、ツールだけです。
なぜ
既存のPostgres MCPサーバーは、単純なクエリラッパーです。スキーマの調査とSELECTのみ。ロック影響分析を伴うマイグレーションを処理するものはなく、EXPLAINとpg_stat_statementsからパフォーマンスを診断するものもなく、データベースが置かれているコンテナ化された環境を理解するものもありません。今日、データベースを操作するエージェントは、目が見えず安全でない状態で飛んでいます。
pgops-mcpは運用の頭脳です。スキーマインテリジェンス → ガード付きクエリ → マイグレーションエンジン → パフォーマンス診断 → 環境認識、そしてすべてのアクションを分類可能・確認可能・監査可能にする安全アーキテクチャを備えています。
Related MCP server: PostgreSQL MCP Server
ツールサーフェス (v0.1)
グループ | ツール |
スキーマ |
|
クエリ |
|
パフォーマンス |
|
マイグレーション |
|
環境 |
|
ゲート付き |
|
* サーバーが--approval-modeで実行されない限り、これらは一切登録されません。さらに、各呼び出しには確認トークンが必要です。container.execはさらに、読み取り専用の診断コマンドの許可リストを強制します。シェルは提供されません。Dockerソケットはホスト上でrootと同等の権限を持つため、デフォルトは読み取り専用アクセスです。
安全モデル (中核となる差別化要因)
読み取り専用/読み書き用の接続ロールを分離。ツールは適切なロールにバインド
実行前のステートメント分類 — 無制限の
DELETE/UPDATEはブロック破壊的なアクションには明示的な確認トークンが必要
実行されたすべてのステートメントは、タイミングと判定とともに追記専用の監査ログに記録
タイムアウト階層による暴走クエリのキャンセル
MCPサーフェス
プリミティブ | ここにあるもの |
ツール | 13 — スキーマ、クエリ、エクスプレイン、アドバイス、マイグレーション、環境 |
リソース |
|
プロンプト |
|
エリシテーション | 危険なアクションはエージェント経由ではなくユーザーに直接尋ねます。確認トークンはフォールバックです |
進捗 / ロギング | 長時間の操作中のベストエフォート通知 |
リモートアクセスとエージェントトークン
stdioは認証を必要としません。サーバーはクライアントが起動するサブプロセスであり、開かれたポートはありません。HTTPは認証が必要なため、キーなしでは起動を拒否します。
pgops-mcp keygen # RS256 keypair
pgops-mcp issue-token --subject my-agent # read-only by default
pgops-mcp issue-token --subject deploy-bot --scope pgops:read --scope pgops:write
pgops-mcp scopes # which scope each tool needs
pgops-mcp --transport http --public-key ~/.pgops/keys/pgops_public.pemサーバーは公開キーのみを保持するため、トークンを検証できますが、発行はできません。スコープ (pgops:read / pgops:write / pgops:admin) はガードレールと同じ危険度レベルに対応し、スコープエントリのないツールはadminを要求します — デフォルトで拒否。特に指定がない限り、ループバックにバインドします。
クイックスタート
uv sync
# point at your local Postgres in Docker:
export PGOPS_DSN="postgresql://user:pass@localhost:5432/mydb"
uv run pgops-mcp # stdio transport for Claude Desktop / Cursor / VS CodeClaude Desktopに追加:
{
"mcpServers": {
"pgops": {
"command": "uv",
"args": ["run", "--directory", "/path/to/pgops-mcp", "pgops-mcp"]
}
}
}ドキュメント
docs/PRD.md— 何と理由、目標、非目標docs/SPEC.md— ハードゲート付きの段階的技術仕様docs/ARCHITECTURE.md— システム設計 + トレードオフdocs/TOOLS.md— スキーマと例を含む完全なツールカタログdocs/adr/— アーキテクチャ決定記録docs/flow.md— 進行中の進捗ログdocs/interview_prep.md— 増え続けるインタビューQ&A
ステータス
フェーズ0〜6b完了 (319テスト、すべてのガードレール、判定、ロック影響ルールが、モックなしでtestcontainersを介した実際のPostgresに対して証明済み。さらに、サーバーを実際のMCPサブプロセスとしてstdio経由で、また認証付きHTTPサーバーとして駆動するエンドツーエンドスイートも含む)。
フェーズ | 状態 | ツール |
0 · ブートストラップ | ✅ | シード済み開発スタック (120万行の |
1 · 接続コア + 読み取りパス | ✅ |
|
2 · 書き込みパス + 安全性 | ✅ |
|
3 · パフォーマンス脳 | ✅ |
|
4 · マイグレーションエンジン | ✅ |
|
5 · Dockerレイヤー | ✅ |
|
6a · MCP完全性 | ✅ | リソース、プロンプト、エリシテーション、進捗 |
6b · リモート + 認証 | ✅ | HTTPトランスポート、JWT、スコープ付きエージェントトークン、キー生成CLI |
6c · パッケージング | 次 | PyPI、Smithery、MCPレジストリ |
migration.rollbackは意図的にまだ未実装です — docs/TOOLS.mdを参照してください。
120万行のordersに対する型変更でmigration.planが返すサンプル:
ALTER TABLE "orders" ALTER COLUMN "total_cents" TYPE bigint
op=table_rewrite risk=high estimate=4800ms confidence=medium
why: rewrites every row and rebuilds every index, holding AccessExclusiveLock
SAFER: add a new column of the target type, backfill in batches, sync with a
trigger, swap the names, then drop the old column開発データベースをクイックスタート (ホストポート5433、ローカルのPostgres (5432) との衝突を回避):
docker compose up -d
export PGOPS_DSN="postgresql://pgops:pgops_dev@localhost:5433/pgops_demo"
uv run pgops-mcp --selfcheckThis server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with PostgreSQL databases through schema intelligence, query execution, and DBA tooling including index analysis and health monitoring. Features configurable access levels and audit logging for secure database operations.539MIT
- FlicenseNot gradedqualityDmaintenanceExposes PostgreSQL database operations as tools for AI assistants, allowing SQL queries and schema inspection.
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with PostgreSQL databases through natural language queries, schema inspection, and safe SQL execution.91
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to safely interact with PostgreSQL databases, perform queries, inspect schemas, and analyze query performance.2
Related MCP Connectors
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Comprehensive PostgreSQL documentation and best practices, including ecosystem tools
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/arzharch/pgops-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server