| Crates.io | postgres-mcp |
| lib.rs | postgres-mcp |
| version | 0.3.2 |
| created_at | 2025-03-31 03:36:48.424074+00 |
| updated_at | 2025-06-01 00:19:25.262296+00 |
| description | A PostgreSQL MCP (Model Context Protocol) server implementation for building AI agents |
| homepage | https://github.com/tyrchen/postgres-mcp |
| repository | https://github.com/tyrchen/postgres-mcp |
| max_upload_size | |
| id | 1612986 |
| size | 500,317 |
Postgres MCP is a Model Context Protocol (MCP) implementation for PostgreSQL databases. It provides a standardized interface for AI agents to interact with PostgreSQL databases through a set of well-defined commands.
Connection Management
Database Operations
SQL Validation
cargo install postgres-mcp
Add the following to your MCP configuration file:
{
"mcpServers": {
"postgres": {
"command": "postgres-mcp",
"args": ["stdio"]
}
}
}
or run it in SSE mode:
First, start the postgres-mcp server in SSE mode:
postgres-mcp sse
Then, configure the MCP config file to use the SSE mode:
{
"mcpServers": {
"postgres": {
"url": "http://localhost:3000/sse"
}
}
}
Once you started the postgres-mcp server, you should see the status of the MCP config is green, like this (cursor):

And then you could interact with it via the agent, like this (cursor):

pg_mcp register "postgres://postgres:postgres@localhost:5432/postgres"
# Returns a connection ID (UUID)
pg_mcp unregister <connection_id>
pg_mcp query <connection_id> "SELECT * FROM users"
pg_mcp insert <connection_id> "INSERT INTO users (name, email) VALUES ('John Doe', 'john.doe@example.com')"
pg_mcp update <connection_id> "UPDATE users SET name = 'Jane Doe' WHERE id = 1"
pg_mcp delete <connection_id> "users" "1"
pg_mcp create <connection_id> "CREATE TABLE users (id SERIAL PRIMARY KEY, name VARCHAR(255), email VARCHAR(255))"
pg_mcp drop <connection_id> "users"
pg_mcp create_index <connection_id> "CREATE INDEX idx_users_name ON users (name)"
pg_mcp drop_index <connection_id> "idx_users_name"
pg_mcp describe <connection_id> "users"
To build from source:
git clone https://github.com/yourusername/postgres-mcp.git
cd postgres-mcp
cargo build --release
MIT license. See LICENSE.md for details.
Contributions are welcome! Please open an issue or submit a pull request.