{"_id":"@abiswas97/postgres-mcp","name":"@abiswas97/postgres-mcp","dist-tags":{"latest":"2.0.0"},"versions":{"2.0.0":{"name":"@abiswas97/postgres-mcp","version":"2.0.0","description":"PostgreSQL MCP server with diagnostics, slow query analysis, and connection monitoring","type":"module","main":"dist/index.js","bin":{"postgres-mcp":"dist/index.js"},"scripts":{"build":"tsc","start":"node dist/index.js","dev":"tsx src/index.ts","test":"jest","test:unit":"jest tests/unit","test:integration":"jest tests/integration","test:watch":"jest --watch","test:coverage":"jest --coverage","lint":"biome check src tests","lint:fix":"biome check --write src tests","format":"biome format --write src tests","typecheck":"tsc --noEmit","validate":"npm run lint && npm run typecheck","prepublishOnly":"npm run validate && npm run build && npm test","publish:public":"npm publish --access public","version:patch":"npm version patch","version:minor":"npm version minor","version:major":"npm version major"},"keywords":["mcp","model-context-protocol","kysely","database","postgresql","postgres","sql","orm","typescript"],"author":{"name":"Avi","email":"avishek.biswas.1997@gmail.com"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/abiswas97/postgres-mcp.git"},"homepage":"https://github.com/abiswas97/postgres-mcp#readme","bugs":{"url":"https://github.com/abiswas97/postgres-mcp/issues"},"dependencies":{"@modelcontextprotocol/sdk":"^0.6.0","dotenv":"^16.4.5","kysely":"^0.27.3","pg":"^8.11.5","zod":"^3.22.4","zod-to-json-schema":"^3.24.5"},"devDependencies":{"@biomejs/biome":"^2.4.6","@testcontainers/postgresql":"^10.13.1","@types/jest":"^29.5.12","@types/node":"^20.12.7","@types/pg":"^8.11.5","jest":"^29.7.0","ts-jest":"^29.1.2","tsx":"^4.7.2","typescript":"^5.4.5"},"_id":"@abiswas97/postgres-mcp@2.0.0","gitHead":"459d578feb003079298ab98c8c06905b0acfd66a","types":"./dist/index.d.ts","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-UU26bAMtBwIWfPq1sxfgM6xh/lm2sqzNGCof4xep/zzCHfBwy6C4mMVUkFM+aUaqZhT01jFrEem18A1Gw8TEcA==","shasum":"bb52cef5b7043c8d33860b13248f6f4e3b32859b","tarball":"https://registry.npmjs.org/@abiswas97/postgres-mcp/-/postgres-mcp-2.0.0.tgz","fileCount":59,"unpackedSize":159707,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCPXCaIo9XO8Ad3FsPL6uvJ068DailEugI0MQZp1XSBMgIgDq6qD4z+XTQGHzPoGu2yhFaxJhzf4SGKjVAEtF2YAsY="}]},"_npmUser":{"name":"abiswas97","email":"avishek.biswas.1997@gmail.com"},"directories":{},"maintainers":[{"name":"abiswas97","email":"avishek.biswas.1997@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/postgres-mcp_2.0.0_1773005745181_0.36565600700749745"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-08T21:35:45.026Z","2.0.0":"2026-03-08T21:35:45.333Z","modified":"2026-03-08T21:35:45.511Z"},"maintainers":[{"name":"abiswas97","email":"avishek.biswas.1997@gmail.com"}],"description":"PostgreSQL MCP server with diagnostics, slow query analysis, and connection monitoring","homepage":"https://github.com/abiswas97/postgres-mcp#readme","keywords":["mcp","model-context-protocol","kysely","database","postgresql","postgres","sql","orm","typescript"],"repository":{"type":"git","url":"git+https://github.com/abiswas97/postgres-mcp.git"},"author":{"name":"Avi","email":"avishek.biswas.1997@gmail.com"},"bugs":{"url":"https://github.com/abiswas97/postgres-mcp/issues"},"license":"ISC","readme":"# Postgres MCP Server\n\n[![npm version](https://badge.fury.io/js/postgres-mcp-server.svg)](https://www.npmjs.com/package/postgres-mcp-server)\n[![Tests](https://github.com/abiswas97/postgres-mcp-server/actions/workflows/test.yml/badge.svg)](https://github.com/abiswas97/postgres-mcp-server/actions/workflows/test.yml)\n[![GitHub issues](https://img.shields.io/github/issues/abiswas97/postgres-mcp-server)](https://github.com/abiswas97/postgres-mcp-server/issues)\n\nA Model Context Protocol (MCP) server that provides secure database access to PostgreSQL through Kysely ORM. This server enables Claude Desktop to interact with PostgreSQL databases using natural language.\n\n## Features\n\n- **MCP Tools**: Query execution, table listing, schema inspection, and constraint information\n- **Type Safety**: Full TypeScript support with typed inputs/outputs\n- **Connection Pooling**: Configurable connection limits with idle timeout\n- **Error Handling**: Graceful error messages for connection and query issues\n- **Security**: Parameterized queries to prevent SQL injection\n\n## Installation\n\n```bash\nnpx postgres-mcp-server\n```\n\n## Configuration\n\nCreate a `.env` file with your database credentials:\n\n```env\nDB_HOST=127.0.0.1\nDB_PORT=5432\nDB_USER=postgres\nDB_PASSWORD=your_password_here\nDB_NAME=postgres\nDB_SSL=true\n```\n\n## Available Tools\n\n| Tool                  | Description                                 | Required Parameters                 | Optional Parameters                                         |\n| --------------------- | ------------------------------------------- | ----------------------------------- | ----------------------------------------------------------- |\n| **`query`**           | Execute SQL queries with pagination support | `sql` (string)                      | `pageSize` (1-500), `offset` (number), `parameters` (array) |\n| **`describe_table`**  | Get table structure and column details      | `schema` (string), `table` (string) | -                                                           |\n| **`list_tables`**     | List all tables in a schema                 | `schema` (string)                   | -                                                           |\n| **`list_schemas`**    | List all schemas in the database            | -                                   | `includeSystemSchemas` (boolean)                            |\n| **`get_constraints`** | Get table constraints (PK, FK, etc.)        | `schema` (string), `table` (string) | -                                                           |\n| **`list_indexes`**    | List indexes for a table or schema          | `schema` (string)                   | `table` (string)                                            |\n| **`list_views`**      | List views in a schema                      | `schema` (string)                   | -                                                           |\n| **`list_functions`**  | List functions and procedures               | `schema` (string)                   | -                                                           |\n| **`explain_query`**   | Get query execution plan                    | `sql` (string)                      | `analyze` (boolean), `format` (text/json/xml/yaml)          |\n| **`get_table_stats`** | Get table size and statistics               | `schema` (string)                   | `table` (string)                                            |\n\n### Key Features\n\n- **Pagination**: Query tool supports up to 500 rows per page with automatic LIMIT/OFFSET handling\n- **Security**: Parameterized queries prevent SQL injection, READ_ONLY mode by default\n- **Type Safety**: Full TypeScript support with Zod schema validation\n\n## Claude Desktop Configuration\n\nAdd this server to your Claude Desktop configuration file:\n\nEdit `claude_desktop_config.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"postgres-mcp-server\": {\n      \"command\": \"npx\",\n      \"args\": [\"postgres-mcp-server\"],\n      \"env\": {\n        \"DB_HOST\": \"127.0.0.1\",\n        \"DB_PORT\": \"5432\",\n        \"DB_USER\": \"postgres\",\n        \"DB_PASSWORD\": \"your_password_here\",\n        \"DB_NAME\": \"your_database_name\",\n        \"DB_SSL\": \"true\"\n      }\n    }\n  }\n}\n```\n\n### Configuration File Locations\n\n- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`\n- **Windows**: `%APPDATA%\\Claude\\claude_desktop_config.json`\n\n## Development\n\n```bash\n# Clone and install dependencies\ngit clone https://github.com/abiswas97/postgres-mcp-server.git\ncd postgres-mcp-server\nnpm install\n\n# Run in development mode with hot reload\nnpm run dev\n\n# Build for production\nnpm run build\n\n# Run tests\nnpm run test\n\n# Run specific test suites\nnpm run test:unit\nnpm run test:integration\n```\n\n## Environment Variables\n\n| Variable            | Default     | Description                             |\n| ------------------- | ----------- | --------------------------------------- |\n| `DB_HOST`           | `127.0.0.1` | PostgreSQL host                         |\n| `DB_PORT`           | `5432`      | PostgreSQL port                         |\n| `DB_USER`           | `postgres`  | Database user                           |\n| `DB_PASSWORD`       | _required_  | Database password                       |\n| `DB_NAME`           | `postgres`  | Database name                           |\n| `DB_SSL`            | `true`      | Enable SSL connection                   |\n| `READ_ONLY`         | `true`      | Restrict to SELECT/WITH/EXPLAIN queries |\n| `QUERY_TIMEOUT`     | `30000`     | Query timeout in milliseconds           |\n| `MAX_PAGE_SIZE`     | `500`       | Maximum rows per page                   |\n| `DEFAULT_PAGE_SIZE` | `100`       | Default page size when not specified    |\n\n## License\n\nISC\n","readmeFilename":"README.md","_rev":"1-a3ea613faceac954a5ea5cede19cc7ee"}