Skip to main content
Glama
ferronicardoso

mcp-postgresql

PostgreSQL 用 MCP サーバー

Docker Publish GHCR Node.js

本番環境向けの PostgreSQL 用 MCP サーバーで、データベース操作を MCP クライアント(Claude Desktop、VS Code Copilot、Cursor、および互換性のあるホスト)に公開します。

機能

  • クエリ実行(SELECTINSERTUPDATEDELETE

  • データベースの検出とスキーマイントロスペクション

  • テーブルメタデータの検査(カラム、型、NULL許容性、デフォルト値、主キー)

  • インデックスと外部キーの検出

  • 安全なデプロイのための環境駆動型設定

Related MCP server: Azure Database for PostgreSQL MCP Server

利用可能なツール

ツール

説明

execute_query

SQL 文を実行し、行または影響を受けた行数を返します

list_tables

INFORMATION_SCHEMA.TABLES からテーブルを一覧表示します(スキーマフィルタはオプション)

describe_table

テーブルのカラムメタデータと主キーマーカーを返します

list_databases

すべての PostgreSQL データベースを一覧表示します

get_table_indexes

テーブルのインデックスを定義と主キー/一意フラグと共に一覧表示します

get_foreign_keys

テーブルの外部キーと参照先を一覧表示します

要件

  • Node.js 18+

  • PostgreSQL インスタンスへのアクセス

  • MCP ホストから PostgreSQL へのネットワーク接続(host:port

設定

環境変数を使用して接続設定を行います:

変数

必須

デフォルト

説明

PGHOST (または POSTGRES_HOST)

いいえ

localhost

PostgreSQL ホストまたは IP

PGPORT (または POSTGRES_PORT)

いいえ

5432

PostgreSQL TCP ポート

PGDATABASE (または POSTGRES_DB)

いいえ

postgres

デフォルトデータベース

PGUSER (または POSTGRES_USER)

はい

データベースユーザー

PGPASSWORD (または POSTGRES_PASSWORD)

はい

データベースパスワード

PGSSL (または POSTGRES_SSL)

いいえ

false

SSL/TLS を有効にします

PGPOOL_MAX

いいえ

10

最大プール接続数

PGPOOL_IDLE_TIMEOUT_MS

いいえ

30000

プールアイドルタイムアウト (ミリ秒)

MCP_TRANSPORT

いいえ

stdio

トランスポートモード: stdio(デフォルト、npx/Claude Desktop/VS Code 用)または http(Streamable HTTP、Docker/リモートクライアント(n8n など)用)

MCP_HTTP_PORT

いいえ

3002

HTTP サーバーのポート(MCP_TRANSPORT=http の場合のみ使用)

MCP_HTTP_HOST

いいえ

0.0.0.0

HTTP サーバーのバインドアドレス(MCP_TRANSPORT=http の場合のみ使用)

使い方

GitHub から直接実行

npx github:ferronicardoso/mcp-postgresql

Claude Code (CLI)

claude mcp add postgresql --scope user -- npx -y github:ferronicardoso/mcp-postgresql

--scope はサーバー登録の保存場所を制御します:

スコープ

保存場所

表示対象

local (デフォルト)

プロジェクトローカル、追跡対象外

あなただけ、このプロジェクトのみ

project

プロジェクトルートの .mcp.json

リポジトリをクローンした全員(共有するためにコミットしてください)

user

あなたのグローバル 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-postgresql

PowerShell:

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-postgresql

Codex 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-postgresql

PowerShell:

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:latest

PowerShell:

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:latest

MCP エンドポイントは 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 フックを使用して、次のことを行います:

  1. TypeScript をビルドする(npm run build

  2. 生成されたアーティファクトをステージングする(git add dist

手動でのフォールバック:

npm run build
git add dist

セキュリティに関する注意事項

  • 実際の認証情報や .env ファイルをコミットしないでください。

  • 本番環境では、最小権限のデータベースユーザーを優先してください。

  • 公共または信頼できないネットワークの場合は、暗号化を有効にし(PGSSL=true)、証明書を適切に設定してください。

ライセンス

MIT © Raphael Augusto Ferroni Cardoso

Install Server
A
license - permissive license
A
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

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

  • A
    license
    Not graded
    quality
    C
    maintenance
    An 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.
    22
    2
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A 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
  • A
    license
    Not graded
    quality
    C
    maintenance
    A production-ready MCP server for PostgreSQL — built for Claude Desktop, Claude Code, and any MCP-compatible AI agent.
    Apache 2.0
  • A
    license
    Not graded
    quality
    C
    maintenance
    A 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.
    22
    1
    ISC

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

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