شعار Postgres MCP Server

Postgres MCP Server

مؤسسة
microsoft

Connect your coding agent to PostgreSQL. postgres-mcp lets you generate

الناشرmicrosoft
المستودعpostgres-mcp
التفريعات
1
النجوم
26
الأدوات المتاحة
13
نوع نقل البياناتstdio
الفئات
الترخيصMIT
الروابط
  • اربط الأدوات بسير عمل الذكاء الاصطناعي

    يتيح Postgres MCP Server إمكانات MCP التي يمكن لتطبيقات الذكاء الاصطناعي العميلة ووكلاء الذكاء الاصطناعي المتوافقة استخدامها.

  • الأدوات المتاحة: 13

    تصفّح الإجراءات القابلة للاستدعاء أدناه، بما في ذلك أسماؤها وأوصافها عندما يوفّرها الخادم.

  • إعدادات جاهزة للنسخ

    استخدم أمثلة إعداد التثبيت لتهيئة هذا الخادم في تطبيق MCP العميل المفضّل لديك.

  • مؤشرات الاهتمام بالمصدر المفتوح

    النجوم: 26، والنسخ المتفرعة: 1 في المستودع المرتبط.

Postgres MCP Server

Platforms: Claude | Copilot | Codex | Open Code Postgres: local | on-prem | azure | aws | gcp Release status: Preview

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:

sh
# 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, …):

