lgpd-mask-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@lgpd-mask-mcp chame sample_safe na tabela customers e mostre 5 linhas mascaradas"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
lgpd-mask-mcp
MCP de consulta a banco com máscara de dados sensíveis (LGPD) para Cursor/agents.
Reduz risco de PII no contexto do modelo. Não substitui DPO/jurídico.
O que é este MCP (em 30 segundos)
MCP = protocolo para o Cursor falar com um processo externo via tools.
Neste projeto o processo é um server Node que:
Recebe pedidos do agent (
sample_safe,query_masked, …)Consulta Postgres só com SELECT que ele mesmo monta (sem SQL livre do agent)
Aplica a policy YAML (máscara)
Devolve JSON já sem PII cru
Seu chat no Cursor
→ escolhe uma tool
→ lgpd-mask-mcp (stdio)
→ mask + pii-policy
→ Postgres (Acme demo ou outro .env)
← linhas mascaradasRelated MCP server: Secure RDS Read-Only MCP Server
Status
MVP usável localmente (tools + Acme + DX).
Como usar em 5 minutos (neste repo)
cp .env.example .env # edite senhas locais só no .env (não versionado)
docker compose up -d db # Postgres Acme
npm install
npm run build
npm test # opcional
npx tsx scripts/demo-visual.mts # opcional: HTML em docs/demo/Plugar no Cursor (este projeto)
Copie
.cursor/mcp.json.example→.cursor/mcp.json.Troque
<ABSOLUTE_PATH_TO_THIS_REPO>pelo path local desta pasta.No modo host, preencha
<LOCAL_PASSWORD>/<LOCAL_MASK_SALT>(mesmos valores do seu.env).PII_POLICY_PATHpode ser relativo aocwd(ex.:pii-policy.example.yaml).Settings → MCP →
lgpd-maskverde → no chat: “chame sample_safe na tabela customers”.
Detalhes: docs/RUNBOOK.md.
Usar este MCP em outro projeto Cursor
O MCP não precisa estar dentro do outro repo. O Cursor só precisa do comando + cwd.
{
"mcpServers": {
"lgpd-mask": {
"command": "node",
"args": ["dist/index.js"],
"cwd": "<ABSOLUTE_PATH_TO_THIS_REPO>",
"env": {
"DATABASE_URL": "postgres://mcp:<LOCAL_PASSWORD>@localhost:5432/acme",
"PII_POLICY_PATH": "pii-policy.example.yaml",
"MASK_SALT": "<LOCAL_MASK_SALT>",
"ALLOWLIST_MODE": "public_all"
}
}
}
}Pré-requisitos: este repo com npm run build + DB no ar.
Banco não-Acme: ALLOWLIST_MODE=yaml + pii-policy.yaml local (não versionar secrets).
Tools
Tool | O que faz |
| Health: policy + DB |
| Tabelas na allowlist |
| Colunas + flag PII |
| yaml vs heurística (sem ler linhas) |
| N linhas já mascaradas |
| Pedido estruturado (joins/where) + máscara |
Publicar no GitHub (upload via web)
Importante: upload pela interface web não aplica .gitignore.
Se mandar uma pasta/ZIP inteira, .env e mcp.json locais podem vazar.
NÃO enviar
.env/.env.local.cursor/mcp.json(só o.example)pii-policy.yaml(só o.example)node_modules/dist/dumps, CSV real, exports
Pode enviar
src/,specs/,docs/,fixtures/acme/.env.example,.cursor/mcp.json.example,pii-policy.example.yamlpackage.json,package-lock.json, Dockerfiles, rules
Checklist: docs/UPLOAD.md.
Ignorado pelo git (quando usar git) | Versionado |
|
|
|
|
.env.example traz senha só de demo local (mcp / valor placeholder) — nunca produção.
Arquitetura
Cursor --stdio--> mcp (Node host ou Compose)
|
+--> policy YAML + mask engine
+--> Postgres (SELECT gerado pelo server)Specs
Contratos:
specs/Defaults:
docs/DECISIONS.mdRunbook:
docs/RUNBOOK.md
Autor
Kayque Prado — artefato 2026 + uso com legado/banco sob LGPD.
Available Tools
6 toolsclassify_piiB
Classify columns as PII using YAML policy and heuristics (no row data).
Inputs: table (required), columns.
describe_schemaB
Describe columns for an allowlisted table, with PII flags from policy/heuristics.
Inputs: table (required), schema.
list_tablesB
List allowlisted tables in the connected database.
Inputs: schema.
pingB
Health check: policy + DB connectivity.
Inputs: message.
query_maskedC
Run a structured SELECT (no raw SQL) with joins/where; PII columns are masked.
Inputs: from (required), columns (required), joins, limit, +2 more.
sample_safeB
Return up to N rows from a table with PII columns masked.
Inputs: table (required), limit.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Most tools have distinct roles: listing tables, describing schema, classifying PII, sampling masked rows, structured masked queries, and health checks. However, describe_schema already surfaces PII flags while classify_pii separately classifies PII, and sample_safe versus query_masked both return masked row data, creating mild overlap in when to choose each.
Five of six tools follow a clean verb-first snake_case pattern (list_tables, describe_schema, classify_pii, sample_safe, query_masked). The bare 'ping' deviates from the verb_noun convention but is a conventional health-check name and does not cause confusion.
Six tools is well-scoped for a read-only, PII-masking database access server. Each tool covers a distinct part of the workflow: discovery, schema inspection, PII classification, safe sampling, masked querying, and connectivity checking.
The surface covers the core lifecycle for safe database exploration: listing tables, describing schema, classifying PII, sampling rows, filtering/joining via structured SELECT, and health checks. Minor gaps remain around aggregates/counts or pagination helpers, but the main masked-query workflow is complete and write operations are intentionally excluded.
Related MCP Connectors
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
Guard AI agents' PostgreSQL/MySQL access via MCP: SQL audit, auth, masking, write approval
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Deterministic safety, correctness & cost gate that vets Postgres SQL before your AI agent runs it.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA PostgreSQL MCP server that automatically detects and obfuscates personally identifiable information (PII) in query results using column-name heuristics and NLP analysis. It enables AI agents to interact securely with databases by masking sensitive data by default while allowing selective unmasking under user control.4-
- AlicenseNot gradedqualityDmaintenanceProvides read-only access to PostgreSQL databases via MCP, enforcing least-privilege roles, row-level security, masked views, and SQL AST guardrails to prevent data leakage and unauthorized operations, enabling AI agents to safely query sensitive production data.MIT
- AlicenseNot gradedqualityCmaintenanceEnables read-only, SELECT-only querying of any Postgres database through MCP-compatible clients like Claude, with schema introspection and guarded SQL execution.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to query Postgres, BigQuery and DuckDB read-only through policy-checked SQL, with AST-based guards that refuse writes and dangerous functions, column masking on the way out, and an audit log of every query. Also exposes schema browsing and query-planning tools so agents can see allowed tables, columns and costs before running anything.MIT