{"id":50836979,"url":"https://github.com/achmadya-dev/mcp-postgres-query","last_synced_at":"2026-06-14T04:05:13.672Z","repository":{"id":359257254,"uuid":"1245220558","full_name":"achmadya-dev/mcp-postgres-query","owner":"achmadya-dev","description":"Model Context Protocol (MCP) server for PostgreSQL to run SQL queries via stdio","archived":false,"fork":false,"pushed_at":"2026-06-14T02:45:55.000Z","size":172,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-14T03:07:28.935Z","etag":null,"topics":["cursor","database","mcp","model-context-protocol","postgres","postgresql","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/achmadya-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-21T02:55:42.000Z","updated_at":"2026-06-14T02:45:59.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/achmadya-dev/mcp-postgres-query","commit_stats":null,"previous_names":["achmadya-dev/mcp-postgres-typescript"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/achmadya-dev/mcp-postgres-query","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achmadya-dev%2Fmcp-postgres-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achmadya-dev%2Fmcp-postgres-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achmadya-dev%2Fmcp-postgres-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achmadya-dev%2Fmcp-postgres-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/achmadya-dev","download_url":"https://codeload.github.com/achmadya-dev/mcp-postgres-query/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achmadya-dev%2Fmcp-postgres-query/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34308668,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-14T02:00:07.365Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cursor","database","mcp","model-context-protocol","postgres","postgresql","typescript"],"created_at":"2026-06-14T04:05:08.387Z","updated_at":"2026-06-14T04:05:13.658Z","avatar_url":"https://github.com/achmadya-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @achmadya-dev/mcp-postgres-query\n\nMCP server for PostgreSQL. Runs a single SQL statement per tool call over **stdio**. **Read-only by default** — writes and DDL require explicit env flags.\n\n## Requirements\n\n- Node.js **≥ 20**\n- A reachable PostgreSQL server\n\n## Install from npm\n\n```json\n{\n  \"mcpServers\": {\n    \"postgres\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@achmadya-dev/mcp-postgres-query\"],\n      \"env\": {\n        \"POSTGRES_HOST\": \"localhost\",\n        \"POSTGRES_PORT\": \"5432\",\n        \"POSTGRES_USER\": \"your_user\",\n        \"POSTGRES_PASSWORD\": \"your_password\",\n        \"POSTGRES_DATABASE\": \"your_database\"\n      }\n    }\n  }\n}\n```\n\nOr use `envFile` instead of inline `env` (see [Cursor MCP docs](https://cursor.com/docs/mcp)).\n\n## Develop from source\n\n```bash\ngit clone https://github.com/achmadya-dev/mcp-postgres-query.git\ncd mcp-postgres-query\npnpm install\npnpm run build\npnpm test\n```\n\nOpen the repo root in Cursor. You need a reachable PostgreSQL instance — set connection env in `.cursor/mcp.json` or via `envFile`:\n\n```json\n{\n  \"mcpServers\": {\n    \"postgres\": {\n      \"command\": \"node\",\n      \"args\": [\"${workspaceFolder}/dist/index.js\"],\n      \"env\": {\n        \"POSTGRES_HOST\": \"localhost\",\n        \"POSTGRES_PORT\": \"5432\",\n        \"POSTGRES_USER\": \"your_user\",\n        \"POSTGRES_PASSWORD\": \"your_password\",\n        \"POSTGRES_DATABASE\": \"your_database\"\n      }\n    }\n  }\n}\n```\n\n## Environment variables\n\n### Connection\n\n| Variable            | Default      | Description                        |\n| ------------------- | ------------ | ---------------------------------- |\n| `POSTGRES_HOST`     | `localhost`  | PostgreSQL host                    |\n| `POSTGRES_PORT`     | `5432`       | Port                               |\n| `POSTGRES_USER`     | _(empty)_    | Username                           |\n| `POSTGRES_PASSWORD` | _(empty)_    | Password                           |\n| `POSTGRES_DATABASE` | _(optional)_ | Default database                   |\n| `POSTGRES_MAX_ROWS` | `500`        | Max rows for row-returning queries |\n\n### Write access\n\n| Variable                 | Allows   |\n| ------------------------ | -------- |\n| `ALLOW_INSERT_OPERATION` | `INSERT` |\n| `ALLOW_UPDATE_OPERATION` | `UPDATE` |\n| `ALLOW_DELETE_OPERATION` | `DELETE` |\n| `ALLOW_DDL_OPERATION`    | DDL      |\n\nEnabled values: `true`, `1`, `yes`, `on`.\n\n## Tools\n\n| Tool              | Statements                                     | Env flag                 |\n| ----------------- | ---------------------------------------------- | ------------------------ |\n| `postgres_select` | `SELECT`, `EXPLAIN`, `TABLE`, `VALUES`, `SHOW` | always on                |\n| `postgres_insert` | `INSERT`                                       | `ALLOW_INSERT_OPERATION` |\n| `postgres_update` | `UPDATE`                                       | `ALLOW_UPDATE_OPERATION` |\n| `postgres_delete` | `DELETE`                                       | `ALLOW_DELETE_OPERATION` |\n| `postgres_ddl`    | DDL                                            | `ALLOW_DDL_OPERATION`    |\n\n### Tool input\n\n| Parameter  | Required | Description                                 |\n| ---------- | -------- | ------------------------------------------- |\n| `sql`      | yes      | Single SQL statement                        |\n| `database` | no       | Overrides `POSTGRES_DATABASE` for this call |\n\nExample:\n\n```json\n{\n  \"sql\": \"SELECT datname FROM pg_database\",\n  \"database\": \"postgres\"\n}\n```\n\nUse `schema.table` in `sql` for other schemas in the same database.\n\n## Behavior and security\n\n- One statement per request.\n- Results are JSON text with `columns`, `rows`, `rowCount`, `truncated`, `maxRows` for row-returning queries.\n- Execute results return `kind: \"execute\"` with `affectedRows`.\n\n## Package scripts\n\n```bash\npnpm run build\npnpm test\npnpm start\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fachmadya-dev%2Fmcp-postgres-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fachmadya-dev%2Fmcp-postgres-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fachmadya-dev%2Fmcp-postgres-query/lists"}