Mcp Psycopg2

io.github.daedalusPublished by GitHub account daedalusv0.1.0Updated Oct 25, 2026

MCP server exposing psycopg2 PostgreSQL database adapter functionality

VerifiedSTDIODesktop onlyDatabasesDeveloper Tools

Overview

AI-generated overview

A local MCP server that exposes psycopg2 PostgreSQL adapter functionality, letting an assistant connect to and query PostgreSQL databases.

What you can do
Open, close, inspect and list database connections, and parse or build connection strings and DSN parameters via psycopg2-style tools. Manage transactions: begin, commit, rollback, set isolation level and session parameters. Create and close cursors, execute single or parameterized batch SQL, and fetch one, many or all rows. Quote identifiers, bind parameters, and register JSON, hstore and composite type adapters. Run COPY operations, server-side named cursors, large-object read/write, and cancel queries.
When to use it
Useful when an assistant needs direct, low-level access to a PostgreSQL database from the desktop: running ad-hoc SQL, inspecting schema or data, managing transactions, or moving data with COPY and large objects.
Requirements
Runs as a local process on the user's machine, installed from the PyPI package mcp-psycopg2 (Python). A reachable PostgreSQL server and valid connection details are needed; the manifest declares no environment variables, headers or authentication, so connection parameters are supplied through the tools.
Before you install
Tools can execute arbitrary SQL, write or delete data, commit transactions, run COPY to and from files, and write large objects; use a least-privilege database account and review statements before running. Connection strings and DSN parameters may contain credentials and are exposed through tools such as get_dsn_parameters and make_dsn.

Installation

In SourceWeft

  1. Open Mcp Psycopg2 in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

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/

Source: README.md at commit 768b769

Tools

0
SourceWeft has not started this package in its sandbox yet, so its tools are not known.

Version history

1
  1. v0.1.0LatestSep 16, 2026

Score

50% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts

    Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.

  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listed15 pts

    Answer tools/list without a credential, or ship a package that starts in a sandbox without one.

  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts