# Postgres and REST twins

The Postgres and REST twins MCP server for Claude Code creates local Postgres and REST stand-ins from a schema or OpenAPI spec. Requests outside the declared contract are rejected with a reason.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI
- Author: cmdrvl
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/cmdrvl/twinning
- Updated: 2026-11-13
- Security check: automated, 2026-11-17 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/mcp/postgres-and-rest-twins

## What it does

The server runs local Postgres and REST twins from a SQL schema or OpenAPI specification. Clients connect with their usual driver, and writes that break a constraint return a SQLSTATE and a refusal reason. It also records a report of requests.

The Postgres twin accepts a declared SQL subset; the REST twin serves routes defined by its spec. Requests beyond either contract are refused rather than guessed. A query set can be replayed against old and candidate Postgres snapshots to inspect migration differences.

Installation through `npx` uses the package runner. The ready-made server is available for macOS and Linux; the Windows archive contains no MCP server.

## Requirements
- Needs: Node.js (commands run via npx)
- Works with: PostgreSQL

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add twinning -- npx -y @cmdrvl/twinning-mcp
```

### Codex

**Platform CLI**
```bash
codex mcp add postgres-and-rest-twins -- npx -y @cmdrvl/twinning-mcp
```

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "postgres-and-rest-twins": {
            "command": "npx",
            "args": [
                "-y",
                "@cmdrvl/twinning-mcp"
            ]
        }
    }
}
```

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "postgres-and-rest-twins": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "@cmdrvl/twinning-mcp"
            ]
        }
    }
}
```

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add postgres-and-rest-twins npx -y @cmdrvl/twinning-mcp
```

## When to use it
- check how an extractor handles writes that violate a schema constraint
- compare query results across legacy and candidate database snapshots
- test an API client against an OpenAPI contract

## Example prompts
- Start a Postgres twin from `schema.sql` and show why writes that break constraints are refused.
- Replay this query set against the old and candidate Postgres snapshots, then report the differences.
- Test this REST client against the OpenAPI contract and show schema-related refusals.

## Similar
- [prisma-postgres](https://affpapa.org/en/nevibecode/skills/prisma-postgres.md) — skill · 431100 installs
- [prisma-postgres-setup](https://affpapa.org/en/nevibecode/skills/prisma-postgres-setup.md) — skill · 425700 installs
- [neon-postgres-branches](https://affpapa.org/en/nevibecode/skills/neon-postgres-branches.md) — skill · 37300 installs
- [neon-postgres-egress-optimizer](https://affpapa.org/en/nevibecode/skills/neon-postgres-egress-optimizer.md) — skill · 35100 installs
- [postgres-pro](https://affpapa.org/en/nevibecode/skills/postgres-pro.md) — skill · 8400 installs
- [postgres-patterns](https://affpapa.org/en/nevibecode/skills/postgres-patterns.md) — skill · 7200 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
