# PostgREST

MCP server for PostgREST — REST API layer for PostgreSQL

## Quick Start

```bash
# Connect this server (installs CLI if needed)
npx -y @smithery/cli@latest mcp add node2flow/postgrest

# Browse available tools
npx -y @smithery/cli@latest tool list node2flow/postgrest

# Get full schema for a tool
npx -y @smithery/cli@latest tool get node2flow/postgrest pg_get_schema

# Call a tool
npx -y @smithery/cli@latest tool call node2flow/postgrest pg_get_schema '{}'
```

## Direct MCP Connection

Endpoint: `https://postgrest--node2flow.run.tools`

**Required config:**
- `POSTGREST_URL` (query) — PostgREST server URL (e.g. http://localhost:3000)

**Optional config:**
- `POSTGREST_TOKEN` (query) — JWT token for authenticated requests (optional — anonymous role works without)

## Tools (10)

- `pg_get_schema` — Get the PostgREST OpenAPI schema — lists all available tables, views, functions, and their columns/types. Use this firs…
- `pg_describe_table` — Get detailed column information for a table/view — column names, types, formats, required fields, defaults, and constra…
- `pg_list_records` — List records from a table/view with filtering, column selection, ordering, and pagination.
- `pg_count_records` — Count records in a table/view matching optional filters. Returns count using exact (precise but slower), planned (fast …
- `pg_call_function` — Call a PostgreSQL function/procedure via RPC. Use POST (default) for volatile functions, GET for immutable/stable funct…
- `pg_insert_records` — Insert one or more records into a table. Pass a single object or array of objects. Use return="representation" to get t…
- `pg_update_records` — Update records matching a filter. IMPORTANT: filter is required to prevent accidental full-table updates. Use return="r…
- `pg_upsert_records` — Insert or update records (upsert). Uses "merge-duplicates" (update existing) or "ignore-duplicates" (skip existing) res…
- `pg_delete_records` — Delete records matching a filter. IMPORTANT: filter is required to prevent accidental full-table deletion. Use return="…
- `pg_replace_record` — Full replace (PUT) a single record matching a filter. All columns must be specified including the primary key. Creates …

```bash
# Get full input/output schema for a tool
npx -y @smithery/cli@latest tool get node2flow/postgrest <tool-name>
```

## Resources

- `postgrest://server-info` — Connection status and available tools for this PostgREST MCP server

## Prompts (2)

- `explore-database` — Guide for exploring and querying a PostgREST database
- `manage-data` — Guide for inserting, updating, and deleting data via PostgREST

---

License: MIT
