Skip to content

iwanbk/postgres-mcp-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PostgreSQL MCP Server in Go

Go CI

A Go implementation of a Model Context Protocol (MCP) server for PostgreSQL. This server enables LLMs to inspect database schemas and execute read-only queries against PostgreSQL databases.

Features

  • Exposes PostgreSQL table schemas as resources
  • Provides a tool to execute read-only SQL queries
  • Uses sqlx for PostgreSQL connectivity
  • Built with the mcp-go library

Installation

go install github.com/iwanbk/postgres-mcp-go@latest

Or build from source:

git clone https://github.com/iwanbk/postgres-mcp-go.git
cd postgres-mcp-go
go build -v

Usage

Run the server by providing a PostgreSQL connection URL using the -database_url flag:

postgres-mcp-go -database_url=postgresql://username:password@localhost/mydb

You can also view available options with the help flag:

postgres-mcp-go -help

Resources

The server provides schema information for each table in the database:

  • postgres://<host>/<table>/schema - JSON schema information for each table
    • Includes column names and data types
    • Automatically discovered from database metadata

Tools

  • query - Execute read-only SQL queries against the connected database
    • Input: sql (string): The SQL query to execute
    • All queries are executed within a READ ONLY transaction

Security

This server only allows read-only operations. All queries are executed within a READ ONLY transaction to prevent any data modification.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published