jsonc
{
  "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

AreaTools
Connectionslist / add / remove profiles, connect, disconnect, list databases
Queryread‑only SQL (postgres_mcp_query), DDL/DML (postgres_mcp_modify)
Schemafetch CREATE scripts for tables, indexes, functions, sequences…
Datadescribe a CSV, bulk‑load a CSV via COPY
Diagnosticsprobe server capabilities, collect performance metric groups

See the usage guide for tools, configuration, authentication (including Microsoft Entra ID), TLS, and the security model.


Security in one minute

  • The server doesn't decide what's allowed — your database does. It just passes requests along to PostgreSQL and runs them as the database user in your connection profile. It can't tell the difference between a request you meant to make and one the AI invented or was tricked into making, so anything that database user can do, the AI can do. What actually protects you is the permissions you give that user, the approval prompts in your MCP client, and the model you choose to run. See Security model for who's responsible for what, plus a checklist for locking things down.
  • postgres_mcp_query is read‑only. Omitted profile access_mode permits write tools; set access_mode: ro and use a read-only database role unless writes are intentionally delegated.
  • Microsoft Entra ID (AAD) is selected automatically for Azure profiles without a stored keyring password. Store a profile password to use password authentication instead.
  • Local file reads (postgres_mcp_bulk_load_csv, postgres_mcp_describe_csv) are limited to the MCP server's startup working directory by default and paths allowed with allow-access-to-path <path>. A file allows only itself; a directory allows recursive access.
  • Secrets are scrubbed from error messages before they leave the process.

See more info about security model in the usage guide.


Requirements

  • Node.js 22+ (to run via npx).
  • Linux x64/arm64, macOS x64/arm64, or Windows x64. Windows ARM uses x64 emulation.
  • A reachable PostgreSQL database — local, Docker, on‑premises, Azure Database for PostgreSQL, Amazon RDS/Aurora, Google Cloud SQL/AlloyDB, or any wire‑compatible server.

Changelog

See CHANGELOG.md for release notes.

License

Licensed under the MIT License © Microsoft.

التثبيت

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

الأدوات المتاحة

  • pgsql_list_connection_profiles

    List all available PostgreSQL connection profiles. Returns a list of profiles with ID, name, host, port, and default database. Use the profile ID with pgsql_connect to establish a connection.

  • pgsql_connect

    Connect to a PostgreSQL database server using a profile ID and optional database name. The profile ID is retrieved from pgsql_list_connection_profiles. Returns a connection ID that is used to interact with the database with other pgsql tools. If a specific database is given and the connection fails, use $pgsql_list_databases against a connection to the default database to find the correct database name. The connection ID is a string formatted as 'pgsql/{profile_id}[/{database name}]', where if no database name is present it's the default database for the profile.

  • pgsql_disconnect

    Disconnect from a PostgreSQL database server using a connection ID.

  • pgsql_list_databases

    List all databases on the connected PostgreSQL server. Requires a connectionId from pgsql_connect. Returns a list of database names available on the server.

  • pgsql_db_context

    Get context about this database by fetching the CREATE scripts for a specific type of database object or all types. Use this tool to retrieve detailed context about the database objects (e.g. tables, indexes, functions, sequences, comments, ownership, default_privileges, fdw, or all) within a given schema or across all schemas. Note: Always call this tool first to fetch the most up-to-date database schema context before executing any queries or modifications. This tool is strictly read-only and prevents duplicate or conflicting operations by ensuring you know the current state.

  • pgsql_bulk_load_csv

    Bulk‐load CSV file via COPY into a PostgreSQL table. Supports column mapping, optional SQL transforms, truncate-before-insert, and PK-based upsert. Use this to bulk-load CSV data into an existing table. The path must live under an approved bulk-load path (the current working directory by default, or one approved via postgres-mcp allow-access-to-path <path> / PGSQL_MCP_ALLOWED_PATHS). A directory grants recursive access to descendants; a file grants access only to that exact canonical file. Example: pgsql_bulk_load_csv( connectionId='tools://server/mydb', path='/path/to/file.csv', table='mytable', mapping={'col1': 'col1', 'col2': 'col2'}, transforms={'col2': 'src.col2::int'}, mode='upsert' )

  • pgsql_describe_csv

    Describe the structure and contents of a CSV file. Returns a YAML description of the CSV file, including fields, types, and metadata. Useful for preparing to import CSV data into a database. The selected file path must be approved for CSV access (via postgres-mcp allow-access-to-path <path> or PGSQL_MCP_ALLOWED_PATHS). A directory grants recursive access to descendants; a file grants access only to that exact canonical file.

  • pgsql_get_server_capabilities

    CALL THIS FIRST before diagnosing performance issues. Discovers what diagnostic tools are available for the connected server. Returns PostgreSQL version, Azure detection status, and available diagnostic groups for pgsql_get_metrics_group. Each group includes its ID, description, and metric count. Shows why certain groups may be unavailable (missing extensions, version requirements, Azure-only features). Required step before using pgsql_get_metrics_group for troubleshooting.

  • pgsql_get_metrics_group

    Diagnose slow database and performance issues. USE THIS FIRST when users report slow queries, high CPU, or performance problems. Collects pre-correlated metrics by diagnostic group: core_health (CPU, memory, connections, storage), saturation (I/O pressure, disk, cache performance), throughput (transactions, tuples, workload volume), lock_contention (blocking sessions, deadlocks, lock waits). For Azure servers, includes Azure Monitor metrics automatically. Call pgsql_get_server_capabilities first to see available groups. Max 5 groups per request, max 7 days for historical data.

  • pgsql_query

    Run a formatted SQL query against a database. For performance diagnostics, prefer pgsql_get_metrics_group instead. Requires a connection_id from the return value of pgsql_connect. This query must not modify the database at all. Can include SELECT, SHOW, EXPLAIN etc. Do not include additional statements, e.g. SET search_path, in this query. It must only be a single, spacious, well formatted query with line breaks and tabs. The statement will be presented to the user, so focus on readability. Returns the results of the query. You MUST include a validation query to check the validity of EVERY literal value used in the SQL query. Do NOT skip this step. This tool is strictly read-only and executes a single statement only. Use EXPLAIN for performance or optimization analysis and include execution plan details. On error, return clear error messages to the user.

  • pgsql_modify

    Modify the database and/or schema by executing SQL statements including DDL (CREATE, ALTER, DROP) and DML (INSERT, UPDATE, DELETE). Useful when designing schemas or inserting data. It must only be a single, spacious, well formatted query with line breaks and tabs. The statement will be presented to the user, so focus on readability. Returns the results of the statement execution, if any. Note: Always fetch up-to-date database schema context using the pgsql_db_context tool before proposing or executing modifications to avoid duplicates or conflicts. Ensure explicit user confirmation. On error, return clear and descriptive error messages to the user. NOTE: Use this tool when working with PostgreSQL databases INSTEAD of asking the user to run the psql CLI tool, unless otherwise explicitly asked to.

  • pgsql_add_connection

    Add a new PostgreSQL connection profile. The profile will be stored in ~/.postgres-mcp/connections.yaml. IMPORTANT: This tool does NOT accept passwords for security reasons. After adding the connection, the user must run: postgres-mcp connection set-password <profile_name> to securely set the password via the OS keyring. For Docker/CI environments, use the PGSQL_MCP_CONNECTION_STRING environment variable instead. Optionally set 'access_mode' to 'ro' (read-only) to block write tools (pgsql_modify, pgsql_bulk_load_csv) against this profile. Defaults to 'rw' (read-write) when omitted.

  • pgsql_remove_connection

    Remove a PostgreSQL connection profile. This removes the profile from ~/.postgres-mcp/connections.yaml and deletes its password from the OS keyring. Use pgsql_list_connection_profiles to see available profiles.

استخدم MCP الخاص بـ Postgres MCP Server مع نماذج ذكاء اصطناعي متعددة

يربط TypingMind أدوات MCP على مستوى مساحة العمل، لذا بمجرد توصيل Postgres MCP Server، يمكنك استخدامه مع نماذج ذكاء اصطناعي مختلفة في TypingMind بدلًا من إعداده لكل نموذج على حدة. يعمل تكامل MCP هذا محليًا عبر موصل MCP الخاص بـ TypingMind على جهازك.

دليل الإعداد لاستخدام الموصل المحلي

استخدم هذا الخيار عندما يحتاج خادم MCP إلى الوصول إلى ملفات محلية أو تطبيقات أو موارد خاصة على جهاز الكمبيوتر لديك.

1

فتح إعدادات MCP

في TypingMind، انتقل إلى «الإعدادات»، ثم «الإعدادات المتقدمة»، ثم «بروتوكول سياق النموذج»، واختر «إعداد الموصل».

  1. افتح TypingMind في متصفحك.
  2. انقر على أيقونة الإعدادات.
  3. انتقل إلى الإعدادات المتقدمة.
  4. افتح قسم بروتوكول سياق النموذج.
  5. انقر على «إعداد الموصل» واختر «هذا الجهاز».
شاشة إعداد موصل MCP في TypingMind مع تحديد «هذا الجهاز»
2

تنفيذ أمر الموصل

اختر «هذا الجهاز»، وانسخ الأمر من TypingMind وشغّله في Terminal. أبقِ العملية قيد التشغيل أثناء استخدام MCP.

  1. انسخ أمر الإعداد الذي يعرضه TypingMind.
  2. افتح Terminal على macOS أو Windows Terminal على Windows.
  3. الصق الأمر ونفّذه.
  4. وافق على تثبيت الحزمة إذا طلب منك Terminal تأكيد المتابعة.
  5. أبقِ نافذة Terminal والعملية التي تعمل فيها قيد التشغيل أثناء استخدام أدوات MCP.
3

أضف Postgres MCP Server كخادم

عندما تظهر حالة الموصل «جاهز»، انقر على «تعديل الخوادم» والصق إعدادات خادم MCP.

  1. انتظر حتى تظهر حالة الموصل «جاهز».
  2. انقر على «تعديل الخوادم».
  3. الصق إعدادات خادم MCP الخاص بـ Postgres MCP Server.
  4. احفظ قائمة الخوادم.
  5. حدّث الحالة إذا أردت التأكد من أن الموصل لا يزال جاهزًا.
إعدادات MCP في TypingMind تعرض خادمًا نشطًا وزر «تعديل الخوادم»
{
  "mcpServers": {
    "postgres-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@microsoft/postgres-mcp"
      ]
    }
  }
}
4

