Skip to main content
Glama
lgpd-mask-mcp

lgpd-mask-mcp

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:

  1. Recebe pedidos do agent (sample_safe, query_masked, …)

  2. Consulta Postgres só com SELECT que ele mesmo monta (sem SQL livre do agent)

  3. Aplica a policy YAML (máscara)

  4. 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 mascaradas

Related 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)

  1. Copie .cursor/mcp.json.example → .cursor/mcp.json.

  2. Troque <ABSOLUTE_PATH_TO_THIS_REPO> pelo path local desta pasta.

  3. No modo host, preencha <LOCAL_PASSWORD> / <LOCAL_MASK_SALT> (mesmos valores do seu .env).

  4. PII_POLICY_PATH pode ser relativo ao cwd (ex.: pii-policy.example.yaml).

  5. Settings → MCP → lgpd-mask verde → 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

ping

Health: policy + DB

list_tables

Tabelas na allowlist

describe_schema

Colunas + flag PII

classify_pii

yaml vs heurística (sem ler linhas)

sample_safe

N linhas já mascaradas

query_masked

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.yaml

  • package.json, package-lock.json, Dockerfiles, rules

Checklist: docs/UPLOAD.md.

Ignorado pelo git (quando usar git)

Versionado

.env, .cursor/mcp.json

.env.example, .cursor/mcp.json.example

pii-policy.yaml, node_modules/, dist/

src/, fixtures sintéticas

.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

Autor

Kayque Prado — artefato 2026 + uso com legado/banco sob LGPD.

Available Tools

6 tools
classify_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

    A3.5/5.0

    Scored across 6 tools

    Disambiguation4/5

    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.

    Naming Consistency4/5

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      A 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
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides 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
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables read-only, SELECT-only querying of any Postgres database through MCP-compatible clients like Claude, with schema introspection and guarded SQL execution.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables 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