mcpField
M
mcp-server-postgres

mcp-server-postgres

Local
github.com/yuru-shaDatabases0Updated 42w ago

About mcp-server-postgres

mcp-server-postgres is an MCP server for LLMs that need to inspect PostgreSQL schemas and run read-only queries. It executes queries in READ ONLY transactions to limit database changes.

Key features

  1. 01PostgreSQL schema inspection
  2. 02Read-only query execution
  3. 03READ ONLY transaction enforcement
  4. 04Docker support
  5. 05NPM package available

Use cases

  1. 01Inspect a PostgreSQL database schema
  2. 02Run queries without modifying data

MCP support

Exposes PostgreSQL schema inspection and read-only query capabilities to MCP clients. Queries run in READ ONLY transactions.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"postgres-yuru-sha": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"mcp/postgres"
]
}
}
}
Run commanddocker run -i --rm mcp/postgres

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
ocimcp/postgres

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

mcp-server-postgres

CI Status smithery badge

Model Context Protocol Server for PostgreSQL databases. This server enables LLMs to inspect database schemas and execute read-only queries.

Features

  • Read-only access to PostgreSQL databases
  • Schema inspection capabilities
  • Safe query execution within READ ONLY transactions
  • Docker support
  • NPM package available

Installation

Using Docker
# Build the Docker image
make docker

# Run with Docker
docker run -i --rm mcp/postgres postgresql://host:port/dbname
Installing via Smithery

To install PostgreSQL Database Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @yuru-sha/mcp-server-postgres --client claude

Usage

With Claude Desktop

Add the following configuration to your claude_desktop_config.json:

{
  "mcpServers": {
    "postgres": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "mcp/postgres",
        "postgresql://host:port/dbname"
      ]
    }
  }
}

Note: When using Docker on macOS, use host.docker.internal if the PostgreSQL server is running on the host network.

Connection URL Format
postgresql://[user][:password]@host[:port]/database

Replace /database with your database name.

Development

# Initial setup
make setup

# Build the project
make build

# Format code
make format

# Run linter
make lint

License

This project is released under the MIT License.

Security

This server enforces read-only access to protect your database. All queries are executed within READ ONLY transactions.

For enhanced security, we recommend creating a read-only user.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.