MCP Data Gateway
Integrates with Google Workspace as an identity provider, enabling the gateway to validate OAuth 2.1 tokens and match verified email addresses against organisational role allowlists for governed database access.
Integrates with Okta as an identity provider, enabling the gateway to validate OAuth 2.1 tokens and match verified email addresses against organisational role allowlists for governed database access.
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., "@MCP Data Gatewaywhat were our top 5 products by revenue last quarter?"
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.
MCP Data Gateway
A governed MCP server for organisational databases. An organisation connects a database, people authenticate through the organisation's own identity provider, and questions are answered under role-based limits with every decision logged.
Status: in progress. The policy model and SQL guard are implemented and tested. Identity, the MCP server, the audit store and the dashboard are next — see Roadmap.
The problem this is built around
Connecting a language model to a company database is easy. Every published analysis of MCP database incidents lands on the same cause: a tool that accepts free-form SQL against a connection with more privilege than the question needed. In one documented case an instruction hidden inside a support ticket caused an agent holding service-role credentials to read an entire table.
The usual mitigation — a read-only database user — is necessary and not sufficient. A read-only role still permits reading every row of every table it can see, which is precisely the exfiltration case.
So the interesting part of this project is not the connection. It is everything that has to refuse.
Related MCP server: Database Assistant MCP Server
Design
flowchart LR
C[MCP client] -->|OAuth 2.1 token| S[Gateway]
S -->|verify signature, audience, issuer| I[Organisation's IdP]
S --> P[Policy: email -> role]
P --> G[SQL guard]
G -->|refused + reason| A[(Audit store)]
G -->|approved, bounded| D[(Organisation database)]
D --> A
A --> W[Log dashboard]Identity is delegated. Under the MCP specification (revision 2026-07-28) a server is an OAuth 2.1 resource server: it validates tokens and never issues them. Each organisation points the gateway at its own provider — Google Workspace, Okta, Entra — and the gateway verifies the token's signature, issuer and audience, then matches the verified email against that organisation's allowlist. No password ever reaches this service, and no token is ever forwarded upstream.
Authorisation is an allowlist. A role names the tables it may read, optionally the columns, a row cap and a timeout. A denylist answers "what have we thought to forbid"; an allowlist answers "what have we decided to permit", and only the second holds when the thing on the other side is a model improvising queries.
Statements are parsed, not pattern-matched. The guard builds an abstract syntax tree and inspects it. Regular expressions over SQL are defeated by comments, nested sub-selects, unions and whitespace; an AST is defeated by none of those, because it describes what a statement does rather than how it is spelled.
What the guard refuses
Refused | Why it matters |
Anything that is not a single SELECT | Writes, DDL and multi-statement payloads never reach the database |
A write hidden inside a CTE |
|
| Writes a table while looking like a read |
A second statement after a comment | The classic injection shape |
Tables outside the role | Including via |
System catalogues |
|
Functions that leave the engine |
|
Columns the role may not read | Checked on qualified and unqualified references |
| It cannot be proven safe, so it is refused with an instruction to name the columns |
Anything it cannot prove safe is refused with a reason. A wrong refusal costs a confused user; a wrong approval costs a breach.
Approved statements are rewritten, not just approved: a missing limit is added and an oversized one lowered, so no query can return an unbounded result.
Run the tests
uv venv --python 3.12
uv pip install -e ".[dev]"
uv run pytest -qRoadmap
Policy model — organisations, roles, table and column rules
SQL guard — AST validation, scope enforcement, result bounding
Identity — JWT verification, audience and issuer binding, email allowlist
MCP server — Streamable HTTP, protected resource metadata, curated tools
Audit store — every decision with its reason, PII redacted
Log dashboard — who asked what, under which role, allowed or denied
Demo organisation with seeded synthetic data
Licence
MIT. No real data, credentials or customer information belongs in this repository.
This server cannot be deployed
Maintenance
Related MCP Connectors
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
- BasedashOAuthcom.basedash
Governed BI MCP. Ask questions of live company data and list workspace sources via OAuth.
Paid remote MCP for governed database query review, SQL simulation, approvals, and audits.
Related MCP Servers
- AlicenseAqualityDmaintenanceGive your AI agent safe, plain-English access to any database via MCP. Ask questions in natural language, get SQL queries and results, run read-only queries, and set up scheduled alerts.934 npm1MIT
- FlicenseAqualityDmaintenanceEnables read-only exploration and querying of PostgreSQL or MySQL databases via MCP, with schema discovery, safe SQL validation, natural language to SQL conversion, and CSV export.111-
- AlicenseNot gradedqualityAmaintenanceEnables secure, controlled access to existing relational databases via MCP, with API key authorization, read/write permissions, table-level allow/deny lists, SQL validation, rate limiting, audit logging, and a web management console. Supports PostgreSQL, MySQL, SQLite, SQL Server, and Oracle.20 npm1MIT
- AlicenseNot gradedqualityBmaintenanceProvides read-only, guarded access to business databases via MCP. Enables natural language querying with built-in security barriers like table allowlists, PII masking, and audit logging.MIT