استخدام الاتصال مع نماذج مختلفة

احفظ قائمة الخوادم، وافتح «الإضافات»، وفعّل أدوات MCP الخاصة بـ Postgres MCP Server، ثم اختر أي نموذج ذكاء اصطناعي مدعوم في TypingMind واستخدم الأدوات في المحادثة أو أسندها إلى وكيل ذكاء اصطناعي.

  1. افتح صفحة الإضافات في TypingMind.
  2. فعّل أدوات MCP الخاصة بـ Postgres MCP Server.
  3. ابدأ محادثة واختر نموذج الذكاء الاصطناعي الذي تريد استخدامه.
  4. استخدم أدوات MCP في المحادثة أو عيّنها لوكيل ذكاء اصطناعي.
  5. انتقل إلى نموذج ذكاء اصطناعي آخر عند الحاجة دون إعادة الاتصال بـ MCP.
محادثة في TypingMind تستخدم أدوات MCP المفعّلة مع نموذج ذكاء اصطناعي محدّد
هل يمكنك استخدام Postgres MCP Server لمساعدتي في هذه المهمة؟
Postgres MCP Server
بالتأكيد. قرأته.
إليك ما وجدته باستخدام Postgres MCP Server.

الأسئلة الشائعة

ما استخدامات خادم MCP Postgres MCP Server؟

