Skip to main content
Glama
@guardbee/mcp-db-gateway

@guardbee/mcp-db-gateway

Official
by GuardBee

@guardbee/mcp-db-gateway

npm version npm downloads License: MIT Smithery

KVKK / GDPR uyumlu MCP (Model Context Protocol) sunucusu — LLM ile veritabanı arasına güvenlik katmanı ekler.

Claude veya başka bir LLM, veritabanınızı doğrudan sorgulamak yerine bu gateway üzerinden geçer. Hassas alanlar otomatik olarak maskelenir, tablo erişimleri rol bazlı kontrol edilir, her sorgu audit log'a yazılır.

Claude ──► MCP Gateway ──► Veritabanı
              │
              ├─ PII maskeleme   (tcKimlik → [REDACTED])
              ├─ Rol kontrolü    (ai-agent sadece products tablosuna erişir)
              ├─ Rate limiting   (dakikada max 100 sorgu)
              └─ Audit log       (her sorgu kayıt altına alınır)

Özellikler

  • PII Maskeleme — TC kimlik no, IBAN, e-posta, telefon, şifre hash vb. otomatik maskelenir

  • Rol Bazlı Erişim (RBAC) — Her rol için tablo beyaz/kara listesi ve alan kuralları

  • Rate Limiting — Global ve tablo bazlı istek penceresi

  • Audit Log — Console, dosya veya HTTP webhook'a yazılabilir

  • Prisma Adaptörü — Mevcut PrismaClient'ı doğrudan bağlayın

  • 61 unit test — Masker, pipeline, RBAC, rate limiter ve Prisma adaptörü kapsanmış


Related MCP server: MCPBridge

Hızlı Başlangıç

1. Smithery ile Tek Tıkla Bağla

Smithery üzerinden Claude Desktop'a tek tıkla ekleyebilirsiniz.

2. Global Kurulum ile Claude Desktop'a Bağla

npm install -g @guardbee/mcp-db-gateway

~/Library/Application Support/Claude/claude_desktop_config.json dosyasına ekleyin (macOS):

{
  "mcpServers": {
    "guardbee-db-gateway": {
      "command": "guardbee-gateway",
      "env": {
        "DATABASE_URL": "postgresql://user:pass@localhost:5432/mydb"
      }
    }
  }
}

Windows: %APPDATA%\Claude\claude_desktop_config.json Linux: ~/.config/Claude/claude_desktop_config.json

Claude Desktop'ı yeniden başlatın. Demo veritabanı otomatik yüklenir, PII maskeleme aktif olur.

3. Projede Kullan (Prisma)

npm install @guardbee/mcp-db-gateway
import { PrismaClient } from "@prisma/client";
import { createServer, createPrismaAdapter } from "@guardbee/mcp-db-gateway";

const prisma = new PrismaClient();

const server = createServer(
  {
    audit: { enabled: true, sink: "file", filePath: "./audit.jsonl" },
  },
  createPrismaAdapter(prisma)
);

MCP Tools

Gateway aşağıdaki 4 tool'u Claude'a sunar:

Tool

Açıklama

query_table

Tablodan satır sorgula (PII otomatik maskelenir)

list_tables

Erişilebilir tabloları listele (rol kısıtlamaları uygulanır)

describe_table

Tablo şeması ve maskeleme politikasını göster

gateway_status

Aktif config, roller ve rate limit durumunu göster


Yapılandırma

createServer({
  // PII alan kuralları (ilk eşleşen uygulanır)
  fieldRules: [
    { field: "tcKimlik",     strategy: "redact" }, // [REDACTED]
    { field: "iban",         strategy: "mask"   }, // TR32***890
    { field: "email",        strategy: "mask"   }, // ah***@example.com
    { field: "passwordHash", strategy: "redact" },
    { field: "*Token*",      strategy: "redact" }, // glob pattern
  ],

  // Tablo erişim kuralları
  tableRules: [
    { table: "audit_logs", access: "deny"  },
    { table: "users",      access: "allow", maxRows: 25 },
  ],

  // Varsayılan maksimum satır
  defaultMaxRows: 50,

  // Rate limiting
  rateLimit: {
    enabled: true,
    windowMs: 60_000,          // 1 dakika
    maxRequests: 100,           // global limit
    maxRequestsPerTable: 20,    // tablo başına
  },

  // Audit log
  audit: {
    enabled: true,
    sink: "file",              // "console" | "file" | "http"
    filePath: "./audit.jsonl",
    // webhookUrl: "https://..."  (sink: "http" için)
  },

  // Roller
  roles: [
    {
      name: "ai-agent",
      allowTables: ["products", "orders"],  // sadece bu tablolar
      maxRows: 10,
    },
    {
      name: "analyst",
      denyTables: ["audit_logs"],           // bu tablo engellenir
      fieldRules: [
        { field: "email", strategy: "allow" }, // e-posta maskesiz
      ],
    },
  ],

  // Aktif rol (GATEWAY_ROLE env var ile de ayarlanabilir)
  activeRole: "ai-agent",
});

