AegisQuery
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.
AegisQuery — a governed analytics MCP server
A production-grade Model Context Protocol server that gives LLM agents safe, read-only access to an analytics data warehouse — mediated by a layered safety pipeline (AST validation, column/row governance, PII masking, cost limits, result truncation, audit) over both stdio and an OAuth-secured Streamable HTTP transport.
Built in TypeScript against the official @modelcontextprotocol/sdk, targeting MCP spec revision 2025-11-25 and designed stateless-first for the direction the protocol is heading.
Its differentiator is the security story: it reproduces the class of bug that defeated Anthropic's own reference Postgres MCP server — a stacked-statement injection (COMMIT; DROP SCHEMA public CASCADE;) that bypassed a naive READ ONLY transaction — and then defeats it with structural AST validation plus defense-in-depth. See docs/ for the full SRS / HLD / LLD / Design documents.
🔴 Live demo
web-beta-rosy-0ovpsr1q8m.vercel.app — a coffee-themed web console (light + dark) that runs the same governance engine on Vercel serverless. Switch roles (analyst / regional / finance / admin) and watch the same query behave differently: PII masked for an analyst but raw for an admin, cost denied for an analyst but visible to finance, and adversarial SQL rejected on the spot. Source in web/.
Related MCP server: safedb-mcp
Quickstart
npm install
npm run seed # build a local SQLite warehouse (deterministic synthetic data)
npm run smoke # end-to-end verification incl. an adversarial SQL corpus
npm run eval # golden-task scorecard vs an independent oracle
# run the server
npm run build && npm start # stdio (local, env-key auth)
npm start -- --http # Streamable HTTP (remote, bearer/OAuth auth)Point an MCP client (e.g. Claude Desktop, MCP Inspector) at node dist/index.js, with AEGIS_API_KEY=devkey in the environment.
What it exposes
Tools (workflow-oriented, not endpoint mirrors):
Tool | Purpose |
| Rank tables/columns relevant to a natural-language question (with access levels). |
| Curated metric — gross/net revenue by day/week/month. No model-authored SQL. |
| Validate a query and return plan + cost + violations without executing. |
| Governed ad-hoc read-only |
Resources — the warehouse schema (aegis://catalog, aegis://schema/{table}), annotated per-policy with allow / mask / deny.
Prompts — analyze_question, steering agents to discover schema, prefer curated metrics, and treat results as data.
The safety pipeline
Every query passes the same ordered stages before a single row is returned:
parse (AST) → read-only guard → reference extraction → table/column allowlist
→ PII masking → row-policy injection → cost guard (LIMIT/scan budget)
→ execute (read-only role) → truncate to token budget → auditAST read-only guard — only a single
SELECT/WITH/UNIONpasses; multiple statements parse to an array and are rejected. This structurally prevents the stacked-statement bypass.Defense in depth — the SQLite connection is opened read-only, so even a parser gap cannot mutate data.
Governance — deny-by-default table/column allowlists; PII columns masked (
substr(x,1,2)||'***') and refused if used outside the projection; restricted columns (cost, url) require an elevated role.Row-level policy — mandatory
WHEREpredicates injected from principal attributes (e.g. aregional_analystis scoped to their region).Cost & context — planner-based scan estimate rejects runaway queries; every result is
LIMIT-capped and truncated to a ~25k-token budget.Audit — one structured JSON record per invocation (principal, raw + rewritten SQL, decision, rows, ms).
Auth
stdio — credentials from the environment (
AEGIS_API_KEY), per the spec (stdio servers should not use OAuth).HTTP — bearer token validated and mapped to a role/policy; unauthenticated requests get
401with RFC 9728 Protected Resource Metadata. Stateless (no session id) so it scales behind a round-robin load balancer.
Key map format (AEGIS_API_KEYS): key:role[:attr=val;attr=val], e.g. devkey:analyst, eu-key:regional_analyst:region=EU, admin-key:admin.
Configuration
Env var | Default | Meaning |
|
| Transport selection. |
|
| SQLite warehouse path. |
|
| Hard row cap (injected LIMIT). |
|
| Reject queries whose plan exceeds this. |
|
| Result truncation budget. |
|
| Principal key map. |
|
| HTTP bind port. |
Architecture
transports/{stdio,http} → server (McpServer) → tools ─┐
│ ├─ pipeline ─ sql/analyzer (AST)
auth (principal) │ policy (governance)
catalog (resources) │ db/adapter → sqlite
└─ auditThe warehouse sits behind a read-only ReadOnlyAdapter interface — SQLite locally, Postgres in production — so governance logic never touches a specific engine.
Learning-ordered roadmap
This repo is built as a learning vehicle; each milestone is independently demoable and teaches one MCP / AI-engineering competency.
M | Build | Learn |
M0 | stdio server + a tool | JSON-RPC lifecycle, tools/list·call |
M1 | read-only query + schema resources | resources vs tools, zod I/O, structured content |
M2 | reproduce the CVE → AST + read-only enforcement | why appsec applies; defense-in-depth |
M3 | allowlist, PII masking, row policy | data governance |
M4 | cost guard, truncation, pagination | context engineering, token economics |
M5 | curated metrics + catalog search | Anthropic tool-authoring principles |
M6 | audit log, error taxonomy | production ops/observability |
M7 | Streamable HTTP + OAuth 2.1, stateless | remote MCP, auth |
M8 | golden-task eval harness | eval — the top hiring signal |
Verification
npm run typecheck # strict TS, src + scripts
npm run smoke # 20 assertions incl. 9 adversarial rejections + integrity check
npm run eval # dev + held-out scorecard (accuracy, tokens, latency, errors)Documentation
Full design suite (generated, colorful .docx) in docs/: SRS, HLD, LLD, Design. Regenerate with npm run docs. All four are driven by a single source of truth in scripts/docgen/spec.ts.
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
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
The BigQuery remote MCP server is a fully managed service that uses the Model Context Protocol to connect AI applications and LLMs to BigQuery data sources. It provides secure, standardized tools for AI agents to list datasets and tables, retrieve schemas, generate and execute SQL queries through natural language, and analyze data—enabling direct access to enterprise analytics data without requiring manual SQL coding.
Scan prompts for injection attacks, redact PII, and audit LLM SDK usage from any MCP client
Related MCP Servers
- AlicenseBqualityDmaintenanceAn MCP server that bridges AI assistants with data warehouses through Cube.js to enable governed, natural language semantic analytics queries. It provides tools for metadata discovery and secure query execution while enforcing governance policies like PII blocking and access limits.3264 npm1MIT
- AlicenseAqualityCmaintenanceSecure MCP server for safe, read-only DB access by AI agents, with SQL guardrails, table allowlists, PII masking, and audit logs661 npm9MIT
- AlicenseNot gradedqualityCmaintenanceA governed MCP server enabling LLM agents to query BigQuery, inspect GCS, trigger Airflow DAGs, and run data-quality checks with built-in security guardrails like allow-lists, cost ceilings, and audit trails.1MIT
- AlicenseAqualityBmaintenanceA security-hardened Postgres MCP server that enables LLM agents to run safe, read-only SQL queries with enforcement via SQL-AST inspection and read-only transactions.1MIT