Go-MCP-Postgres is a ready-to-use Model Context Protocol (MCP) server for interacting with PostgreSQL databases. It provides tools for CRUD operations with options for read-only mode and query plan checking. This lightweight server requires no Node.js or Python environment to function.
You can install go-mcp-postgres using one of these methods:
Download the latest release from the official GitHub releases page and add it to your $PATH
or a location you can easily access.
If you have Go installed, build it from source with:
go install -v github.com/guoling2008/go-mcp-postgres@latest
You can run the MCP server in two different modes:
Configure your application to use go-mcp-postgres with the following JSON configuration:
{
"mcpServers": {
"postgres": {
"command": "go-mcp-postgres",
"args": [
"--dsn",
"postgresql://user:pass@host:port/db"
]
}
}
}
If the binary is not in your $PATH
, specify the full path:
{
"mcpServers": {
"postgres": {
"command": "C:\\Users\\<username>\\Downloads\\go-mcp-postgres.exe",
"args": [
"--dsn",
"postgresql://user:pass@host:port/db"
]
}
}
}
Run the server in SSE mode using:
./go-mcp-postgres --t sse --ip x.x.x.x --port nnnn --dsn postgresql://user:pass@host:port/db --lang en
--lang
: Set language (en/zh-CN), defaults to system language--read-only
: Enable read-only mode, restricting available tools to those beginning with list
, read_
and desc_
--with-explain-check
: Forces checking query plans before execution using EXPLAIN statementsThe MCP server provides various tools for database operations that are automatically localized based on the language parameter.
name
: (Optional) Specific table name to filter byquery
: SQL CREATE TABLE statementquery
: SQL ALTER TABLE statementname
: Table name to describequery
: SQL SELECT statementquery
: SQL INSERT statementquery
: SQL UPDATE statementquery
: SQL DELETE statementname
: Table name to countThere are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.