guoling2008_go_mcp_postgres

guoling2008_go_mcp_postgres

by guoling2008
A ready-to-use MCP server for interacting with PostgreSQL databases, enabling CRUD operations and automation without requiring Node.js or Python.

PostgreSQL Integration for MCP Server

Overview

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.

go-mcp-postgres

Installation

  1. Download the latest release and place it in your $PATH or an accessible directory.
  2. Alternatively, if you have Go installed, you can build it from source:

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

Usage

Method A: Using Command Line Arguments for stdio mode

{
  "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.

Method B: Using Command Line Arguments for sse mode

./go-mcp-postgres --t sse --ip x.x.x.x --port nnnn --dsn postgresql://user:pass@host:port/db

Optional Flags

  • --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.

Tools

Schema Tools

  1. list_database
  2. Lists all databases in the PostgreSQL server.
  3. Parameters: None
  4. Returns: A list of database names.

  5. list_table

  6. Lists all tables in the PostgreSQL server.
  7. Parameters:
    • name: (Optional) Filters tables by name.
  8. Returns: A list of table names.

  9. create_table

  10. Creates a new table in the PostgreSQL server.
  11. Parameters:
    • query: The SQL query to create the table.
  12. Returns: Number of rows affected.

  13. alter_table

  14. Alters an existing table in the PostgreSQL server.
  15. Parameters:
    • query: The SQL query to alter the table.
  16. Returns: Number of rows affected.

  17. desc_table

  18. Describes the structure of a table.
  19. Parameters:
    • name: The name of the table to describe.
  20. Returns: The table structure.

Data Tools

  1. read_query
  2. Executes a read-only SQL query.
  3. Parameters:
    • query: The SQL query to execute.
  4. Returns: The query result.

  5. write_query

  6. Executes a write SQL query.
  7. Parameters:
    • query: The SQL query to execute.
  8. Returns: Number of rows affected and the last insert ID.

  9. update_query

  10. Executes an update SQL query.
  11. Parameters:
    • query: The SQL query to execute.
  12. Returns: Number of rows affected.

  13. delete_query

  14. Executes a delete SQL query.
  15. Parameters:
    • query: The SQL query to execute.
  16. Returns: Number of rows affected.

  17. count_query

  18. Counts the number of rows in a table.
  19. Parameters:
    • name: The name of the table to count.
  20. Returns: The row count.

License

This project is licensed under the MIT License.

About

This project is a fork of go-mcp-mysql, adapted to work with PostgreSQL. Special thanks to the original author for their work.

Resources

Activity

  • Stars: 3
  • Watchers: 1
  • Forks: 0

Releases

Languages

  • Go: 100.0%

Features & Capabilities

Categories
mcp_server model_context_protocol postgresql go database_integration automation crud_operations sse

Implementation Details

Stats

0 Views
3 GitHub Stars

Repository Info

guoling2008 Organization

Similar MCP Servers

continuedev_continue by continuedev
25049
21423
9300