MCP Secure Gateway
Provides read-only access to a local SQLite database (a sample e-commerce DB), letting agents introspect schemas, run validated SELECT/UNION queries with clamped row limits, and view query plans via EXPLAIN QUERY PLAN, while blocking DDL/DML and masking PII in returned rows.
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.
🛡️ MCP Secure Gateway
Zero-Trust Tool Server for AI Agents & LLM Clients (File · Database · Web)
Connecting AI agents (Claude Desktop, Cursor IDE) to internal business data carries severe risks: accidental database mutation, credential exposure, PII leaks into LLM prompts, and unbounded resource consumption.
MCP Secure Gateway is an enterprise-grade Model Context Protocol (MCP) tool server implementing the July 2026 Stateless Streamable HTTP specification alongside local Stdio IPC. It enforces host-level, deterministic zero-trust guardrails across filesystem, database, and outbound web boundaries.
Architecture & Zero-Trust Defense Boundaries
flowchart TD
Client["Client Layer\nClaude Desktop / Cursor IDE"]
subgraph Gateway["Host Security Boundary (FastMCP 4.x)"]
Transport["Transport Layer\nStdio IPC / Streamable HTTP (:8000/mcp)"]
Dispatcher["Closed Enum Tool Dispatcher\nFail-closed on unmapped tools"]
Audit["Structured Audit Stream\nstructlog JSON + correlation ID"]
end
subgraph Defenses["Deterministic Guardrails"]
PathGuard["TOCTOU-Safe Path Sandbox\nO_NOFOLLOW · is_relative_to · 1 MiB Cap"]
ASTGuard["sqlglot AST SQL Validator\nStrict SELECT/UNION · Clamped LIMIT 100"]
URLGuard["SSRF URL Guard\nMetadata & Loopback Block"]
PIIMask["PII Redaction Engine\nEmail · Phone · SSN · Card Masking"]
DBDriver["Read-Only SQLite Engine\nmode=ro URI · Opcode Execution Timeout"]
end
subgraph Data["Protected Resources"]
FS[("Documents Directory\nsample_data/documents/")]
DB[("E-Commerce SQLite\necommerce.db")]
Web["Outbound Public Web"]
end
Client --> Transport --> Dispatcher --> Audit
Dispatcher --> PathGuard --> FS
Dispatcher --> ASTGuard --> DBDriver --> DB
DB --> PIIMask
Dispatcher --> URLGuard --> WebRelated MCP server: mcp-gateway
Host-Enforced Security Invariants
Security Invariant | Defensive Implementation | OWASP LLM Mapping |
Zero Database Mutation |
| LLM01 / LLM02 |
Path Sandboxing | Canonical resolution, | LLM10 |
Sensitive File Immunity | Blacklist denying | LLM06 / LLM10 |
Autonomous PII Masking | Heuristic column scanner + regex scrubbing for emails, phone numbers, and SSNs | LLM06 |
SSRF Prevention | Pre-fetch URL validation blocking AWS/GCP cloud metadata ( | LLM10 |
Query DoS Mitigation | SQLite opcode progress handler aborting queries exceeding 2.0s timeout ceiling | LLM04 |
Payload Clamping | 1 MiB max file inspection, 100-row SQL limit, 64 KB response byte ceiling | LLM04 |
Fail-Closed Dispatch | Pydantic v2 | LLM07 / LLM08 |
7 Standard MCP Tools
list_directory(path: str = "."): List sandboxed directory entries with file metadata (blacklisted files hidden).read_file(path: str): Read text content of sandboxed files with automated PII masking.search_files(query: str, path: str = "."): ReDoS-immune literal substring search across directory files.describe_schema(): Introspect database tables and columns with automated sensitivity flags.query_database(sql: str): Validate, clamp, execute read-only SQL, and mask returned PII.explain_query(sql: str): Return query execution plan (EXPLAIN QUERY PLAN).fetch_url(url: str): Retrieve outbound web content with SSRF blocking and payload caps.
60-Second Quick Start
1. Clone & Install
git clone https://github.com/pine-tree111/mcp-secure-gateway.git
cd mcp-secure-gateway
uv sync --all-extras
make install-hooks # Install pre-push Git hook2. Seed Sample Database
make seed # Seed sample e-commerce SQLite database3. Quality Verification
make test # pytest with 80%+ branch coverage
make lint # ruff check + mypy --strict
make pre-push # run all 11 pre-push quality gates4. Run the Server
Option A: Local Process (Stdio or HTTP)
make run # Start local server (python -m app.server)Option B: Hardened Docker Container (Loopback 127.0.0.1:8000)
make docker-build # Build multi-stage hardened image
make docker-up # Start container in background
curl -s http://127.0.0.1:8000/health
make docker-down # Stop container5. Connect Claude Desktop
See SETUP.md for copy-paste client configuration (supports local Stdio and Docker HTTP modes).
Developer Commands (Makefile)
Command | Action |
| Run pytest with 80%+ branch coverage enforcement |
| Run Ruff linter and Mypy strict type checking |
| Auto-format Python source files with Ruff |
| Dependency CVE vulnerability scan via pip-audit |
| Run full 11-gate quality audit script |
| Seed local e-commerce SQLite sample database |
| Start server locally ( |
| Install pre-push audit script as Git hook |
| Build production multi-stage Docker container |
| Run container in background ( |
| Stop and tear down Docker container |
| Remove pytest, mypy, and ruff cache directories |
License
MIT License — Copyright (c) 2026 Shafiul Ismam. See LICENSE for details.
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
Safety tools for AI agents: safe page reader, prompt-injection, secrets, PII and MCP server scans
Find, vet, and run MCP tools through a secure audited gateway with prompt-injection risk scoring
Security & DLP proxy for MCP: tool-poisoning scans, PII redaction on tool args/results. Beta.
Deterministic runtime safety for AI agents: scan PII, gate tool actions, verify LLM output.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to safely explore and diagnose remote servers by providing a read-only sandbox with controlled access to files, logs, Docker, and databases. It exposes MCP tools that allow natural-language investigation and direct command execution without write permissions.4-
- AlicenseNot gradedqualityCmaintenanceEnables a language model to safely query internal services through a closed set of read-only, schema-validated tools, with full auditing and refusal logging.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to inspect schemas, walk Delta table history, run read-only DuckDB queries, and check data-quality and job-run status safely.MIT
- AlicenseNot gradedqualityCmaintenanceEnables 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.1MIT