Skip to main content
Glama
emory-usc

Governor SQL MCP

by emory-usc

Governor SQL MCP

CI

A governed, read-only MCP server over SQL. Stand it up from nothing, point an AI agent at it, and the agent can only ever see what the caller is allowed to see. Three things matter when you expose a database to a model, and all three are enforced by construction:

  • Read-only by construction. Exactly three tools — describe_entities, read_records, aggregate_records — and no write path exists anywhere in the code. Create, update, delete, and execute are absent, not merely denied.

  • The views are the security boundary. Base tables are never exposed. The model can only see the columns a published view deliberately includes.

  • Per-user row-level security, fail-closed. A caller's claim resolves to a predicate. An unresolved or absent claim sees zero rows — never everything.

The engine is SQLite (standard library), so it runs anywhere with no database server and no credentials. The security model is documented in SQL terms (sql/03_rls.sql) and maps directly onto SQL Server SESSION_CONTEXT predicates in a real deployment.

Quick start

pip install -e ".[mcp]"        # core runs with no dependencies; mcp extra adds the server
governed-sql verify            # row-level security demo (admin / manager / anonymous)
governed-sql run               # start the MCP server (streamable-http on :8000)

Related MCP server: governed-mcp

Row-level security

Caller claim

Rows visible

admin

all of them

manager:mgr-01

only that manager's customers

(no claim)

zero — fail closed

Using from LangChain / LangGraph

The server speaks standard MCP, so any MCP-capable client can consume it. LangChain exposes it through langchain-mcp-adapters:

from langchain_mcp_adapters.client import MultiServerMCPClient

client = MultiServerMCPClient({
    "governed-sql": {
        "url": "http://localhost:8000/mcp",
        "transport": "streamable_http",
    }
})
tools = await client.get_tools()
# describe_entities / read_records / aggregate_records are now typed
# LangChain tools, each bound by the caller's row-level security.

Deployment

  • Dockerfile — multi-stage uv build, slim non-root runtime, healthcheck.

  • infra/main.bicep — Container Apps with scale-to-zero (0–2 replicas), Log Analytics + App Insights, liveness probe. Compiles clean (az bicep build).

  • .github/workflows/deploy.yml — GHCR build/push, Trivy scan (blocking on CRITICAL/HIGH), OIDC Bicep deploy on version tags.

Security posture

See SECURITY.md. The short version: read-only surface, fail-closed RLS, honest withheld_count disclosure, synthetic data, no credentials in the repo or image.

Structure

sql/                    schema, published views, documented RLS policy
src/governed_sql_mcp/   db / query / server / cli
infra/main.bicep        Container Apps deployment
tests/                  pytest suite (RLS, masking, read-only surface)

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to safely query and explore SQLite databases through read-only, guard-protected tools that block writes, sensitive table access, and runaway queries.
    1
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to query a read-only data surface through typed tools, enforcing caller-specific row access, field masking, and withheld-row disclosure so they can retrieve entitled information without writes or silent data leakage.
    MIT
  • A
    license
    Not graded
    quality
    B
    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
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to run read-only SQL against SQLite or MySQL databases through MCP tools for listing tables, describing schemas, and querying data. Wraps every call in guardrails such as statement allow-listing, row caps, query timeouts, PII masking, and audit logging.
    1
    MIT