The PostgreSQL Integration for MCP Server is a zero-burden, ready-to-use Model Context Protocol (MCP) server designed for interacting with PostgreSQL databases and automation. This server eliminates the need for Node.js or Python environments, providing tools for CRUD operations on PostgreSQL databases and tables. It also includes a read-only mode to prevent unintended write operations and an optional EXPLAIN
statement check to validate query plans before execution.
Note: This project is a work in progress and may not yet be ready for production use.
$PATH
or an accessible directory.shell
go install -v github.com/guoling2008/go-mcp-postgres@latest
{
"mcpServers": {
"postgres": {
"command": "go-mcp-postgres",
"args": [
"--dsn",
"postgresql://user:pass@host:port/db"
]
}
}
}
Note: If the binary is not in your $PATH
, replace go-mcp-postgres
with the full path to the binary.
./go-mcp-postgres --t sse --ip x.x.x.x --port nnnn --dsn postgresql://user:pass@host:port/db
--read-only
: Enables read-only mode, restricting tools to list
, read_
, and desc_
operations.--with-explain-check
: Disables the default EXPLAIN
statement check before executing CRUD queries.list_database
Returns: A list of database names.
list_table
name
: (Optional) Filters tables by name.Returns: A list of table names.
create_table
query
: The SQL query to create the table.Returns: Number of rows affected.
alter_table
query
: The SQL query to alter the table.Returns: Number of rows affected.
desc_table
name
: The name of the table to describe.read_query
query
: The SQL query to execute.Returns: The query result.
write_query
query
: The SQL query to execute.Returns: Number of rows affected and the last insert ID.
update_query
query
: The SQL query to execute.Returns: Number of rows affected.
delete_query
query
: The SQL query to execute.Returns: Number of rows affected.
count_query
name
: The name of the table to count.This project is licensed under the MIT License.
This project is a fork of go-mcp-mysql, adapted to work with PostgreSQL. Special thanks to the original author for their work.