- Home
- MCP servers
- Postgres
Postgres
- rust
32
GitHub Stars
rust
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Postgres MCP provides a standardized interface for AI agents to interact with PostgreSQL databases through a set of well-defined MCP commands. It supports multiple concurrent connections, basic CRUD operations, and safety and validation features to ensure secure and correct SQL execution against PostgreSQL databases.
How to use
You connect to a PostgreSQL database through an MCP client by registering a database connection, then issue high-level commands to read, insert, update, delete, or manage schema objects. The server supports both local, stdio-based usage and remote HTTP-based interaction, so you can run it as a local process or connect to a running endpoint.
How to install
cargo install postgres-mcp
Configuration and operation specifics
The MCP server can be run in two ways: as a local process using stdio, or as a remote HTTP/SSE endpoint. Use the stdio mode when running the server locally and the HTTP/SSE mode when you want to connect clients over HTTP.
Stdio (local) mode configuration example:
{
"mcpServers": {
"postgres": {
"command": "postgres-mcp",
"args": ["stdio"]
}
}
}
SSE/HTTP mode configuration example (URL-based):
{
"mcpServers": {
"postgres": {
"url": "http://localhost:3000/sse"
}
}
}
Common commands and workflows
Once connected, you can perform a range of operations to manage data and schema. Typical workflows include registering a connection, running queries, and managing tables and indexes.
Register a database connection and obtain a connection ID (UUID), then use that ID for subsequent operations.
Available commands (high level)
Register a Database Connection: establish a new connection and obtain its ID for later use.
Unregister a Connection: release a previously opened connection by its ID.
Execute a SELECT Query: fetch data from a table, returning rows that match your query.
Insert Data: add new rows to a table.
Update Data: modify existing rows based on a condition.
Delete Data: remove rows from a table.
Create a Table: define a new table with columns and constraints.
Drop a Table: remove an existing table.
Create an Index: improve query performance on a column or set of columns.
Drop an Index: remove a previously created index.
Describe a Table: inspect the structure of a table, including columns and data types.
List Tables: enumerate tables within a schema.
Available tools
register
Register a new database connection and obtain a connection ID for subsequent operations.
unregister
Release an active connection using its connection ID.
query
Execute a SELECT query against a connected database and return matching rows.
insert
Insert new records into a table.
update
Update existing records based on a condition.
delete
Delete records from a table.
create_table
Create a new table with specified columns and constraints.
drop_table
Drop an existing table from the database.
create_index
Create an index to improve query performance.
drop_index
Drop an existing index.
describe_table
Describe the structure of a table, including column types and constraints.
list_tables
List all tables in a given schema.