Skip to main content
Glama

PostgreSQL MCP Server

by hthuong09
MIT License
28
  • Linux
  • Apple

MCP PostgreSQLサーバー

これは、PostgreSQLデータベースとやり取りするためのモデルコンテキストプロトコル(CMP)サーバーです。PostgreSQLデータベースへのクエリとスキーマの検査を行うための読み取り専用インターフェースを提供します。

インストール

npm install -g @hthuong09/postgres-mcp

構成

サーバーは複数の方法で構成できます。優先順位は次のとおりです。

  1. 環境変数
    • POSTGRES_URL : 完全なデータベース URL (例: postgres://user:pass@host:5432/dbname )
    • 個別の接続パラメータ:
      • POSTGRES_HOST : データベースホスト
      • POSTGRES_PORT : データベースポート(デフォルト: 5432)
      • POSTGRES_DB : データベース名
      • POSTGRES_USER : データベースユーザー
      • POSTGRES_PASSWORD : データベースパスワード
      • POSTGRES_SSL : SSL モードを有効にする (有効にするには 'true' に設定)
      • POSTGRES_SCHEMA : データベーススキーマ(デフォルト: 'public')
    • 追加構成:
      • DOTENV_PATH : .env ファイルへのカスタムパス
      • DEBUG_MCP : デバッグログを有効にする(有効にするには「true」に設定)
  2. コマンドライン
    npx @hthuong09/postgres-mcp "postgres://user:pass@host:5432/dbname"

リソース

  • テーブルスキーマ: データベース内の各テーブルはリソースとして公開されます
  • リソース URI 形式: postgres://user@host/dbname/table_name/schema
  • レスポンス形式: 列定義のJSON配列(名前とデータ型)

使用例

  1. 環境変数の使用:
    export POSTGRES_HOST=localhost export POSTGRES_DB=mydb export POSTGRES_USER=myuser export POSTGRES_PASSWORD=mypassword npx @hthuong09/postgres-mcp
  2. 接続 URL の使用:
    npx @hthuong09/postgres-mcp "postgres://myuser:mypassword@localhost:5432/mydb"
  3. SSL で環境変数を使用する:
    export POSTGRES_HOST=db.example.com export POSTGRES_DB=mydb export POSTGRES_USER=myuser export POSTGRES_PASSWORD=mypassword export POSTGRES_SSL=true npx @hthuong09/postgres-mcp
  4. カスタム .env ファイルの場所を使用する:
    DOTENV_PATH=/path/to/.env npx @hthuong09/postgres-mcp

セキュリティに関する考慮事項

  • データベースの資格情報は安全に保管する必要がある
  • プロセスリストで資格情報が公開されないように、本番環境ではコマンドライン引数の代わりに環境変数または .env ファイルを使用します。
  • 実稼働環境ではSSLの使用を検討する
  • サーバーは安全のため読み取り専用トランザクションのみを許可します
  • パスワードはリソースURIから自動的に削除されます

発達

ローカルでサーバーを構築するには:

npm install npm run build

開発中にウォッチモードで実行するには:

npm run watch

デバッグ

デバッグログを有効にするには、 DEBUG_MCP=trueを設定します。ログは次の場所に書き込まれます。

  • Unix/macOS: /tmp/postgres-mcp-debug.json
  • Windows: %TEMP%/postgres-mcp-debug.json

ライセンス

マサチューセッツ工科大学

-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

PostgreSQL データベースと対話してテーブルを一覧表示したり、スキーマを取得したり、読み取り専用 SQL クエリを実行したりできるようにするモデル コンテキスト プロトコル サーバー。

  1. インストール
    1. 構成
      1. リソース
    2. 使用例
      1. セキュリティに関する考慮事項
        1. 発達
          1. デバッグ
            1. ライセンス

              Related MCP Servers

              • -
                security
                F
                license
                -
                quality
                A Model Context Protocol server providing both read and write access to PostgreSQL databases, enabling LLMs to query data, modify records, and manage database schemas.
                Last updated -
                86
                7
                JavaScript
              • A
                security
                A
                license
                A
                quality
                A Model Context Protocol server that enables powerful PostgreSQL database management capabilities including analysis, schema management, data migration, and monitoring through natural language interactions.
                Last updated -
                18
                498
                94
                TypeScript
                AGPL 3.0
                • Linux
                • Apple
              • A
                security
                A
                license
                A
                quality
                A Model Context Protocol server that enables interaction with PostgreSQL databases for analyzing setups, debugging issues, managing schemas, migrating data, and monitoring performance.
                Last updated -
                1
                0
                TypeScript
                MIT License
              • -
                security
                F
                license
                -
                quality
                A Model Context Protocol server implementation that provides a simple interface to interact with PostgreSQL databases, enabling SQL queries, database operations, and schema management through MCP.
                Last updated -
                Python

              View all related MCP servers

              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/hthuong09/postgres-mcp'

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