postgres_mcp_cra
v1.0.3
Published
Secure MCP server for reading PostgreSQL databases
Maintainers
Readme
PostgreSQL MCP Server
A secure, read-only MCP (Model Context Protocol) server for PostgreSQL databases. Provides safe access to PostgreSQL through standardized MCP tools with built-in security measures to prevent data modification.
Features
- 🔒 Read-only access - Only SELECT queries are allowed
- 🛡️ SQL injection protection - Parameterized queries and input validation
- 📊 Schema exploration - List schemas, tables, and table structures
- 🔍 Query execution - Execute parameterized SELECT queries (max 1000 rows)
- ✅ Type-safe - Built with TypeScript and Zod validation
- 🚀 Easy setup - Simple configuration via environment variables
Installation
npm install postgres_mcp_craOr install globally:
npm install -g postgres_mcp_craQuick Start
1. Install the package (optional)
If you want to install locally in a project:
npm install postgres_mcp_craNote: Installation is optional when using npx (recommended method below).
2. Configure MCP Server
Add to your .mcp.json or Claude Desktop configuration:
Recommended: Using npx (no installation required)
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "postgres_mcp_cra"],
"env": {
"PGHOST": "localhost",
"PGPORT": "5432",
"PGDATABASE": "mydatabase",
"PGUSER": "myuser",
"PGPASSWORD": "mypassword"
}
}
}
}Or use a connection string with npx:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "postgres_mcp_cra"],
"env": {
"DATABASE_URL": "postgresql://user:password@localhost:5432/mydatabase"
}
}
}
}Alternative: Using local installation
If you've installed the package locally:
{
"mcpServers": {
"postgres": {
"command": "node",
"args": ["node_modules/postgres_mcp_cra/dist/index.js"],
"env": {
"PGHOST": "localhost",
"PGPORT": "5432",
"PGDATABASE": "mydatabase",
"PGUSER": "myuser",
"PGPASSWORD": "mypassword"
}
}
}
}3. Usage Example

Security
⚠️ Important Security Notice
For sensitive databases, always use a database connection with read-only permissions.
This MCP server is designed to be read-only and includes multiple security measures:
- ✅ Only SELECT queries are allowed
- ✅ SQL injection protection through parameterized queries
- ✅ Input validation with Zod schemas
- ✅ Schema/table name validation
- ✅ Query result limits (1000 rows max)
However, you should still configure your PostgreSQL user with read-only permissions to add an extra layer of security.
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For issues, questions, or contributions, please open an issue on the GitHub repository.
