Postgres

Postgres

By guoling2008 GitHub

-

postgres database
Overview

what is go-mcp-postgres?

go-mcp-postgres is a Model Context Protocol (MCP) server designed for interacting with Postgres databases, allowing for easy CRUD operations and automation without the need for a Node.js or Python environment.

how to use go-mcp-postgres?

To use go-mcp-postgres, you can either download the latest release and add it to your PATH or build it from source using Go. You can then run the server with command line arguments to connect to your Postgres database.

key features of go-mcp-postgres?

  • Zero burden, ready-to-use MCP server for Postgres.
  • Supports CRUD operations on Postgres databases and tables.
  • Read-only mode to prevent unintended write operations.
  • Ability to check query plans using the EXPLAIN statement before execution.

use cases of go-mcp-postgres?

  1. Automating database interactions without complex setups.
  2. Performing safe read-only operations on production databases.
  3. Quickly creating and managing Postgres tables and data.

FAQ from go-mcp-postgres?

  • Is go-mcp-postgres production-ready?

No, it is still a work in progress and may not be ready for production use.

  • What programming environments are required?

No Node.js or Python environment is needed; it runs independently.

  • Can I use it for read-only operations?

Yes, you can enable a read-only mode to restrict operations.

Content

go-mcp-postgres

Overview

Copy code from https://github.com/Zhwt/go-mcp-mysql/ and with ai help, I change db from mysql to postgres.

Zero burden, ready-to-use Model Context Protocol (MCP) server for interacting with Postgres and automation. No Node.js or Python environment needed. This server provides tools to do CRUD operations on Postgres databases and tables, and a read-only mode to prevent surprise write operations. You can also make the MCP server check the query plan by using a EXPLAIN statement before executing the query by adding a --with-explain-check flag.

Please note that this is a work in progress and may not yet be ready for production use.

Installation

  1. Get the latest release and put it in your $PATH or somewhere you can easily access.

  2. Or if you have Go installed, you can build it from source:

go install -v github.com/guoling2008/go-mcp-postgres@latest

Usage

Method A: Using Command Line Arguments

{
  "mcpServers": {
    "postgres": {
      "command": "go-mcp-postgres",
      "args": [
        "--dsn",
        "postgresql://user:pass@host:port/db"
      ]
    }
  }
}

Note: For those who put the binary outside of your $PATH, you need to replace go-mcp-postgres with the full path to the binary: e.g.: if you put the binary in the Downloads folder, you may use the following path:

{
  "mcpServers": {
    "postgres": {
      "command": "C:\\Users\\<username>\\Downloads\\go-mcp-postgres.exe",
      "args": [
        ...
      ]
    }
  }
}

Optional Flags

  • Add a --read-only flag to enable read-only mode. In this mode, only tools beginning with list, read_ and desc_ are available. Make sure to refresh/restart the MCP server after adding this flag.
  • By default, CRUD queries will be first executed with a EXPLAIN ? statement to check whether the generated query plan matches the expected pattern. Add a --with-explain-check flag to disable this behavior.

Tools

Schema Tools

  1. list_database

    • List all databases in the Postgres server.
    • Parameters: None
    • Returns: A list of matching database names.
  2. list_table

    • List all tables in the Postgres server.
    • Parameters:
      • name: If provided, list tables with the specified name, Otherwise, list all tables.
    • Returns: A list of matching table names.
  3. create_table

    • Create a new table in the Postgres server.
    • Parameters:
      • query: The SQL query to create the table.
    • Returns: x rows affected.
  4. alter_table

    • Alter an existing table in the Postgres server. The LLM is informed not to drop an existing table or column.
    • Parameters:
      • query: The SQL query to alter the table.
    • Returns: x rows affected.
  5. desc_table

    • Describe the structure of a table.
    • Parameters:
      • name: The name of the table to describe.
    • Returns: The structure of the table.

Data Tools

  1. read_query

    • Execute a read-only SQL query.
    • Parameters:
      • query: The SQL query to execute.
    • Returns: The result of the query.
  2. write_query

    • Execute a write SQL query.
    • Parameters:
      • query: The SQL query to execute.
    • Returns: x rows affected, last insert id: <last_insert_id>.
  3. update_query

    • Execute an update SQL query.
    • Parameters:
      • query: The SQL query to execute.
    • Returns: x rows affected.
  4. delete_query

    • Execute a delete SQL query.
    • Parameters:
      • query: The SQL query to execute.
    • Returns: x rows affected.

Big thanks to https://github.com/Zhwt/go-mcp-mysql/ again.

License

MIT

No tools information available.
Sqlite
Sqlite by sqlite

Database interaction and business intelligence capabilities

sqlite database
View Details
mcp-db-server
mcp-db-server by iotassss

-

mcp-db-server database
View Details
mcp-lancedb-server
mcp-lancedb-server by richard-gyiko

-

mcp-lancedb-server database
View Details
db-mcp
db-mcp by goru00

Database Model Context Protocol (DB-MCP) Server

db-mcp database
View Details

mysql数据库连接,改 f4ww4z/mcp-mysql-server中的连接配置支持cherry studio

mcp-mysql-server database
View Details

Mirror of

mysql database
View Details

The official Redis MCP Server is a natural language interface designed for agentic applications to manage and search data in Redis efficiently

redis database
View Details