MP

microsoft/postgres-mcp

Developer tools公式

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

79 stars 3 forks 品質 85 トレンド 23MIT

postgres-mcpを使用すると、クエリを生成し、分析を実行したり、データベーススキーマを設計したり、サーバーとクエリのパフォーマンスを診断したり、接続を安全に管理したり、データをインポートしたりすることができます.

概要

postgres-mcpを使用すると、クエリを生成し、分析を実行したり、データベーススキーマを設計したり、サーバーとクエリのパフォーマンスを診断したり、接続を安全に管理したり、データをインポートしたりすることができます。 GitHub Copilot、Claude Code、Codex、Open Code、Cursor、VSコードなど、あらゆるMCPクライアントに対応しています。 - [https://www.npmjs.com/package/@microsoft/postgres-mcp - — npx から直接実行します。 名前付きプロファイルを一度作成します。パスワードはOSキーリングに保存され、設定ファイルでは保存されません。 接続によって作成されたプロファイルは、access mode: ro が設定されていない場合を除き、許可書き込みツールを追加します。 書くべきではない自発的な代理店のために、明示的な読み取り専用プロファイルを読み取り専用のデータベースロールを使用して、読み取り専用のプロファイルを参照してください。 サーバは stdio 上で MCP を話します。 npx @microsoft/postgres-mcp run でクライアントを指す - 認証情報はクライアントのコンフィグで行いません。 コーディングエージェントは、保存されたプロファイルをランタイムで発見し、接続します。 — mcpServers 形式 (~/.copilot/mcp-config.json, mcp.json, .cursor/mcp.

概要(AI 翻訳)

コーディングエージェントをPostgreSQLに接続します。 postgres-mcp] クエリと実行分析、データベーススキーマの設計、パフォーマンスの診断 サーバとクエリ、接続を安全に管理し、データをインポートします。 お問い合わせ MCP クライアントと互換性 — GitHub Copilot, Claude コード, Codex, Open コード, カーソル、VSコードなど。

クイックスタート

##1. 接続プロファイルを保存

名前付きプロファイルを一度作成します。パスワードはOSキーリングに保存されます。 設定ファイル:

[connection addによって作成されたプロファイルは、書き込みツールを許可します [access_mode: ro]をセットします。 書くべきではない自発的な代理店のために、使用して下さい 明示的な読み取り専用プロファイルと読み取り専用データベースロール — 参照 読み取り専用プロファイル。

##2. コーディングエージェントにpostgres-mcpを追加

サーバは stdio 上で MCP を話します。 クライアントをポイント [[npx @microsoft/postgres-mcp run] — クライアントのコンフィギュレーションでクレデンシャルが移動しません。 コーディングエージェントは、実行時に保存されたプロファイルを発見し、接続します.

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

Postgres MCP Server

Connect your coding agent to PostgreSQL. postgres-mcp lets you generate queries and run analytics, design database schemas, diagnose performance of the server and queries, securely manage connections, and import data. It is compatible with any MCP client — GitHub Copilot, Claude Code, Codex, Open Code, Cursor, VS Code, and more.

Quick start

1. Save a connection profile

Create a named profile once — the password is stored in your OS keyring, never in a config file:

# add a profile from a libpq URI or key=value string
npx -y @microsoft/postgres-mcp connection add local \
  "postgresql://postgres@localhost:5432/postgres"

# store its password securely (hidden prompt)
npx -y @microsoft/postgres-mcp connection set-password local

# check it
npx -y @microsoft/postgres-mcp connection list

Profiles created by connection add permit write tools unless access_mode: ro is set. For autonomous agents that should not write, use an explicit read-only profile and a read-only database role — see Read-only profiles.

2. Add postgres-mcp to your coding agent

The server speaks MCP over stdio. Point your client at npx @microsoft/postgres-mcp run — no credentials go in the client config; the coding agent discovers and connects to your saved profile at runtime.

GitHub Copilot CLI, Claude Code, Cursor & Claude Desktop — clients that use the mcpServers format (~/.copilot/mcp-config.json, mcp.json, .cursor/mcp.json, claude_desktop_config.json, …):

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["-y", "@microsoft/postgres-mcp", "run"]
    }
  }
}

Running headless or in CI, without a keyring? The server can also take a database connection string from the environment — see Connecting without a profile in the guide.

3. Ask your coding agent

“List the tables in my PostgreSQL database.” “Show me the 10 most recent orders from my PostgreSQL database.” “What’s slowing down my PostgreSQL server right now?”

The agent calls the server’s tools (postgres_mcp_connect, postgres_mcp_query, postgres_mcp_db_context, …) for you.


What it can do

Area Tools
Connections list / add / remove profiles, connect, disconnect, list databases
GitHub で README 全文を見る

インストール

npx -y @microsoft/postgres-mcp run
MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

{ "mcpServers": { "postgres": { "command": "npx", "args": ["-y", "@microsoft/postgres-mcp", "run"] } } }