| Crates.io | rmcp-postgres |
| lib.rs | rmcp-postgres |
| version | 0.1.0 |
| created_at | 2026-01-03 13:38:03.489147+00 |
| updated_at | 2026-01-03 13:38:03.489147+00 |
| description | PostgreSQL MCP server built with rmcp - query, insert, update, delete, and schema inspection tools |
| homepage | |
| repository | https://github.com/sqrew/rmcp-postgres |
| max_upload_size | |
| id | 2020087 |
| size | 78,636 |
A PostgreSQL MCP (Model Context Protocol) server built with rmcp, the Rust MCP SDK.
Provides comprehensive PostgreSQL database access through MCP tools for querying, inserting, updating, deleting, and inspecting database schemas.
cargo install rmcp-postgres
git clone https://github.com/sqrew/rmcp-postgres
cd rmcp-postgres
cargo build --release
The binary will be at target/release/rmcp-postgres.
Set your PostgreSQL connection string and run:
# Using environment variable
export POSTGRES_CONNECTION_STRING="host=localhost user=postgres dbname=mydb password=secret"
rmcp-postgres
# Using command line argument
rmcp-postgres --db-config "host=localhost user=postgres dbname=mydb password=secret"
Add to your Cargo.toml:
[dependencies]
rmcp-postgres = "0.1"
rmcp = { version = "0.12", features = ["server"] }
tokio = { version = "1", features = ["full"] }
Use in your code:
use rmcp::service::ServiceExt;
use rmcp_postgres::PostgresServer;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create server with connection string
let server = PostgresServer::new("host=localhost user=postgres dbname=mydb");
// Serve over stdio (for MCP)
let (stdin, stdout) = (tokio::io::stdin(), tokio::io::stdout());
server.serve((stdin, stdout)).await?;
Ok(())
}
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"postgres": {
"command": "rmcp-postgres",
"env": {
"POSTGRES_CONNECTION_STRING": "host=localhost user=postgres dbname=mydb password=secret"
}
}
}
}
Or if installed from source:
{
"mcpServers": {
"postgres": {
"command": "/path/to/rmcp-postgres/target/release/rmcp-postgres",
"env": {
"POSTGRES_CONNECTION_STRING": "host=localhost user=postgres dbname=mydb"
}
}
}
}
PostgreSQL connection strings support multiple formats:
# Basic
"host=localhost user=postgres dbname=mydb"
# With password
"host=localhost user=postgres dbname=mydb password=secret"
# With port
"host=localhost port=5433 user=postgres dbname=mydb"
# Full URL format
"postgresql://postgres:secret@localhost:5432/mydb"
See the tokio-postgres documentation for all connection options.
{
"query": "SELECT * FROM users WHERE active = true LIMIT 10"
}
{
"table_name": "users",
"data": {
"username": "alice",
"email": "alice@example.com",
"active": true
}
}
{
"table_name": "users",
"values": {
"active": false
},
"where_conditions": {
"username": "alice"
}
}
{
"table_name": "users"
}
# Build
cargo build
# Run tests
cargo test
# Run with debug logging
RUST_LOG=rmcp_postgres=debug,rmcp=debug rmcp-postgres
Contributions welcome! Please feel free to submit issues or pull requests.
MIT