PostgreSQL MCP
STREAMABLE HTTPMCP server for PostgreSQL database interaction through HTTP interface
MCP server for PostgreSQL database interaction through HTTP interface
A Model Control Protocol (MCP) server implementation for PostgreSQL databases. This project provides a simple HTTP interface to interact with PostgreSQL databases through MCP, allowing you to execute read-only queries and explore database resources.
.env filesgit clone https://github.com/ipfans/postgres-mcp.git cd postgres-mcp go mod download
You can configure the database connection in two ways:
go run cmd/postgres-mcp/main.go -db "postgres://user:password@localhost:5432/dbname"
.env file in the project rootDATABASE_URL=postgres://user:password@localhost:5432/dbname
go run cmd/postgres-mcp/main.go
The server will start on port 8080 by default.
List database resources:
POST http://localhost:8080/mcp
Content-Type: application/json
{
"type": "function",
"name": "resources"
}
Execute a read-only query:
POST http://localhost:8080/mcp
Content-Type: application/json
{
"type": "function",
"name": "query",
"arguments": {
"query": "SELECT * FROM your_table LIMIT 10"
}
}
This project is open source and available under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.