We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/gardner/mcp-postgres'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
CLAUDE.md•1.39 KiB
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Overview
This is a Model Context Protocol (MCP) server that provides read-only access to PostgreSQL databases. It allows LLMs to inspect database schemas and execute read-only SQL queries.
## Commands
```bash
# Install dependencies
pnpm install
# Build TypeScript to dist/
pnpm run build
# Watch mode for development
pnpm run watch
# Build Docker image (run from repo root)
docker build -t mcp/postgres -f src/postgres/Dockerfile .
# Run the server (requires database URL argument)
node dist/index.js postgresql://localhost:5432/mydb
```
## Architecture
Single-file MCP server (`index.ts`) that:
1. **Resources**: Exposes table schemas from `information_schema.columns` as JSON resources at `postgres://<host>/<table>/schema`
2. **Tools**: Provides a `query` tool that executes SQL within `READ ONLY` transactions (always rolled back)
3. **Transport**: Uses stdio transport for MCP communication
The server uses `pg.Pool` for connection management. All queries are intrinsically read-only via PostgreSQL's `BEGIN TRANSACTION READ ONLY`.
## Key Dependencies
- `@modelcontextprotocol/sdk`: MCP server implementation
- `pg`: PostgreSQL client
## Docker Notes
When connecting to PostgreSQL on the host machine from Docker, use `host.docker.internal` instead of `localhost` in the connection URL.