# @codegiveness/postgresql-sharp-mcp [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/codegiveness/postgresql-sharp-mcp  
**GitHub Stars:** 1  
**npm Downloads (last month):** 879  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/codegiveness-postgresql-sharp-mcp

## Description
Database-agnostic PostgreSQL MCP server with live discovery and bounded per-call selection. Installs one platform package with the .NET runtime bundled; no .NET installation or runtime downloads required.

## Tools
Capabilities this server exposes over MCP:

- **list_databases** — target`, `limit`, `offset
- **list_schemas** — literal `prefix`, `include_system`, page
- **list_objects** — schema`, `type`, literal `search`, `include_system`, page
- **get_object_details** — schema`, `name`, `section`: columns/constraints/indexes/triggers/definition/parameters; `type`, `identity_arguments`, page
- **execute_sql** — sql`, `parameters` (values for `$1..$n`), `read_only`, page
- **explain_query** — sql`, `parameters`, `format`: summary/json, `analyze`, optional HypoPG `indexes
- **analyze_indexes** — schema`, `table`, page
- **get_top_queries** — order_by`: total_time/mean_time/calls/rows/reads, page
- **analyze_db_health** — section`: summary/vacuum/index/constraints/sequences/replication/blocking; `schema` where applicable, page

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "postgresql-sharp-mcp": {
    "command": "npx",
    "args": ["-y","--allow-scripts=@codegiveness/postgresql-sharp-mcp","@codegiveness/postgresql-sharp-mcp@0.7.1"],
    "env": {
      "POSTGRES_DATABASE_LOCK_MODE": ""
    }
  }
}
```

**Requires environment variables:** `POSTGRES_DATABASE_LOCK_MODE` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What @codegiveness/postgresql-sharp-mcp does

@codegiveness/postgresql-sharp-mcp exposes PostgreSQL administration and query-inspection functions as MCP tools. It is aimed at developers, DBAs, and data engineers who already have access to a PostgreSQL database and want an AI assistant or coding agent to inspect and work with it.

The server can enumerate accessible databases, browse schemas and objects, retrieve details for tables and other database objects, execute SQL, inspect query plans, review index usage, rank statements from query statistics, and examine database health. It connects to an existing PostgreSQL installation; it does not provision a database.

SQL calls use read-only behavior by default. The default access mode permits explicitly requested writes, so a least-privileged login and deliberate access restrictions are appropriate for shared or production data.

## How it works

An MCP client starts the application as a local stdio server. The server uses a PostgreSQL connection string supplied during client setup, then sends tool results back to the assistant. Results are bounded by rows and bytes rather than returned without limit. Larger responses can be continued with the returned `next_offset` value.

The discovery tools support targeted database, schema, and object selection. Object inspection can focus on columns, constraints, indexes, triggers, definitions, or parameters. SQL parameters map to PostgreSQL `$1` through `$n` placeholders. Query plans can be returned as a summary or JSON, with optional analysis and hypothetical indexes when HypoPG is available. Query ranking can use total time, mean time, call count, rows, or reads; health checks cover areas such as vacuum, indexes, constraints, sequences, replication, and blocking.

## Setup and configuration

The quickest installation uses Node.js 22 or newer and npm. Running the package with `npx` installs the platform-specific package and bundles the .NET runtime, so the resulting server does not require a separate .NET installation or runtime download. The installed native command also runs without Node.js after setup.

A global .NET tool installation is another option, but it requires the .NET 10 runtime and SDK. Standalone archives are available for Linux x64 and ARM64, macOS x64 and ARM64, and Windows x64; these archives include the runtime and do not require Node.js, npm, or the .NET SDK.

Register the resulting command with an MCP client and provide a connection string for an existing PostgreSQL database. The server supports Linux, macOS, and Windows. Use `--validate` to check configuration and receive advisory warnings. `POSTGRES_DATABASE_LOCK_MODE=strict` preserves strict database-lock behavior for installations that need it.

## Tools and capabilities

- `list_databases` enumerates accessible databases with bounded selection.
- `list_schemas` and `list_objects` browse schemas and database objects, including optional system-object filtering and search.
- `get_object_details` returns selected metadata sections such as columns, constraints, indexes, triggers, definitions, and parameters.
- `execute_sql` runs SQL with `$1`-style parameter values and a read-only control.
- `explain_query` returns summary or JSON plans, with optional analysis and HypoPG indexes.
- `analyze_indexes` examines indexes for a selected table.
- `get_top_queries` orders query statistics by time, calls, rows, or reads.
- `analyze_db_health` checks selected database-health areas, including vacuum, blocking, and replication.

_Full upstream README: https://allmcps.com/mcp/codegiveness-postgresql-sharp-mcp/readme_

