SCML MCP server
Commit Oct 26, 2026Secures agentic AI systems by enforcing least-agency policies, scanning for prompt injection, and gating tool calls through a middleware layer.
Also known as ravindu57/SCML
- Stars
- 0
- Tools
- 7
- Downloads, 30 days
- —
- Latest version
- —
- Last commit
- Oct 26, 2026
- License
- Apache-2.0
What is SCML MCP?
SCML secures agentic AI systems by enforcing least-agency policies, scanning for prompt injection, and gating tool calls through a middleware layer. It exposes 7 tools, such as authorize_tool_call, scan_content, check_memory_write.
Summary generated from the project's README
About SCML MCP server
Securing agentic AI systems by enforcing least-agency policies and scanning for prompt injection is what SCML enables through a dedicated middleware layer. It acts as a trust-aware context mediation tool for LLM agents, RAG pipelines, and tool-calling systems, sitting between the agent and external integrations to prevent hijacked tool calls or poisoned memory. Developers can deploy it locally using Python or TypeScript SDKs, or connect it to MCP-compatible clients like Claude Desktop, Cursor, or Windsurf.
The server provides specific tools to manage security, including authorize_tool_call for policy enforcement, scan_content for detecting injections, and redact_output to strip PII and secrets. It also features check_memory_write to score integrity and get_audit_trail to replay decisions via a SHA-256 hash chain. Because it uses multi-tenant policy namespaces bound to API keys, it allows different organizations to maintain isolated security boundaries within a single instance.
What you can do with it
- 1Preventing prompt injection attacksAn AI client can use the scanner to detect malicious instructions within untrusted external content.
- 2Enforcing tool call authorizationDevelopers can gate tool execution by checking if an agent's requested action complies with established security policies.
- 3Protecting sensitive data in responsesThe system can automatically remove personally identifiable information and secrets from an agent's output.
- 4Auditing agent decision historySecurity teams can replay past session decisions using a tamper-evident hash chain for forensic analysis.
Written from the project's README. Every use case is checked against a quote from it.
SCML MCP tools 7
Detected from the READMEauthorize_tool_callscan_contentcheck_memory_writeredact_outputget_audit_trailget_policyhealth_check
Configuration
DATABASE_URLSCML_API_KEYSCML_URL
Automated checks
Ran Nov 14, 2026Full report →Not verified yet. A server needs a score of 80, no serious finding, and enough data for us to check. How checks work · What to fix for more points
- Source repository linked and reachableravindu57/scml is public and reachablegithub.com/ravindu57/scml ↗Pass
- Package names this repository as its sourceNot checked
- Build provenance (Sigstore attestation)Not checked
- Open source license (OSI)Apache-2.0spdx.org/licenses/Apache-2.0.html ↗Pass
- Commit or release in the last yearLast commit or release 2026-10-26github.com/ravindu57/scml ↗Pass
- OpenSSF ScorecardNot checked
- Package name not close to a popular packageNot checked
- No critical advisory in the package or its dependenciesNot checked
- No hidden instructions to the model7 tool descriptions and the README read; no override phrases, credential paths or hidden charactersPass
- Destructive tools are labelledNo tool named like delete, drop or execPass
- Remote endpoint answers the MCP handshakeNot checked
README
View on GitHub█▀▀ █▀▀ █▀█▀█ █
▀▀▓ ▓░ █ ▓ ▓░
▀▀▀ ▀▀▀ ▀ ▀ ▀▀▀
SCML — Securing Agentic AI at the Middleware Layer
Trust-aware context mediation for LLM agents, RAG pipelines, and tool-calling systems.
The Problem
┌─────────────────────────────────────────────────────────────────────┐
│ LLM agents call tools, read documents, store memories. │
│ Every integration is a new attack surface. │
│ │
│ • Poisoned memory → privilege escalation │
│ • Malicious tool out → agent hijacked, data exfiltrated │
│ • Prompt injection → agent instructions overridden │
│ │
│ Existing guardrails secure the MODEL. │
│ SCML secures the MIDDLEWARE. │
└─────────────────────────────────────────────────────────────────────┘
LLM agents call external tools, read untrusted documents, and make decisions with real-world consequences. Every integration is a new attack surface. Existing guardrails focus on the model layer. SCML sits one layer lower — the middleware between the agent and the world — where policy is enforced before any tool call is authorised, before any memory write is persisted, and before any outbound response leaves the process.
What SCML Does
SCML is a trust-aware context mediation middleware. Every data path passes through a pipeline that labels data, scans for injection, enforces declarative per-agent policy, redacts sensitive content, and logs every decision to a tamper-evident SHA-256 hash chain.
SCML Mediation Pipeline
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ Trust │──▶│ Injection│──▶│ Policy │──▶│ Memory │──▶│ Output │──▶│ Audit │
│ Label │ │ Scan │ │ Gate │ │ Check │ │ Redact │ │ Log │
└──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘
│ │ │ │ │ │
▼ ▼ ▼ ▼ ▼ ▼
Propagate Detect & Allow / Deny Quarantine Strip PII SHA-256
taint block inject per-agent & score & secrets hash chain
Side-effect operations fail closed: an unreachable mediator denies by default, never permits by silence.
Multi-Tenant Policy Namespaces
One SCML instance can serve many companies, each with its own policy document. The tenant is bound to the API key, never supplied by the client:
| Key format | Tenant | Principal |
|---|---|---|
sk-abc123 |
default (TRUST_MEDIATOR_DEFAULT_TENANT) |
fingerprint |
alice:sk-abc123 |
default |
alice |
acme@sk-abc123 |
acme |
fingerprint |
acme@ops:sk-abc123 |
acme |
ops |
CallerDepderives the tenant from the authenticated key; no request model accepts atenant_idfield, so a caller cannot claim another company's namespace by shaping the body.- Policy reads, writes, per-agent updates, version history and rollback are all
scoped to
caller.tenant— Acme's agents and versions never collide with Globex's, even for the sameagent_id. - A tenant that enrols no policy is deny-all (fail-closed at the tenant
boundary); only the
defaulttenant falls back to the gateway YAML. - Memory, audit replay, gRPC and rate limits are scoped the same way: a
record, quarantine entry or session written with Acme's key is invisible to
Globex's, admins included. Session ids are namespaced internally
(
acme::s1), so a client id may not contain::. - Pre-tenancy deployments are unchanged: an unqualified key resolves to the
defaulttenant, exactly as before.
Install
pip install trust-mediator # client SDK — 14 packages, ~32 MB
pip install "trust-mediator[server]" # run the mediator yourself
Python SDK
from scml import SCMLClient
scml = SCMLClient("http://localhost:8000", api_key="sk-...")
# Label and scan untrusted content
ctx = scml.mediate_context(session_id="s1", content=untrusted_document)
# Gate a tool call — untrusted arguments are denied, trusted ones pass
decision = scml.mediate_tool_call(
session_id="s1",
tool_name="send_email",
arguments={"to": ctx.parsed["recipient"]},
argument_trust_labels={"to": ctx.trust_label},
)
if not decision.allowed:
raise RuntimeError(decision.reason) # fail closed
TypeScript SDK (zero runtime deps)
const { SCML } = require('scml-client');
const scml = new SCML({ url: process.env.SCML_URL });
const ctx = await scml.mediateContext({ sessionId, content: untrustedDoc });
const d = await scml.mediateToolCall({
sessionId, tool: 'send_email',
arguments: { to: ctx.parsed?.recipient },
argumentTrustLabels: { to: ctx.trustLabel ?? 'untrusted_data' },
});
if (!d.allowed) throw new Error(d.reason);
MCP Server (Claude Desktop / Cursor / Windsurf)
SCML exposes its full security pipeline as MCP tools — any MCP-compatible client gets tool-call authorization, injection scanning, memory quarantine, and PII redaction with zero code changes.
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ LLM Client │──────▶│ SCML MCP │──────▶│ Your Tool │
│ (Claude, │ │ Server │ │ (API, DB, │
│ Cursor) │◀──────│ │◀──────│ file, etc) │
└──────────────┘ │ • authorize │ └──────────────┘
│ • scan │
│ • quarantine│
│ • redact │
└──────────────┘
Install
pip install trust-mediator mcp
Run
SCML_URL=http://localhost:8000 SCML_API_KEY=sk-your-key \
python -m trust_mediator.mcp.server
Claude Desktop config
Add to ~/.claude/claude_desktop_config.json:
{
"mcpServers": {
"scml": {
"command": "python",
"args": ["-m", "trust_mediator.mcp.server"],
"env": {
"SCML_URL": "http://localhost:8000",
"SCML_API_KEY": ""
}
}
}
}
Available MCP tools
| Tool | What it does |
|---|---|
authorize_tool_call |
Check if a tool call is allowed by policy |
scan_content |
Detect prompt injection in external content |
check_memory_write |
Score a memory write for integrity |
redact_output |
Strip PII and secrets from responses |
get_audit_trail |
Replay session decisions with hash chain |
get_policy |
Show active security policy |
health_check |
Verify SCML is running |
Benchmarks
SCML is evaluated on two published benchmarks (AgentDojo, InjecAgent) plus an in-house memory-poisoning corpus: 2,051 attacked cases in total (949 + 1,054 + 48). Every number below comes from a committed file in benchmarks/results/.
What is not met yet (PRD §14.2). On AgentDojo, SCML reaches 7.3% ASR (target < 5%), a 75% reduction (target ≥ 90%), and keeps 81% of benign utility (target ≥ 90%). Only 2 of AgentDojo's 17 attack types have been run. Memory-poisoning storage ASR is 20.8% (target < 10%). The injection scanner detects 0 of 1,054 InjecAgent attacks: least-agency tool policy is the defence, not detection.
InjecAgent — 1,054 third-party cases (ACL Findings 2024)
Ablation truth: Removing the scanner → 0.0% ASR. Removing tool policy → 100.0% ASR. Tool policy is the entire defence. The scanner detects 0 of 1,054 attacks.
AgentDojo — All Four Suites (949 attacked cases)
Tool-Output Sanitizer — Targeting the Slack Gap (FR-OR-03)
The slack gap (30.5% ASR) is caused by attacks delivered inside tool results that the model rewrites rather than copies. The deterministic ToolOutputSanitizer strips instruction framing before the agent reads them — no LLM call, no new dependencies.
Pilot only, a single task (output_sanitizer.md): on slack user_task_2 under important_instructions (5 injections), SCML ASR is 60% and SCML + --sanitize is 0%, with 5/5 tool results rewritten and no added utility cost.
The full slack
--sanitizesuite (21 tasks × 5 injections) has not been committed as a result, so no suite-level sanitizer number is claimed here.
Memory Poisoning (48 in-house cases)
Storage ASR 20.8% against a < 10% target: not met (memory_poisoning.md). Storage counts a poisoned record that was persisted; harm (below) counts whether the mediator would have let its goal through. Both are reported because either alone misleads.
Pessimistic harm total: 18.8% (9/48). The 22 control-bypass cases are inert because the mediator never reads agent memory to decide authorisation.
Quick Start
git clone https://github.com/ravindu57/SCML.git && cd SCML
python3 -m venv .venv && .venv/bin/pip install -e ".[dev]"
DATABASE_URL="" REDIS_URL="" TRUST_MEDIATOR_API_KEYS="" \
.venv/bin/uvicorn trust_mediator.api.app:app --port 8000 &
sleep 2
bash demo.sh # run the demo
.venv/bin/pytest tests/ -q # 874 passed (needs the [grpc] extra)
cd clients/typescript && npm test # 25 passed
Interactive docs: http://localhost:8000/docs
Docker Compose
bash deploy.sh # builds image, starts Postgres + Redis + mediator
Dashboard
bash run-demo.sh # mediator :8000, dashboard :3100, agents :4000/:4100
bash run-demo.sh --stop # tear down
Architecture
┌─────────────────────────────────────────────────────────────────────────┐
│ SCML System Architecture │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Python │ │ TypeScript │ │ gRPC │ │
│ │ SDK │ │ SDK │ │ Client │ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │ │
│ └────────────────────┼────────────────────┘ │
│ │ │
│ ┌──────▼──────┐ │
│ │ FastAPI │ /v1/mediate/* │
│ │ + gRPC │ /v1/audit/* │
│ └──────┬──────┘ │
│ │ │
│ ┌───────────────────────────▼───────────────────────────┐ │
│ │ Mediation Pipeline │ │
│ │ │ │
│ │ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ │ │
│ │ │ Trust │→│Inject. │→│ Policy │→│Memory │ │ │
│ │ │ Router │ │Scanner │ │ Engine │ │Integrity│ │ │
│ │ └────────┘ └────────┘ └────────┘ └────────┘ │ │
│ │ │ │ │ │
│ │ └────────────┬───────────────┘ │ │
│ │ ▼ │ │
│ │ ┌──────────────┐ ┌──────────────┐ │ │
│ │ │ Output │ │ Audit │ │ │
│ │ │ Redactor │ │ Logger │ │ │
│ │ └──────────────┘ └──────────────┘ │ │
│ └───────────────────────────────────────────────────────┘ │
│ │ │
│ ┌──────────▼──────────┐ │
│ │ PostgreSQL / SQLite│ │
│ │ + Redis (optional) │ │
│ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘
All config via TRUST_MEDIATOR_* env vars — nothing hardcoded. Every decision emits an AuditEvent.
API Surface
Production Deployment
Full integration guide:
INTEGRATION.md— Python SDK, TypeScript SDK, LangChain guard, HTTP API, embedded mode, and examples for CrewAI, LangGraph, and OpenAI function calling.
Tests
DATABASE_URL="" TRUST_MEDIATOR_ENV=development REDIS_URL="" TRUST_MEDIATOR_API_KEYS="" \
.venv/bin/pytest tests/ -q # 874 passed (needs the [grpc] extra)
cd clients/typescript && npm test # 25 passed
Apache License 2.0 — includes patent grant and defensive termination.
SCML MCP questions
What tools does SCML MCP provide?
It exposes 7 tools, including authorize_tool_call, scan_content, check_memory_write, redact_output, get_audit_trail.
Can I use SCML with Claude Desktop or Cursor?
Yes, SCML exposes its security pipeline as MCP tools that can be used by any MCP-compatible client like Claude, Cursor, or Windsurf.
Is the audit log secure?
Yes, every decision is logged to a tamper-evident SHA-256 hash chain.