Maskeleme Stratejileri

Strateji

Açıklama

Örnek

redact

Alan tamamen silinir

[REDACTED]

mask

Değerin ortası yıldızlanır

ah***@example.com / 530***67

hash

SHA-256 (ilk 16 karakter)

a665a45920422f9d

allow

Olduğu gibi geçer

ahmet@example.com

Glob pattern desteği: *Password*, *Token*, *Secret*


Rol Bazlı Erişim (RBAC)

Rol, sunucu başlatılırken GATEWAY_ROLE env var'ı veya config.activeRole ile belirlenir. Her Claude Desktop profili veya deployment farklı rol ile çalışabilir.

GATEWAY_ROLE=analyst node dist/cli.js

Kural önceliği (yüksekten düşüğe):

  1. Global tableRules deny

  2. Rol denyTables

  3. Rol allowTables (whitelist — ayarlanmışsa tablo bu listede olmalı)

  4. Rol fieldRules → global fieldRules


Prisma Adaptörü

PrismaClient'ı doğrudan geçirin — tablo adı → model eşleştirmesi otomatik yapılır:

Sorgu tablosu

Prisma modeli

"users"

prisma.user

"audit_logs"

prisma.auditLog

"orders"

prisma.order

"orderItems"

prisma.orderItem


Geliştirme

npm run dev          # tsx ile geliştirme modu
npm run build        # TypeScript derleme
npm test             # 61 unit test
npm run test:watch   # İzleme modu
npm run type-check   # Sadece tip kontrolü

Lisans

MIT — GuardBee

Available Tools

4 tools
describe_tableA

Get the column names and gateway masking policy for a table — helps the LLM understand what data it can access.

Inputs: table (required).

gateway_statusA

Show the active gateway configuration: field masking rules, table policies, and audit settings.

Inputs: no named parameters.

list_tablesA

List all available database tables. Tables marked as 'deny' in gateway policy are omitted.

Inputs: no named parameters.

query_tableA

Query rows from a database table with optional filters. All results pass through the KVKK/GDPR gateway — sensitive fields are automatically masked.

Inputs: table (required), limit, filter.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool addresses a distinct concern: retrieving data, enumerating available tables, inspecting one table's schema/policy, and viewing global gateway configuration. There is no meaningful overlap that would cause an agent to select the wrong tool.

    Naming Consistency4/5

    query_table, list_tables, and describe_table follow a clear verb_noun pattern and all names use snake_case. The main deviation is 'gateway_status', which is a noun phrase rather than a verb_noun action, but the inconsistency is minor and the naming remains predictable.

    Tool Count5/5

    The four tools are well-scoped for a read-only database gateway. list_tables and describe_table provide discovery, query_table provides data access, and gateway_status provides configuration awareness, so each tool earns its place without redundancy.

    Completeness5/5

    For the stated domain—controlled, masked access to database tables—the surface covers discovery, schema detail, querying, and policy context with no obvious dead ends. Write operations are absent, but the tool descriptions consistently indicate this is a read/visibility gateway rather than a full CRUD server.

    Maintenance

    ActivityStale
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      F
      maintenance
      A governed SQL gateway that exposes typed tools to AI agents, compiling safe read-only queries from a semantic layer while blocking PII before execution, supporting SQL Server, Postgres, and SQLite.
      9
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Connects AI assistants to PostgreSQL databases with production-grade safety features including query validation, guarded writes, rate limiting, and audit logging.
      3
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to query PostgreSQL databases securely with read-only defaults, PII masking, rate limiting, and human-approved, expiring mutation tokens.
      9
      1
      Apache 2.0
    • 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