Skip to main content
Glama

A security gateway that lets AI agents use enterprise systems through the Model Context Protocol — with access control, human approval, audit logging and AI-based threat detection on every tool call.

Status CI Python MCP License

English · Türkçe


Overview

Companies are connecting LLM agents to CRM and ERP systems. In practice an agent often runs on a single, broadly privileged service account, which means:

  • there is no record of which agent did what, on whose behalf,

  • critical actions such as deleting records or bulk exports have no approval step,

  • an agent manipulated by content it read (prompt injection) goes unnoticed.

The Model Context Protocol (MCP) standardises how agents reach tools, and recent research documents serious security gaps in its ecosystem. Vendors now ship their own MCP servers — Salesforce's hosted MCP servers became generally available in April 2026 and Salesforce itself recommends an MCP gateway for central governance across vendors. This project builds that gateway: a zero-trust policy enforcement point between agents and enterprise systems.

Design principle: the agent is not trusted, even when its owner is. An agent that read a poisoned email behaves like an insider controlled by the attacker.

Related MCP server: agent-security-gateway

Architecture

Every tool call passes six steps: receive → authenticate → authorise → approve if critical → call the enterprise system → screen the returned free text before it reaches the agent. Every decision is written to an append-only audit log that feeds the anomaly detector.

Overview

Approval queue

Overview

Approvals

Audit log

Policies

Audit log

Policies

See it run

Condensed output of scripts/demo_client.py against a local gateway: an allowed call, three blocked attacks, an RBAC denial, one critical action approved and one rejected by an administrator, and the per agent rate limit. Injection screening needs Gözcü running next to the gateway.

Admin dashboard (design prototype)

A design prototype of the planned admin dashboard. The approval API, alerts API and audit log behind it already work; the screen itself is not built yet and the numbers are sample data.

Components

Component

Description

Gateway core

MCP server (Streamable HTTP) — the single entry point for agents; routes tool calls to connectors

Access control

Signed tokens binding agent and user, role-based access control per tool and operation, least privilege — NIST SP 800-207 zero-trust

Human approval

Critical actions wait in an approval queue until an administrator decides; requests expire automatically

Audit log

Every call recorded: agent, user, tool, parameters (masked), decisions, result, latency — append-only

Injection detection

Free-text tool output is screened by the Gözcü, my Turkish and English prompt injection detector, before it reaches the agent

Anomaly detection (planned)

Learns normal behaviour per agent; Isolation Forest compared with an LSTM sequence model

Connectors

Mock ERP and mail connectors for reproducible tests; Salesforce Developer Edition (REST API) is next

Admin dashboard (planned)

Roles and policies, audit log, approval queue, alerts

Quick start

Implemented so far: MCP endpoint, Ed25519 agent tokens, RBAC with effective permissions (agent role ∩ user roles), per-agent rate limit, approval flow for critical actions, prompt injection screening of tool output (with the companion detector), append-only audit log, mock ERP and mail connectors.

python -m venv .venv && .venv\Scripts\activate     # Linux/macOS: source .venv/bin/activate
pip install -r requirements.txt
pytest                          # unit + integration tests
python scripts/gen_keys.py      # once: signing keys + admin token in keys/ (never committed)
docker run --rm -p 8000:8000 pidetect          # optional: detector from Gözcü
$env:GATEWAY_DETECTOR_URL = "http://127.0.0.1:8000"   # PowerShell; Linux/macOS: export ...
python -m gateway               # gateway on http://127.0.0.1:8080/mcp
python scripts/demo_client.py   # second terminal: allowed calls, approvals, blocked attacks
python scripts/approvals.py     # administrator: pending approvals; `approve <id>` / `reject <id>`

Policies: config/policies.toml · decisions: D-005 – D-008

Security analysis

The threat model covers 5 trust boundaries, 4 attacker types and 18 STRIDE threats, each mapped to a requirement and to the penetration test that will check it. OWASP Top 10 for LLM Applications coverage: LLM01 Prompt Injection, LLM02 Sensitive Information Disclosure, LLM05 Improper Output Handling, LLM06 Excessive Agency, LLM10 Unbounded Consumption.

Evaluation plan

Test

Method

Target

Penetration

Token forgery, RBAC bypass, approval replay, prompt-injection suite, OWASP ZAP

Every STRIDE threat checked; attack success rate drops sharply vs. direct connection

Latency

Overhead per tool call

< 100 ms on average

Load

50 concurrent agent sessions (k6 / Locust)

Stable operation

Anomaly detection

Replayed normal and abnormal call sequences

Precision / recall, Isolation Forest vs. LSTM

Usability

2–3 users on the approval flow and dashboard

Task completion, feedback

Documentation

Topic

Document

Requirements (30 functional, 12 non-functional, 9 use cases)

requirements.md

Threat model — STRIDE, OWASP LLM mapping

threat_model.md

MCP endpoint and admin API

api_design.md

Traceability matrix

traceability.md

Diagrams (architecture, DFD, ER, UML, flowcharts, wireframes)

docs/diagrams

Decision log · References

decisions.md · references.md

Project structure

kalkan/
├── gateway/         MCP server, authentication, access control, approval, screening, audit
├── connectors/      Mock ERP and mail connectors (Salesforce next)
├── anomaly/         Anomaly detection models (planned)
├── dashboard/       Admin web interface (planned)
├── tests/           128 unit and integration tests
└── docs/            Analysis, diagrams, decisions

Status

Working now: MCP endpoint (initialize, tools/list, tools/call), Ed25519 agent tokens, RBAC with effective permissions and per agent rate limit, approval flow for critical actions with SSE progress and an admin API, prompt injection screening of tool output through Gözcü, append only audit log, mock ERP and mail connectors, CI with Ruff and pytest.

Next: Salesforce connector, persistent approval queue on PostgreSQL, anomaly detection (Isolation Forest compared with an LSTM), admin dashboard, penetration and load tests.

Tech stack

Built with: Python 3.13 · FastAPI · MCP (Streamable HTTP, checked against the official SDK client) · Ed25519 signed JWT (PyJWT, cryptography) · SQLite · pytest · Ruff · GitHub Actions

Planned: PostgreSQL · scikit-learn · PyTorch · React · TypeScript · Docker Compose · k6 / Locust

Author

Numan Ak · GitHub · LinkedIn

License

MIT

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Governed MCP gateway that lets AI agents call tools with policy enforcement, prompt-injection screening, a kill-switch, and tamper-evident signed audit logs.
      Apache 2.0
    • F
      license
      Not graded
      quality
      D
      maintenance
      MCP server that provides a security gateway for AI agents, enforcing allow/confirm/deny policies on tool calls and requiring human approval for risky operations, with full audit logging.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      A gateway MCP server that lets agents reach any upstream MCP server through one endpoint while enforcing policy rules, holding risky tool calls for human approval, containing prompt-injected sessions, and logging every call.
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      A fail-closed MCP gateway that sits between an AI agent and any real MCP server, enforcing a human-signed Ed25519 policy with tool allowlists, field checks, rate limits, rolling-sum human approval, secret redaction and a hash-chained audit log. It lets operators safely grant agents access to files, email and business systems while denying anything the signed policy does not explicitly allow, and ships with a prompt injection benchmark.
      Apache 2.0