
postgres_mcp
一个为 PostgreSQL 数据库设计的模型上下文协议 (MCP) 服务器,允许 AI 助手安全地与其交互。
Repository Info
About This Server
一个为 PostgreSQL 数据库设计的模型上下文协议 (MCP) 服务器,允许 AI 助手安全地与其交互。
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
PostgreSQL MCP Server
A Model Context Protocol (MCP) server for PostgreSQL databases that allows AI assistants like Claude to interact with your PostgreSQL databases.
Features
- Browse database schemas and table structures
- Run read-only SQL queries against your database
- Automatic truncation of long field values (>200 characters)
- Read-only transactions for safety
Prerequisites
- Node.js 18 or higher
- npm or yarn
- PostgreSQL database
Installation
# Clone the repository
git clone https://github.com/yourusername/postgres_mcp.git
cd postgres_mcp
# Install dependencies
npm install
# Build the project
npm run build
Usage with Cursor
Setup
- Start the MCP server with your PostgreSQL connection string:
node dist/index.js postgres://username:password@hostname:port/database
- In Cursor, configure Claude to use the MCP server by creating a
.cursor/mcp.jsonfile:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"path/to/repo/postgres_mcp/dist/index.js",
"postgres://username:password@hostname:port/database"
]
}
}
}
Make sure to update the path to your index.js file and the database connection string with your actual values.
Using with Claude in Cursor
Once configured, you can ask Claude questions about your database:
- Explore database structure: "What tables are in the database?"
- Query data: "Get the first 5 rows from the users table"
- Ask about schema: "What columns are in the products table?"
Example queries:
Can you show me the schema of the users table?
Run a query to find all customers who made purchases in the last month.
What's the total revenue by product category?
Security Notes
- The server runs queries in read-only transactions to prevent data modification
- Database password is not exposed in resource URIs
- Only allows SELECT queries
Limitations
- Only supports read operations (no INSERT, UPDATE, DELETE)
- Field values longer than 200 characters are truncated
- Limited to PostgreSQL databases
Troubleshooting
If Claude cannot connect to your database:
- Verify your PostgreSQL connection string is correct
- Ensure the database user has appropriate permissions
- Check network connectivity and firewall settings
- Verify the MCP server is running (should show no errors in terminal)
License
MIT
Quick Start
Clone the repository
git clone https://github.com/devacc00/postgres_mcpInstall dependencies
cd postgres_mcp
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.