mcp-postgresql
PostgreSQL 用 MCP サーバー
本番環境向けの PostgreSQL 用 MCP サーバーで、データベース操作を MCP クライアント(Claude Desktop、VS Code Copilot、Cursor、および互換性のあるホスト)に公開します。
機能
クエリ実行(
SELECT、INSERT、UPDATE、DELETE)データベースの検出とスキーマイントロスペクション
テーブルメタデータの検査(カラム、型、NULL許容性、デフォルト値、主キー)
インデックスと外部キーの検出
安全なデプロイのための環境駆動型設定
Related MCP server: Azure Database for PostgreSQL MCP Server
利用可能なツール
ツール | 説明 |
| SQL 文を実行し、行または影響を受けた行数を返します |
|
|
| テーブルのカラムメタデータと主キーマーカーを返します |
| すべての PostgreSQL データベースを一覧表示します |
| テーブルのインデックスを定義と主キー/一意フラグと共に一覧表示します |
| テーブルの外部キーと参照先を一覧表示します |
要件
Node.js 18+
PostgreSQL インスタンスへのアクセス
MCP ホストから PostgreSQL へのネットワーク接続(
host:port)
設定
環境変数を使用して接続設定を行います:
変数 | 必須 | デフォルト | 説明 |
| いいえ |
| PostgreSQL ホストまたは IP |
| いいえ |
| PostgreSQL TCP ポート |
| いいえ |
| デフォルトデータベース |
| はい | — | データベースユーザー |
| はい | — | データベースパスワード |
| いいえ |
| SSL/TLS を有効にします |
| いいえ |
| 最大プール接続数 |
| いいえ |
| プールアイドルタイムアウト (ミリ秒) |
| いいえ |
| トランスポートモード: |
| いいえ |
| HTTP サーバーのポート( |
| いいえ |
| HTTP サーバーのバインドアドレス( |
使い方
GitHub から直接実行
npx github:ferronicardoso/mcp-postgresqlClaude Code (CLI)
claude mcp add postgresql --scope user -- npx -y github:ferronicardoso/mcp-postgresql--scope はサーバー登録の保存場所を制御します:
スコープ | 保存場所 | 表示対象 |
| プロジェクトローカル、追跡対象外 | あなただけ、このプロジェクトのみ |
| プロジェクトルートの | リポジトリをクローンした全員(共有するためにコミットしてください) |
| あなたのグローバル Claude Code 設定 | あなた、すべてのプロジェクトで |
環境変数は -- の前に --env KEY=VALUE フラグを繰り返して渡すことができます。例:
Bash (Linux/macOS/WSL):
claude mcp add postgresql --scope user \
--env PGHOST=localhost \
--env PGPORT=5432 \
--env PGDATABASE=postgres \
--env PGUSER=postgres \
--env PGPASSWORD=your-password \
-- npx -y github:ferronicardoso/mcp-postgresqlPowerShell:
claude mcp add postgresql --scope user `
--env PGHOST=localhost `
--env PGPORT=5432 `
--env PGDATABASE=postgres `
--env PGUSER=postgres `
--env PGPASSWORD=your-password `
-- npx -y github:ferronicardoso/mcp-postgresqlCodex CLI
Bash (Linux/macOS/WSL):
codex mcp add postgresql \
--env PGHOST=localhost \
--env PGPORT=5432 \
--env PGDATABASE=postgres \
--env PGUSER=postgres \
--env PGPASSWORD=your-password \
npx -- -y github:ferronicardoso/mcp-postgresqlPowerShell:
codex mcp add postgresql `
--env PGHOST=localhost `
--env PGPORT=5432 `
--env PGDATABASE=postgres `
--env PGUSER=postgres `
--env PGPASSWORD=your-password `
npx -- -y github:ferronicardoso/mcp-postgresqlこれにより、サーバーが ~/.codex/config.toml に登録されます。削除するには、codex mcp remove postgresql を実行してください。
Claude Desktop 設定
%APPDATA%\\Claude\\claude_desktop_config.json:
{
"mcpServers": {
"postgresql": {
"command": "npx",
"args": ["github:ferronicardoso/mcp-postgresql"],
"env": {
"PGHOST": "localhost",
"PGPORT": "5432",
"PGDATABASE": "postgres",
"PGUSER": "postgres",
"PGPASSWORD": "your-password"
}
}
}
}VS Code MCP 設定
.vscode/mcp.json:
{
"servers": {
"postgresql": {
"command": "npx",
"args": ["github:ferronicardoso/mcp-postgresql"],
"env": {
"PGHOST": "localhost",
"PGPORT": "5432",
"PGDATABASE": "postgres",
"PGUSER": "postgres",
"PGPASSWORD": "your-password"
}
}
}
}Docker で実行 (HTTP トランスポート)
公開イメージはデフォルトで Streamable HTTP モードで実行され、リモート MCP エンドポイントとして使用されます(例:n8n の MCP クライアントツールノードや Streamable HTTP 互換クライアントから)。
Bash (Linux/macOS/WSL):
docker run -d --name mcp-postgresql \
-p 3002:3002 \
-e PGHOST=host.docker.internal \
-e PGPORT=5432 \
-e PGDATABASE=postgres \
-e PGUSER=postgres \
-e PGPASSWORD=your-password \
ghcr.io/ferronicardoso/mcp-postgresql:latestPowerShell:
docker run -d --name mcp-postgresql `
-p 3002:3002 `
-e PGHOST=host.docker.internal `
-e PGPORT=5432 `
-e PGDATABASE=postgres `
-e PGUSER=postgres `
-e PGPASSWORD=your-password `
ghcr.io/ferronicardoso/mcp-postgresql:latestMCP エンドポイントは http://localhost:3002/mcp で利用可能になります。
ローカル開発
git clone https://github.com/ferronicardoso/mcp-postgresql
cd mcp-postgresql
npm install
npm run buildコンパイル済みサーバーを起動:
npm startビルドとコミットのワークフロー
このリポジトリは、npx github:user/repo の使用をサポートするために、意図的に dist/ を追跡しています。
プロジェクトは Husky の pre-commit フックを使用して、次のことを行います:
TypeScript をビルドする(
npm run build)生成されたアーティファクトをステージングする(
git add dist)
手動でのフォールバック:
npm run build
git add distセキュリティに関する注意事項
実際の認証情報や
.envファイルをコミットしないでください。本番環境では、最小権限のデータベースユーザーを優先してください。
公共または信頼できないネットワークの場合は、暗号化を有効にし(
PGSSL=true)、証明書を適切に設定してください。
ライセンス
MIT © Raphael Augusto Ferroni Cardoso
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 gradedqualityCmaintenanceAn extensible MCP server for database operations that supports PostgreSQL for managing schemas, tables, data, and user permissions. It features automatic migration recording for DDL changes and integrates with various AI-powered editors like Cursor, Zed, and Claude Code.222MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) Server that allows AI models to securely interact with data hosted in Azure Database for PostgreSQL. It enables natural language querying, schema exploration, and data management through MCP clients like Claude Desktop and Visual Studio Code.MIT
- AlicenseNot gradedqualityCmaintenanceA production-ready MCP server for PostgreSQL — built for Claude Desktop, Claude Code, and any MCP-compatible AI agent.Apache 2.0
- AlicenseNot gradedqualityCmaintenanceA Model Context Protocol (MCP) server that provides secure database access to PostgreSQL through Kysely ORM, enabling Claude Desktop to interact with PostgreSQL databases using natural language.221ISC
Related MCP Connectors
MCP server for managing Prisma Postgres.
MCP server for interacting with the Supabase platform
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/ferronicardoso/mcp-postgresql'
If you have feedback or need assistance with the MCP directory API, please join our Discord server