Postgres MCP Server هو خادم MCP يتيح لتطبيقات الذكاء الاصطناعي المتوافقة الاتصال بأدوات ومصادر سياق خارجية. في TypingMind، يمكنك إضافة خادم MCP هذا مرة واحدة وإتاحة أدواته في مساحة عملك للذكاء الاصطناعي.

هل يمكنني استخدام خادم MCP Postgres MCP Server مع نماذج ذكاء اصطناعي متعددة في TypingMind؟

نعم. يربط TypingMind أدوات MCP على مستوى مساحة العمل، لذا يمكنك استخدام Postgres MCP Server مع نماذج ذكاء اصطناعي مختلفة مثل Claude أو ChatGPT أو Gemini أو غيرها من النماذج التي أعددتها في TypingMind، دون إعداد خادم MCP لكل نموذج على حدة.

لماذا تستخدم موصل MCP Postgres MCP Server مع TypingMind؟

يُعد TypingMind من أفضل واجهات المحادثة مع النماذج اللغوية الكبيرة، إذ يجمع نماذج ذكاء اصطناعي متعددة ومطالبات وإضافات ووكلاء ذكاء اصطناعي ومفاتيح API وأدوات MCP في مساحة عمل واحدة. بعد توصيل Postgres MCP Server، يمكنك استخدام أدوات MCP الخاصة به عبر نماذجك المفضلة مع الحفاظ على سير عمل محادثاتك منظمًا في TypingMind.

كيف أوصّل خادم MCP Postgres MCP Server بـ TypingMind؟

يعمل Postgres MCP Server عبر موصل MCP المحلي في TypingMind. هذا هو الخيار الأنسب عندما يحتاج خادم MCP إلى الوصول إلى ملفات محلية أو تطبيقات سطح المكتب أو أدوات سطر الأوامر أو موارد خاصة على حاسوبك.

ما الأدوات التي يوفّرها خادم MCP Postgres MCP Server في TypingMind؟

يتيح Postgres MCP Server أدوات MCP بعدد 13، يمكنك تفعيلها من صفحة الإضافات في TypingMind واستخدامها في المحادثات أو تعيينها لوكلاء ذكاء اصطناعي.

هل أحتاج إلى مشاركة مفاتيح API الخاصة بي مع TypingMind لاستخدام خادم MCP Postgres MCP Server؟

لا. يعطي TypingMind الأولوية للعمل المحلي ويُبقي مزوّدي النماذج ومفاتيح API والمطالبات وإعدادات MCP تحت تحكمك. إذا كان Postgres MCP Server يتطلب مصادقة، فأضف الترويسات أو إعدادات OAuth أو الإعدادات المحلية المطلوبة لخادم MCP هذا عند إنشاء الاتصال.

خوادم MCP ذات صلة

عرض الكل

أنشئ مساحة عملك للذكاء الاصطناعي الآن

اشترك في نشرتنا البريدية لتصلك أخبار الميزات الجديدة والهدايا القادمة 👇