# postgresql-sharp MCP server

> Enables AI assistants to discover PostgreSQL databases, inspect schemas, execute SQL, and analyze query plans or database health.

- Repository: https://github.com/codegiveness/postgresql-sharp-mcp
- Page: https://hostedmcp.org/servers/codegiveness/postgresql-sharp-mcp
- Transport: stdio
- Stars: 1
- License: MIT

## Install

### Claude Code

```sh
claude mcp add postgresql-sharp-mcp -- npx -y @codegiveness/postgresql-sharp-mcp
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "postgresql-sharp-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@codegiveness/postgresql-sharp-mcp"
      ]
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "postgresql-sharp-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@codegiveness/postgresql-sharp-mcp"
      ]
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"postgresql-sharp-mcp","type":"stdio","command":"npx","args":["-y","@codegiveness/postgresql-sharp-mcp"]}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "postgresql-sharp-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@codegiveness/postgresql-sharp-mcp"
      ]
    }
  }
}
```

### Codex

```sh
codex mcp add postgresql-sharp-mcp -- npx -y @codegiveness/postgresql-sharp-mcp
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.postgresql-sharp-mcp]
command = "npx"
args = ["-y", "@codegiveness/postgresql-sharp-mcp"]
```

### Gemini CLI

```sh
gemini mcp add -s user postgresql-sharp-mcp npx -- -y @codegiveness/postgresql-sharp-mcp
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "postgresql-sharp-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@codegiveness/postgresql-sharp-mcp"
      ]
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `POSTGRES_ACCESS_MODE` | no | no |  |
| `POSTGRES_DATABASES` | no | no |  |
| `POSTGRES_DATABASE_LOCK_MODE` | no | no |  |
| `POSTGRES_REQUIRE_DATABASE_LOCK` | no | no |  |

## Tools (13)

- `macOS`
- `tls_unavailable`
- `list_databases`
- `list_schemas`
- `list_objects`
- `get_object_details`
- `execute_sql`
- `explain_query`
- `analyze_indexes`
- `get_top_queries`
- `analyze_db_health`
- `advisory`
- `pg_stat_statements`

## FAQ

### Is the SQL execution safe?

SQL calls are read-only by default, though the server's default access mode permits explicitly requested writes.

### How can I install it quickly?

The fastest way is using npx with Node.js 22+ and npm, which automatically installs the necessary .NET runtime.
