Skip to content
Back to search

pg-mcp-server

MCP Server for Postgres

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/ericzakariasson--pg-mcp-server/badge.svg)](/listings/ericzakariasson--pg-mcp-server)

HTML

<a href="/listings/ericzakariasson--pg-mcp-server"><img src="/api/listings/ericzakariasson--pg-mcp-server/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Add to your MCP client settings:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["--yes", "pg-mcp-server", "--transport", "stdio"],
      "env": {
        "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres"
      }
    }
  }
}

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 147 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # Postgres MCP Server
  2. A Model Context Protocol server for PostgreSQL databases. Enables LLMs to query and analyze PostgreSQL databases through a controlled interface.
  3. https://github.com/user-attachments/assets/6571c20c-91c9-4a6e-8332-13b587b79fbf
  4. ## Installation
  5. [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=postgres&config=eyJjb21tYW5kIjoibnB4IC0teWVzIHBnLW1jcC1zZXJ2ZXIgLS10cmFuc3BvcnQgc3RkaW8iLCJlbnYiOnsiREFUQUJBU0VfVVJMIjoicG9zdGdyZXNxbDovL3Bvc3RncmVzOnBvc3RncmVzQGxvY2FsaG9zdDo1NDMyL3Bvc3RncmVzIn19)
  6. Add to your MCP client settings:
  7. ```json
  8. {
  9. "mcpServers": {
  10. "postgres": {
  11. "command": "npx",
  12. "args": ["--yes", "pg-mcp-server", "--transport", "stdio"],
  13. "env": {
  14. "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres"
  15. }
  16. }
  17. }
  18. }
  19. ```
  20. ## Configuration
  21. - `DATABASE_URL` - PostgreSQL connection string (required)
  22. - `DANGEROUSLY_ALLOW_WRITE_OPS` - Enable writes (default: `false`)
  23. - `DEBUG` - Enable debug logging (default: `false`)
  24. - `PG_SSL_ROOT_CERT` - Optional path to a TLS CA bundle (e.g., AWS RDS global bundle)
  25. ## Usage
  26. ### Transports
  27. - Default transport is **stdio**. Switch to **HTTP** with the `--transport` flag.
  28. - HTTP mode serves the MCP Streamable HTTP endpoint at `/mcp` on `PORT` (default `3000`).
  29. - Clients that support Streamable HTTP should connect to `http://localhost:3000/mcp`.
  30. Start commands:
  31. ```bash
  32. # stdio transport (default, via installed CLI)
  33. pg-mcp-server --transport=stdio
  34. # http transport
  35. pg-mcp-server --transport=http
  36. ```
  37. ### Tools
  38. - **`query`** - Execute SQL queries
  39. ```json
  40. { "sql": "SELECT * FROM users WHERE active = true LIMIT 10" }
  41. ```
  42. ### Resources
  43. - **`postgres://tables`** - List all tables
  44. - **`postgres://table/{schema}/{table}`** - Get table schema and sample data
  45. ### Example Prompts
  46. Here's an example prompt to test if your MCP server is working:
  47. ```
  48. Show me the first 5 users from the database
  49. ```
  50. ## Data Analysis & Notebooks
  51. For data analysis and exploration, I've added a Cursor rule for using the MCP server together with notebooks in [`.cursor/rules/notebooks.mdc`](.cursor/rules/notebooks.mdc):
  52. ## Quick Start with Docker
  53. ```bash
  54. # Start PostgreSQL with sample data
  55. bun run db:start
  56. # Test with MCP Inspector
  57. bun run inspector
  58. # Stop PostgreSQL
  59. bun run db:stop
  60. ```
  61. Sample tables included: `users`, `products`, `orders`, `order_items`
  62. ## Development
  63. ```bash
  64. # Clone and install
  65. git clone https://github.com/ericzakariasson/pg-mcp-server.git
  66. cd pg-mcp-server
  67. bun install
  68. # Run (stdio transport)
  69. bun run index.ts -- --transport=stdio
  70. DEBUG=true bun run index.ts -- --transport=stdio
  71. # Run (http transport)
  72. bun run index.ts -- --transport=http
  73. DEBUG=true bun run index.ts -- --transport=http
  74. bun test # Run tests
  75. ```
  76. Use local build in MCP client settings:
  77. ```bash
  78. bun run build:js
  79. ```
  80. ```json
  81. {
  82. "mcpServers": {
  83. "postgres": {
  84. "command": "node",
  85. "args": ["/absolute/path/to/pg-mcp-server/lib/index.js", "--transport", "stdio"],
  86. "env": {
  87. "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres"
  88. }
  89. }
  90. }
  91. }
  92. ```
  93. ## Releases
  94. This repo auto-creates a GitHub Release when you push a tag that matches the version in `package.json`:
  95. 1. Update `CHANGELOG.md` and bump the version in `package.json`.
  96. 2. Commit the changes on `main` (or your release branch).
  97. 3. Create and push a matching tag:
  98. ```bash
  99. VERSION=$(jq -r .version package.json)
  100. git tag v"$VERSION"
  101. git push origin v"$VERSION"
  102. ```
  103. The GitHub Actions workflow will validate that the tag (e.g. `v0.1.0`) matches `package.json`, then use `gh` to create a release with generated notes, and publish to npm.
  104. ## License
  105. MIT - see [LICENSE](LICENSE)

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.