MCP Staging Data
Provides tools for working with PostgreSQL databases: inspecting schemas and likely PII columns, planning referentially complete subsets from root rows, extracting anonymized data into a staging PostgreSQL database, and verifying that PII columns are masked, without exposing source row values to the agent.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
MCP Staging Data
GDPR-safe PostgreSQL subset + anonymization for AI coding agents (Claude Code, Cursor) — copy a small, referentially complete slice of production into staging, mask PII in memory, and never show clear production rows to the model.
Reproduce data-dependent bugs (“order 4812”) with real-shaped data: no raw emails, names, or phones in agent context. Local-first MCP server over stdio.
Part of the petrovicistefan MCP suite — local-first guardrails for AI coding agents.
Status: v0.1 complete locally. npm / MCP Registry publish stays with the maintainer.
Why MCP Staging Data?
Teams often dump production Postgres into a laptop to debug one order — and leak PII into git, Slack, and AI chats. Hosted anonymizers and CLI subsetters are not wired for agents. This server is:
Need | What you get |
Agent-safe | Tools return schema, plans, counts, verify status — never source row values |
GDPR-minded | Anonymize in memory before any target write; fail closed without rules |
Referentially complete | FK walk from a root row (parents + descendants, cycle-safe) |
Deterministic | HMAC pseudonyms so joins keep working across tables |
Local-first | stdio MCP; connections only from env; no telemetry |
Search / discovery keywords
PostgreSQL staging data, database subset for developers, PII anonymization MCP, GDPR-safe test data, production data masking for AI agents, referentially complete subset, deterministic fake email/name/phone, Claude Code Postgres staging, Cursor MCP database anonymizer.
Related MCP server: dryrun
What it does (and does not)
Does: inspect schema + likely PII columns → set per-column rules → plan a subset from a root primary key → extract (read-only source, anonymize, write target) → verify masks on the target.
Does not: full DB replication, backup, MySQL (v0.1), synthetic generation, or a general SQL client for production. The agent is not meant to browse clear production rows.
Quick start (local / unpublished)
cp .env.example .env # edit URLs + HMAC key
npm ci && npm run build
node dist/server.jsCursor
Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"staging-data": {
"command": "node",
"args": ["/absolute/path/to/mcp-staging-data/dist/server.js"],
"env": {
"STAGING_DATA_SOURCE_URL": "postgres://readonly@127.0.0.1:5432/prod_copy",
"STAGING_DATA_TARGET_URL": "postgres://dev@127.0.0.1:5432/staging",
"STAGING_DATA_HMAC_KEY": "replace-with-a-long-random-string"
}
}
}
}Claude Code
claude mcp add staging-data --env STAGING_DATA_SOURCE_URL=... --env STAGING_DATA_TARGET_URL=... --env STAGING_DATA_HMAC_KEY=... -- node /absolute/path/to/mcp-staging-data/dist/server.jsAfter publish: npx -y mcp-staging-data@<version> with the same env block.
Use cases & example prompts
Inspect the source schema and list columns that look like PII.
Set fake_email on users.email and fake_name on users.full_name.
Plan a subset for orders where ids=[4812] and show row counts only.
Extract that subset into staging, then verify no clear emails remain.Typical workflows: bug reproduction on one order/user, GDPR-safer local fixtures, CI policy checks on staging-data.rules.json, shared deterministic masks via STAGING_DATA_HMAC_KEY.
Safety in one paragraph
Connections come only from environment variables. The source session is read-only. The target must not be the same host+port+database as the source (localhost ≡ 127.0.0.1). Rows are anonymized in memory before anything is written. Tools never return source cell values. Extract refuses unless every column in the planned tables has an explicit rule (PII keep also needs a reason).
Environment
Variable | Required | Purpose |
| yes | Read-only Postgres URL |
| yes | Writable staging/local URL |
| yes | ≥16 chars; deterministic pseudonyms |
| no | Defaults to |
Prefer a Postgres role with SELECT-only grants on the source.
Tools
Tool | Kind | Returns |
| read | Tables, FKs, PII-flagged columns |
| write (local file) | Writes/merges |
| read | Related tables + row counts for a root row ( |
| write (target) | Anonymized subset load; counts only |
| read | Whether target PII columns look ruled/masked |
Connection strings are never tool arguments.
Anonymization rules
Type | Behaviour |
| HMAC-SHA256 hex (64 chars) |
| Stable |
| Stable |
| Stable |
| Always |
| Pass-through; on PII columns requires |
Same HMAC key + input ⇒ same output (joins hold). Rotate the key ⇒ all pseudonyms change.
Example staging-data.rules.json:
{
"version": 1,
"columns": {
"users.id": { "type": "keep" },
"users.email": { "type": "fake_email" },
"users.full_name": { "type": "fake_name" },
"orders.status": { "type": "keep", "reason": "workflow status is not personal data" }
}
}Every extracted column needs a rule. Free-text types (text, citext, json, jsonb, xml) are treated as PII risks by heuristics; false positives are expected.
How it compares
Approach | Agent-safe (no clear rows) | Referential subset | In-memory anonymize | MCP-native |
Raw | ❌ | ❌ (usually full) | ❌ | ❌ |
CLI subsetters | ❌ (logs/CLI) | ✅ | varies | ❌ |
Query-result maskers | masks output only | ❌ | n/a | sometimes |
MCP Staging Data | ✅ | ✅ | ✅ | ✅ |
Demo (fake data only)
docker compose -f docker-compose.test.yml up -d
npm run demoSeeds compose “source” from test/fixtures/, plans/extracts order 10, verifies the target, asserts clear fixture emails/names are gone.
Threat model
Assets
Production row values (PII and business data)
Connection strings and
STAGING_DATA_HMAC_KEYAgent / MCP client context (must not receive clear source rows)
Trust boundaries
Operator machine running the MCP server (trusted to hold env secrets)
Source Postgres (untrusted content; network as configured by the operator)
Target Postgres (receives anonymized rows)
MCP client / model (untrusted; schemas, plans, counts, verify only)
Threats and controls
Threat | Control |
Agent reads production rows | Tools never return source cell values; tests assert fixture PII absent from tool output |
Clear data written then masked | Anonymize in memory; only transformed rows are inserted |
Agent supplies DB credentials | Tool schemas forbid url/dsn/password/secret/key-like fields; URLs from env only |
Secrets in errors/logs |
|
Target is production |
|
Writes on source |
|
Unruled / new columns copied clear | Extract refuses unless every planned column has a rule |
Reversible pseudonyms | HMAC keyed by local secret |
Prompt injection via DB content | Agent never sees source row payloads |
Out of scope (v0.1)
Malicious operator with valid env credentials
Perfect PII detection (heuristics + verify reduce risk)
DNS-alias identity beyond loopback normalization
MySQL / synthetic generation / full-DB copy
Residual risk
Heuristic PII detection can miss columns. Review staging-data.rules.json in PRs; rotate STAGING_DATA_HMAC_KEY if leaked.
FAQ
Does the agent see production emails? No. Tools return metadata and counts; extract writes only anonymized values to the target.
Is this a backup tool? No. It copies small subsets (thousands of rows), not whole databases.
Why HMAC? Deterministic masks keep FK/join shape stable without shipping a reversible cipher in v0.1.
Can target equal source? No. Same host+port+database is refused (localhost and 127.0.0.1 match).
Development
npm run check && npm run check:rules && npm test && npm run build
docker compose -f docker-compose.test.yml up -d
npm run test:integrationNode ≥ 22.18. Runtime deps: @modelcontextprotocol/sdk, zod, pg only.
Marketplace
Plugin manifests to copy after npm publish: docs/marketplace-plugin/. Do not pin an unpublished version in mcp-marketplace.
More MCP servers by the author
See the petrovicistefan MCP marketplace: security-guard, database-doctor, api-guardian, dependency-doctor, cost-optimizer, seo-auditor, and more.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Deterministic safety, correctness & cost gate that vets Postgres SQL before your AI agent runs it.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Generate realistic, FK-consistent synthetic test data for your databases from your AI assistant.
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with PostgreSQL databases through schema intelligence, query execution, and DBA tooling including index analysis and health monitoring. Features configurable access levels and audit logging for secure database operations.MIT
- AlicenseNot gradedqualityBmaintenanceGives AI coding assistants, IDEs, and CI full PostgreSQL schema intelligence from an offline snapshot, enabling linting, query validation, migration safety analysis, and foreign key graph exploration without ever exposing database credentials.36BSD 2-Clause "Simplified"
- AlicenseAqualityBmaintenanceEnables AI agents to query PostgreSQL databases securely with read-only defaults, PII masking, rate limiting, and human-approved, expiring mutation tokens.91Apache 2.0
- AlicenseBqualityCmaintenanceEnables AI coding agents to perform deterministic database architecture audits and performance engineering for PostgreSQL and MySQL, covering migration analysis with schema health scoring, ESR-based composite index recommendations, N+1 query detection, EXPLAIN plan diagnosis, transaction and deadlock analysis, partitioning and archival design, and capacity or configuration tuning. It also generates phased Expand & Contract runbooks that turn blocking DDL into zero-downtime production migrations.8MIT