Skip to main content
Glama
aeiyannn

PostgreSQL MCP Server

by aeiyannn

PostgreSQL MCPサーバー

ローカルのPostgreSQLデータベースに接続し、AIアシスタントがデータベースをクエリおよび管理できるようにするMCP(Model Context Protocol)サーバーです。

提供されるツール

ツール

説明

query

読み取り専用SQL(SELECT, SHOW, EXPLAIN)を実行

execute

書き込みSQL(INSERT, UPDATE, DELETE, CREATE, ALTER, DROP)を実行

list_tables

スキーマ内のすべてのテーブルを一覧表示

describe_table

テーブルの列、型、キー、インデックスを表示

list_schemas

データベース内のすべてのユーザースキーマを一覧表示

Related MCP server: PostgreSQL MCP Server

リソース

  • schema-overview (postgres://schema/overview) — Markdown形式のデータベーススキーマ概要

ヘッダーによる動的接続

このサーバーは動的なPostgreSQL接続をサポートしています。初期SSE接続リクエストのHTTPヘッダーを介してデータベース認証情報を提供できます。これにより、デプロイされた単一のサーバーインスタンスで複数の異なるデータベースを扱うことが可能になります。

サポートされているヘッダー

ヘッダー

説明

デフォルト

x-pg-host

PostgreSQLホスト

PG_HOST または localhost

x-pg-port

PostgreSQLポート

PG_PORT または 5432

x-pg-user

PostgreSQLユーザー

PG_USER または postgres

x-pg-password

PostgreSQLパスワード

PG_PASSWORD または postgres

x-pg-database

PostgreSQLデータベース

PG_DATABASE または postgres

x-pg-ssl

SSLの使用 (true/false)

PG_SSL または false

x-pg-ca-cert

CA証明書

PG_CA_CERT


Antigravity / Cursor (VS Code) での設定

このサーバーを Antigravity または Cursor で使用するには、mcp_config.json(通常は %APPDATA%\antigravity\ またはIDEのMCP設定内にあります)に以下を追加してください:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://postgree-mcp-dfadduf9bsdvdwa9.eastasia-01.azurewebsites.net/sse",
        "--header", "x-pg-host: pg-168600c0-aeiyankhan2-d42e.g.aivencloud.com",
        "--header", "x-pg-port: 26768",
        "--header", "x-pg-user: avnadmin",
        "--header", "x-pg-password: YOUR_PASSWORD",
        "--header", "x-pg-database: defaultdb",
        "--header", "x-pg-ssl: true"
      ]
    }
  }
}

Claude Code CLI での設定

Claude Code CLI を使用している場合は、以下のコマンドを使用してこのサーバーを追加できます:

1. Claude Codeのインストール(未インストールの場合)

npm install -g @anthropic-ai/claude-code

2. PostgreSQL MCPサーバーの追加

ターミナルで以下のコマンドを実行してください:

claude mcp add postgres -- npx mcp-remote https://postgree-mcp-dfadduf9bsdvdwa9.eastasia-01.azurewebsites.net/sse \
  --header "x-pg-host: pg-168600c0-aeiyankhan2-d42e.g.aivencloud.com" \
  --header "x-pg-port: 26768" \
  --header "x-pg-user: avnadmin" \
  --header "x-pg-password: YOUR_PASSWORD" \
  --header "x-pg-database: defaultdb" \
  --header "x-pg-ssl: true"

Claude Desktop での設定

claude_desktop_config.json に以下を追加してください:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://postgree-mcp-dfadduf9bsdvdwa9.eastasia-01.azurewebsites.net/sse",
        "--header", "x-pg-host: pg-168600c0-aeiyankhan2-d42e.g.aivencloud.com",
        "--header", "x-pg-port: 26768",
        "--header", "x-pg-user: avnadmin",
        "--header", "x-pg-password: YOUR_PASSWORD",
        "--header", "x-pg-database: defaultdb",
        "--header", "x-pg-ssl: true"
      ]
    }
  }
}

ローカルセットアップ(開発用)

1. 依存関係のインストール

npm install

2. デフォルトデータベースの設定(オプション)

ローカル開発用に .env ファイルを引き続き使用できます:

PG_HOST=localhost
PG_PORT=5432
PG_USER=postgres
PG_PASSWORD=your_password_here
PG_DATABASE=your_database_name

3. ビルドと実行

npm run build
npm start

使用例

設定が完了すると、AIアシスタントに以下のような質問ができます:

  • "データベース内のすべてのテーブルをリストして"

  • "usersテーブルについて説明して"

  • "SELECT * FROM orders WHERE created_at > '2025-01-01'"

  • "productsという名前の新しいテーブルを作成して"

A
license - permissive license
Not graded
quality - not tested
D
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
    A
    quality
    D
    maintenance
    Enables Claude to interact with a local PostgreSQL database through SQL queries, schema inspection, and CRUD operations.
    8
    225
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to query and explore PostgreSQL databases with tools for executing SQL queries, listing tables, and describing table structures.
    MIT

View all related MCP servers

Related MCP Connectors

  • Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.

  • Comprehensive PostgreSQL documentation and best practices, including ecosystem tools

  • Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view det…

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/aeiyannn/postgree-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server