Blog
MCPPostgreSQLSynthetic Data

Generate Postgres test data with Claude (or Cursor)

Connect Weavori's MCP server to Claude or Cursor and your AI assistant can introspect a Postgres schema, estimate a dataset, and generate FK-intact synthetic data — in natural language.

The Weavori TeamAugust 25, 20265 min read

Your AI assistant can already write code, explain errors, and refactor. With Weavori's built-in MCP server, it can also generate Postgres test data — reading your actual schema, estimating a dataset, and producing referentially intact synthetic rows, all from a conversation. This post walks through the whole loop, honestly, including the boundaries.

What you need

  • Weavori — either installed (weavori mcp) or via the zero-install npx launcher
  • Node.js 20+ if you use the npx launcher
  • A WEAVORI_API_KEY from the dashboard, or a one-time weavori login on the same machine
  • An MCP client: Claude Desktop, Cursor, VS Code (Continue), or Qoder

The MCP setup guide has copy-paste configs for all four clients. The short version for Claude Desktop — add this to claude_desktop_config.json and restart:

{
  "mcpServers": {
    "weavori": {
      "command": "npx",
      "args": ["-y", "@weavori/cli", "mcp"],
      "env": {
        "WEAVORI_DATABASE_URL": "postgres://user:password@host:5432/mydb",
        "WEAVORI_API_KEY": "your-api-key"
      }
    }
  }
}

The five Weavori tools appear under the MCP icon: introspect, estimate, generate, doctor, and sync. Three of the five are read-only.

The loop: schema → plan → data

Here's a complete, realistic session. The database is a small e-commerce schema — users, orders, order_items.

You: "Introspect the database at postgres://user:pass@localhost:5432/mydb"

Assistant (calls introspect): returns the schema — tables, columns, types, foreign keys. It now knows orders.user_id references users.id, and order_items.order_id references orders.id.

You: "Estimate how long it would take to generate data for this database"

Assistant (calls estimate): reports expected row counts per table and generation time before anything is written.

You: "Generate 500 rows of synthetic data for each table into the target database"

Assistant (calls generate): Weavori resolves the FK dependency order — users first, then orders, then order_items — and streams the rows via COPY. Every generated order references a real generated user, by construction. The assistant summarizes what it created and how long it took.

That's the whole workflow: three sentences, zero YAML, zero generator configuration. The data is FK-intact because the schema — not a config file — drove the generation.

Why this works for test data

Test data is a natural fit for AI assistants because the hard part is knowing the schema, and that's exactly what introspect solves. A generic prompt like "give me some test data" produces generic rows. An assistant that first reads your tables, constraints, and foreign keys asks better questions and generates data that matches your application — not a tutorial's.

It's also the same engine as the CLI. Everything that makes Weavori's data trustworthy in a pipeline — FK resolution by construction, pg_stats distribution sampling, cross-column coherence — is identical over MCP. There's no second, weaker implementation behind the AI interface.

Where the boundaries are

Being honest about the edges, from our own testing:

  • It connects to a live database. The MCP tools take a connection string. If you want to generate from raw CREATE TABLE statements without any database, that's the CLI's DDL paste mode, not MCP — use weavori directly for that.
  • It writes where you point it. generate and sync write to the target database you specify. Point them at a scratch database first; the estimate tool is there precisely so you can check before generating.
  • Large schemas take minutes. Generation and sync are not instant; raise the tool timeout in your MCP client's settings for big schemas.
  • Auth is explicit. The MCP server authenticates with an API key or a cached login — it never reads your OS keyring, which keeps it usable in headless and CI contexts.

Try it

Point the MCP server at any PostgreSQL database and start with introspect — the tool response alone is the fastest way to understand a schema you didn't write. Then ask for an estimate before you generate anything.

One command, same engine

The MCP server and the CLI are the same codebase. Everything in the Postgres test data guide applies to both interfaces — the difference is only how you talk to it.

Full client configs (Cursor, Continue, Qoder) and troubleshooting live in the MCP setup guide, and the MCP landing page has the five-tool overview.