Skip to main content
Glama

MCP PostgreSQL Server

MCP PostgreSQLサーバー

PostgreSQLデータベース操作を提供するモデルコンテキストプロトコルサーバー。このサーバーにより、AIモデルは標準化されたインターフェースを介してPostgreSQLデータベースと対話できるようになります。

インストール

手動インストール

npm install mcp-postgres-server

または、次のコマンドを直接実行します:

npx mcp-postgres-server

構成

サーバーには次の環境変数が必要です。

{ "mcpServers": { "postgres": { "type": "stdio", "command": "npx", "args": ["-y", "mcp-postgres-server"], "env": { "PG_HOST": "your_host", "PG_PORT": "5432", "PG_USER": "your_user", "PG_PASSWORD": "your_password", "PG_DATABASE": "your_database" } } } }

利用可能なツール

1. connect_db

提供された資格情報を使用して PostgreSQL データベースへの接続を確立します。

use_mcp_tool({ server_name: "postgres", tool_name: "connect_db", arguments: { host: "localhost", port: 5432, user: "your_user", password: "your_password", database: "your_database" } });

2. クエリ

オプションの準備済みステートメントパラメータを使用してSELECTクエリを実行します。PostgreSQLスタイル($1、$2)とMySQLスタイル(?)の両方のパラメータプレースホルダをサポートします。

use_mcp_tool({ server_name: "postgres", tool_name: "query", arguments: { sql: "SELECT * FROM users WHERE id = $1", params: [1] } });

3. 実行する

オプションの準備済みステートメントパラメータを使用して、INSERT、UPDATE、またはDELETEクエリを実行します。PostgreSQLスタイル($1、$2)とMySQLスタイル(?)の両方のパラメータプレースホルダをサポートします。

use_mcp_tool({ server_name: "postgres", tool_name: "execute", arguments: { sql: "INSERT INTO users (name, email) VALUES ($1, $2)", params: ["John Doe", "john@example.com"] } });

4. list_schemas

接続されたデータベース内のすべてのスキーマを一覧表示します。

use_mcp_tool({ server_name: "postgres", tool_name: "list_schemas", arguments: {} });

5. list_tables

接続されたデータベース内のテーブルを一覧表示します。オプションのスキーマパラメータを受け入れます(デフォルトは「public」)。

// List tables in the 'public' schema (default) use_mcp_tool({ server_name: "postgres", tool_name: "list_tables", arguments: {} }); // List tables in a specific schema use_mcp_tool({ server_name: "postgres", tool_name: "list_tables", arguments: { schema: "my_schema" } });

6. テーブルの説明

特定のテーブルの構造を取得します。オプションのスキーマパラメータ(デフォルトは「public」)を受け入れます。

// Describe a table in the 'public' schema (default) use_mcp_tool({ server_name: "postgres", tool_name: "describe_table", arguments: { table: "users" } }); // Describe a table in a specific schema use_mcp_tool({ server_name: "postgres", tool_name: "describe_table", arguments: { table: "users", schema: "my_schema" } });

特徴

  • 自動クリーンアップによる安全な接続処理
  • クエリパラメータの準備済みステートメントのサポート
  • PostgreSQLスタイル($1、$2)とMySQLスタイル(?)の両方のパラメータプレースホルダをサポート
  • 包括的なエラー処理と検証
  • TypeScriptサポート
  • 自動接続管理
  • PostgreSQL固有の構文と機能をサポート
  • データベース操作のマルチスキーマサポート

安全

  • SQLインジェクションを防ぐために準備されたステートメントを使用する
  • 環境変数による安全なパスワード処理をサポート
  • 実行前にクエリを検証します
  • 完了すると自動的に接続が閉じられます

エラー処理

サーバーは、一般的な問題に関する詳細なエラー メッセージを提供します。

  • 接続失敗
  • 無効なクエリ
  • パラメータが不足しています
  • データベースエラー

ライセンス

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

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

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.

AI モデルが標準化されたインターフェースを介して PostgreSQL データベースと対話できるようにし、クエリ、テーブル操作、スキーマ検査などの操作をサポートします。

  1. インストール
    1. 手動インストール
  2. 構成
    1. 利用可能なツール
      1. connect\_db
      2. クエリ
      3. 実行する
      4. list\_schemas
      5. list\_tables
      6. テーブルの説明
    2. 特徴
      1. 安全
        1. エラー処理
          1. ライセンス

            Related MCP Servers

            • A
              security
              A
              license
              A
              quality
              Allows AI assistants to list tables, read data, and execute SQL queries through a controlled interface, making database exploration and analysis safer and more structured.
              Last updated -
              1
              580
              Python
              MIT License
              • Linux
              • Apple
            • A
              security
              A
              license
              A
              quality
              This server enables AI models to interact with MySQL databases through a standardized interface.
              Last updated -
              5
              646
              61
              JavaScript
              MIT License
              • Linux
              • Apple
            • A
              security
              F
              license
              A
              quality
              Enables AI models to perform MySQL database operations through a standardized interface, supporting secure connections, query execution, and comprehensive schema management.
              Last updated -
              7
              35
              22
              JavaScript
            • -
              security
              F
              license
              -
              quality
              A server that allows AI models to interact with PostgreSQL databases through a standardized protocol, providing database schema information and SQL query execution capabilities.
              Last updated -
              JavaScript

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

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