Mcp Psycopg2

io.github.daedalus由 GitHub 帳號 daedalus 發布v0.1.0更新於 Oct 25, 2026

MCP server exposing psycopg2 PostgreSQL database adapter functionality

已驗證STDIO僅桌面資料庫開發者工具

概覽

AI 產生的概覽

一個本機 MCP 伺服器,封裝 psycopg2 PostgreSQL 介面功能,讓助理連線並查詢 PostgreSQL 資料庫。

可以做什麼
透過 psycopg2 風格的工具建立、關閉、檢視與列出資料庫連線,並解析或建構連線字串與 DSN 參數。管理交易:開始、提交、回復、設定隔離層級與工作階段參數。建立與關閉游標,執行單筆或參數化批次 SQL,並取得一列、多列或全部結果。引用識別字、綁定參數,並註冊 JSON、hstore 與複合型別轉接器。執行 COPY 操作、伺服器端具名游標、大型物件讀寫以及取消查詢。
適用情境
適合助理需要在桌面端直接、底層地存取 PostgreSQL 資料庫的情境:執行臨時 SQL、檢視結構或資料、管理交易,或用 COPY 與大型物件搬移資料。
執行需求
以本機程序在使用者電腦上執行,從 PyPI 套件 mcp-psycopg2 安裝(Python)。需要可連線的 PostgreSQL 伺服器與有效連線資訊;清單未宣告環境變數、標頭或驗證,連線參數透過工具傳入。
安裝前請注意
工具可執行任意 SQL、寫入或刪除資料、提交交易、透過 COPY 讀寫檔案以及寫入大型物件;請使用最小權限的資料庫帳號並在執行前檢查語句。連線字串與 DSN 參數可能包含憑證,並會透過 get_dsn_parameters、make_dsn 等工具暴露。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Mcp Psycopg2,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

mcp-psycopg2

MCP server exposing psycopg2 PostgreSQL database adapter functionality.

[PyPI] [Python] [Ruff]

mcp-name: io.github.daedalus/mcp-psycopg2

Install

bash
pip install mcp-psycopg2

Usage

python
from mcp_psycopg2 import mcp
# Run the MCP servermcp.run()

MCP Tools

The server exposes the following tools for interacting with PostgreSQL databases:

Connection Management

  • connect - Create a new database connection
  • close_connection - Close an existing connection
  • get_connection_info - Get connection details

Transaction Management

  • begin_transaction - Start a new transaction
  • commit_transaction - Commit the current transaction
  • rollback_transaction - Rollback the current transaction
  • set_isolation_level - Set transaction isolation level

Cursor Operations

  • create_cursor - Create a new cursor
  • close_cursor - Close a cursor
  • execute_query - Execute a SQL query
  • execute_many - Execute a query with multiple parameter sets
  • fetch_one - Fetch one row
  • fetch_many - Fetch multiple rows
  • fetch_all - Fetch all remaining rows

SQL Composition

  • quote_identifier - Quote an SQL identifier
  • mogrify - Return query string after parameter binding

Type Registration

  • register_json - Register JSON type adapter
  • register_hstore - Register hstore type adapter
  • register_composite - Register composite type adapter

COPY Operations

  • copy_from - Copy data from file to table
  • copy_to - Copy data from table to file
  • copy_expert - Execute custom COPY statement

Server-Side Cursors

  • create_named_cursor - Create a server-side named cursor
  • scroll_cursor - Scroll through cursor results

Large Objects

  • create_large_object - Create or open a large object
  • read_large_object - Read from a large object
  • write_large_object - Write to a large object

Information

  • get_server_version - Get PostgreSQL server version
  • get_backend_pid - Get backend process ID
  • get_dsn_parameters - Get connection parameters
  • get_notices - Get database notices
  • parse_dsn - Parse a connection string
  • make_dsn - Create a connection string

Utility

  • cancel_query - Cancel the current database operation
  • set_session - Set session parameters
  • list_connections - List all active connections
  • list_cursors - List all active cursors

Development

bash
git clone https://github.com/daedalus/mcp-psycopg2.gitcd mcp-psycopg2pip install -e ".[test]"
# run testspytest
# formatruff format src/ tests/
# lintruff check src/ tests/
# type checkmypy src/

來源:README.md,提交 768b769

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分