Skip to content
MoorAI
Get MoorAI
On this page
// blog · buyer’s guide

How MoorAI protects AI apps and APIs

An AI service acts in three places: it calls its model API, it runs tools, and it calls MCP servers that someone else operates. On Claude Enterprise, Anthropic can also hold each prompt and tool call until your own server answers. MoorAI agent v1.17.1 puts a check at each of those points, in your own environment, and sends only content-free signals out of it.

MoorAI v1.4 diagram with a box labelled “Super intelligence” in the middle, standing for any AI agent or app. To the left, its requests to an Anthropic or OpenAI model API pass through the MoorAI model proxy, which is report-only by default and refuses denied requests in enforce mode. To the right, its MCP tool calls pass through the MoorAI MCP gateway: an allowed call is forwarded to the remote MCP server, and a denied call is stopped at the gateway and never reaches the server. Below, the app asks the moorai-serve sidecar on 127.0.0.1:8790 whether to allow a call and gets allow or deny back. A strip lists the real MCP clients tested: Claude Code, Cursor CLI, MCP SDK and MCP Inspector. MoorAI v1.4 AI security at the point. LLM API Anthropic · OpenAI MOORAI Model proxy moorai-model-proxy checks what your agent sends to the LLM >_ Super intelligence MOORAI MCP gateway moorai-mcp-gateway checks every tool call MCP servers remote, over HTTP allowed call: forwarded denied call never reached the server Report-only by default. Enforce mode refuses denied requests. allow this call? allow / deny MOORAI Sidecar decision API moorai-serve · 127.0.0.1:8790 your app asks before a tool runs TESTED WITH REAL MCP CLIENTS Claude Code·Cursor CLI·MCP SDK·MCP Inspector Open source · MIT · moorai.dev MoorAI

MoorAI runs inside coding agents on developers’ laptops. The same engine runs in front of AI apps and APIs: as a hook inside an Agent SDK service, as a decision API your code calls before a tool runs, as a proxy between an agent and its model API, as a gateway in front of remote MCP servers, and as the server Claude Enterprise’s Inference hooks call. This guide covers where each check sits, what it does, who decides what happens when it can’t decide, how to keep it out of the agent’s reach, and what has been tested with real clients.

Where the check happens

Each component runs next to the workload it protects. All of them are in the MoorAI agent, which is open source under MIT. This guide describes agent v1.17.1, released on 14 October 2026, and console v0.87.1.

Where the AI actsMoorAI componentWhat it checks
A service built on the Agent SDK@moorai/agent-sdkEvery tool call, inside your service’s own process, plus its prompts and tool results.
Any agent framework, before a tool runsmoorai-serve sidecarThe tool call your code asks about, text to scan, and chunks about to be embedded. A localhost HTTP decision API on 127.0.0.1:8790.
The model APImoorai-model-proxyWhat the agent sends to the model and the tool calls that come back, on 127.0.0.1:8791, for the Anthropic Messages, OpenAI Chat Completions, Gemini generateContent and Ollama native APIs.
Remote MCP serversmoorai-mcp-gatewayEvery MCP message between the agent and the server, including each tool call and each streamed event.
Claude Enterprise, with Inference hooks onmoorai-inference-hookEach governed prompt from claude.ai, Claude Code and Cowork, and each tool call frame when Validate tool calls is on, before Anthropic goes ahead. On 127.0.0.1:8792, behind your own TLS reverse proxy.
Every other connectionmoorai-egress-proxyThe connections routed through it, against your declared egress rules. For HTTPS, host and port only: it doesn’t decrypt TLS.
Coding agentsHooksTool calls and prompts in Claude Code, Codex, Copilot CLI, Cursor and Gemini CLI.

Which one you need

They combine. A service can call the sidecar for its own tools, reach its MCP servers through the gateway and its model through the proxy. One W3C trace joins them, described below.

The Agent SDK hook: in process

For a service built on the Claude Agent SDK, @moorai/agent-sdk returns the hooks record for query(). PreToolUse returns the decision and reason MoorAI’s shell hook would give: a parity test over 214 payloads under two policy states found no mismatch. The check runs in your code path before each tool call, at a p50 of 1.99 ms on a 2 KB input, and the model doesn’t decide whether it is consulted.

import { moorAIHooks } from "@moorai/agent-sdk";
query({ prompt, options: { hooks: moorAIHooks({ serviceId: "invoice-agent" }) } })

Prompts and tool results are scanned and reported by default. prompts: "enforce" blocks a denied prompt, and toolResults: "advise" tells the model a flagged result is untrusted data. For an app that runs its own RAG ingestion, scanBeforeEmbed and guardEmbed scan each chunk before it is embedded.

The sidecar: a decision API for any framework

moorai-serve is a localhost HTTP decision API on 127.0.0.1:8790 for agent loops that are not Claude Code or the Agent SDK: the OpenAI Agents SDK, LangGraph, CrewAI or your own loop. Before your code runs a tool, it sends the call to POST /v1/tool-call and gets back the decision MoorAI’s hook would make for that call. Your code does what the answer says. POST /v1/scan scans text, including a tool’s raw result as inbound content, and POST /v1/index-scan gives one verdict per chunk about to be embedded. Verdicts never contain the submitted text, though a tool-call verdict’s message can name a file or a host from the call.

It binds loopback only, unless --allow-remote is given with a token of 16 or more characters. It refuses a non-loopback Host (421), a body that is not JSON (415) and a body over 1 MiB (413). The p50 for /v1/scan on 2 KB is 6.4 to 11 ms. A stdlib-only Python client with LangGraph and CrewAI examples is in the repository. /v1/tool-call reads paths on the sidecar’s own filesystem, so run it where the agent’s files are: in the agent’s pod or compose network, where the agent reaches it on loopback and no port is opened to the outside. The quick start’s Run it as a sidecar section has the command, the endpoints and the compose and Kubernetes examples.

What both in-process forms share

The SDK and the sidecar run the same engine and policy as the hook, with server mode’s rules: an “ask” has no one to answer it and is denied, the actor is the workload rather than a person, declared workload profiles are evaluated, and reports are content-free. Some controls need the whole session and are not evaluated in process: the circuit breaker, session risk, deletion volume, intent alignment, learned drift, MCP reputation, model escalation, honeytokens, the mask rewrite and the check of the agent’s own environment for a proxy or CA override. Each result lists them in notEvaluated. Neither form records the allow trail.

The model proxy: between the agent and its model API

moorai-model-proxy listens on 127.0.0.1:8791 with four default routes: /anthropic, /openai, /gemini and, on a loopback bind only, /ollama (Ollama’s API is unauthenticated, so a remote bind drops that route). The agent points its model SDK’s base URL at the proxy, and the proxy forwards each call to the provider. It scans what the agent sends: the prompt and system text, and the tool results and documents fed back, where indirect injection shows up. It decides every tool call in the model’s response before the agent framework receives it, with the decision the sidecar would make, whether or not your code asks the sidecar. The client’s own API key goes upstream untouched and is never logged, stored or reported.

Four parsed APIs

Everything else is forwarded unparsed and unchecked: the OpenAI Responses API, embeddings, Amazon Bedrock, Gemini’s Interactions and Live APIs, and Vertex AI partner models. Assistant turns, images, base64 PDFs, tool definitions and server-side tool blocks are not scanned. The proxy covers only traffic that goes through it: it doesn’t intercept TLS, so an SDK pinned to the provider’s HTTPS URL bypasses it.

Report-only, then enforce

Business actions and function names

Plain function calls are classed by the words of their name: money (issue_refund, transfer_funds), bulk data (export_customer_data_any), identity (reset_password, grant_admin_role), destructive (drop_table, purge_records) or delegation (accept_handoff). Lookups such as get_refund_status are not. Every class alerts by default, and a signed policy sets each one to allow, alert, ask or block. A rule in functionToolActions that names the function itself, exactly or by prefix, wins over its class. Alerts carry the class and the function name, never an argument. Classes come from names, so purge_cache counts as destructive and create_agent as delegation: under the default that costs an alert, under block a call.

Your own system prompt

The application’s own system prompt (Anthropic system, OpenAI system and developer, Gemini systemInstruction, Ollama system messages) is judged like any request content, because a client controls its own system role: personal data or a secret moved there is blocked or asked about per policy. As an opt-in, set only in the verified signed policy or the root-owned admin binding, operatorContext with privacy: "report" makes personal-data findings there report-only. Secrets and every finding that isn’t about data, such as prompt injection, a reverse shell or system-prompt extraction, are still decided as in a user turn. Ollama’s /api/generate prompt counts as the user’s, because the proxy can’t split one string by author.

Decoy keys

With decoyKeys set to place them in a verified signed policy, MoorAI writes three never-issued AI keys, in provider key shapes, into new files that key harvesters sweep and no tool loads. The model proxy checks every request header value, the query string and the body for them, and refuses a match with 403 in report and enforce mode alike. The Critical alert carries the decoy’s id and where it was found. A decoy that is re-encoded before use (base64, split, reversed) isn’t matched.

Placeholder credentials, opt-in

The agent holds a placeholder instead of the API key. The proxy, running as another user or in its own container, swaps the real key in only on the route the placeholder is bound to, refuses any other use of the placeholder, and masks a key the upstream echoes back. A raw key in a credential header or in the ?key= query string is alerted once per route, and refused with --require-placeholders. The MCP gateway has the same mechanism. It doesn’t protect a key the agent can read itself or use on another path, and the agent can still use the placeholder through the proxy, so policy decides what goes through.

One trace, and a record of each model call

Every agent session is one W3C trace. The model proxy learns the session from Claude Code’s X-Claude-Code-Session-Id header and sends traceparent and tracestate on to the provider; a valid incoming traceparent always wins. Its alerts carry traceId, spanId and parentSpanId, so the console’s trace view and an OTLP backend can join an agent action, the model call it made and the MCP call that followed. Only hex ids and an agent name leave, and the proxy adds about 2 to 4 µs per request. Session ids the proxy sees are caller-asserted: a process that can reach it can put its requests in another session’s trace, though it can’t change that session’s hook records.

With the allow trail on (actionTrail: "allowed" in the signed policy), the proxy also queues one content-free record per forwarded model request, with its provider, model and trace fields. Console v0.87.1 does not store these records: its allow trail accepts tool-call records only. In the console a model is named by the proxy’s alerts, and the runtime AIBOM shows model calls that raised no finding as not measured.

What has been run

Response-side enforcement is tested against a fake provider, and Gemini against a fake upstream only. Ollama’s native API was measured live against Ollama 0.15.6 (mistral-nemo) in enforce mode: the allowed call was released and the denied one refused, JSON and streaming. The proxy hasn’t been run with the providers’ own SDKs or against a real hosted provider, which is why report-only is the place to start.

The MCP gateway: in front of remote MCP servers

moorai-mcp-gateway is an HTTP MCP guard. The agent connects to the gateway, and the gateway connects to the remote server. It applies the stdio MCP proxy’s tool-call and tool-result checks, and every message passes through these as well:

A tool call that policy denies is refused at the gateway and doesn’t reach the server; it comes back to the client as an MCP tool result marked as an error. The headers of both MCP spec eras pass through. The gateway adds about 4.7 to 5 ms at p50 against an in-process fake upstream. It doesn’t judge egress rules. For the wider question of trusting MCP servers you don’t run, see MCP security.

The Inference hooks server: for Claude Enterprise

Inference hooks are a Claude Enterprise beta. Once an Owner turns them on, Anthropic sends each governed prompt from claude.ai, Claude Code and Cowork to the organization’s server, and, with Validate tool calls on, each tool call frame as well. Anthropic holds the request until the server answers allow or deny. moorai-inference-hook is that server.

A Read of a credential file, MCP file arguments and local secret egress are not judged here, because those files are not on this server. Field names may change during the beta.

When a check can’t decide

A check can fail to reach a decision: its engine throws, it runs past its time budget, or the content is past a scan cap. The administrator decides what happens then, per surface, in the signed console policy or the root-owned admin binding. The user can’t.

{ "failMode": { "default": "open", "modelProxy": "open", "mcpGateway": "closed", "inferenceHook": "closed" } }
SurfaceOwn defaultSet to closed
Model proxyEnforce mode refuses, report mode forwardsContent it can’t judge is refused. In report mode, only request items past a cap, which are known before forwarding.
MCP stdio guard and HTTP gatewayOpen: forwarded unchangedA tools/call it can’t evaluate gets an error result and the server never receives it; a tool result whose scan failed is replaced by an error result.
Inference hooks serverThe operator’s --fail flag, open unless setThe server answers deny.

The admin binding wins, then the signed policy, then the surface’s own default. No environment variable, settings file or user-scope file is read, so nothing the agent can write turns a closed surface open. Each fail-closed refusal raises one content-free FAIL_CLOSED alert naming the cause and where the setting came from. Logging, inventory and telemetry always fail open.

Keep them out of the agent’s reach

A guardrail the agent can edit isn’t a guardrail. The container image ghcr.io/gitayg/moorai-server holds the server commands (moorai-serve by default, and moorai-mcp-gateway, moorai-model-proxy and moorai-egress-proxy), for amd64 and arm64, and runs as a non-root user (uid 1000). Run them in their own container and the agent process can’t edit their policy or files. Alerts from the sidecar, the gateway, the model proxy and the Agent SDK carry the workload’s container id and, when set through the Kubernetes downward API, its pod, namespace and node, so a SIEM can join MoorAI verdicts with host and container sensor events.

Routing is the other half. When your network policy forces the workload’s model and MCP traffic through the proxy and the gateway, the agent can’t route around them. The restriction is your own network policy. MoorAI’s Kubernetes and compose examples show one: the model proxy, the MCP gateway and moorai-egress-proxy run in their own pod, and the agent’s network reaches only that pod and cluster DNS. The egress proxy enforces your declared egress rules on every other connection the agent opens. It doesn’t decrypt TLS, so for HTTPS it judges host and port only.

For coding agents on servers and in CI, MoorAI’s hooks sit in Claude Code’s system-wide managed settings, which a repository can’t switch off. On a laptop the hook runs as the developer, so disabling it is detected, not prevented: an enrolled device sends a daily coverage heartbeat, and the console raises “agent active, no MoorAI hook traffic”. The full breakdown of what is prevented, what is detected and what is out of scope is in tamper resistance and the FAQ.

What leaves your environment

Prompts, code, files and secrets are checked where the agent runs. They aren’t sent anywhere to be checked. The console receives content-free signals about what fired, not the content that fired it, and trace fields are hex ids. Trust lists what leaves and what stays.

Evidence of what entered the context

Where the Claude Code hook runs, including claude -p in CI and an Agent SDK service that loads the shell hook from its settings, MoorAI keeps a per-session Merkle tree of what entered the agent’s context (context.tree): one content-free leaf per prompt, file read, web result, MCP result, command output and sub-agent hand-off. Every record carries the tree’s root, and an injection alert names the leaf whose content triggered it, so moorai-context-proof --verify finds which session took in a given file. With contextTree: "console" the leaves also go to the console, which re-verifies each record’s root and offers a patient-zero lookup by SHA-256. The in-process SDK, the sidecar, the proxies, the gateway and the Inference hooks server keep no tree. The tree is tamper-evident, not tamper-proof: it lives where the agent can write.

What was tested

On 2026-10-06, on macOS, four real MCP clients ran through MoorAI’s stdio MCP proxy and its HTTP gateway, in front of a test MCP server:

Beyond those runs:

Not tested

Claude Desktop, VS Code and the Cursor desktop app. Windows and Linux for the real-client runs. OAuth discovery through the gateway. A real client and a real remote MCP server in the same run. A live, model-driven denied call through the gateway. A completed session on the 2026-07-28 MCP revision with a real client. The model proxy with the providers’ own SDKs or a real hosted provider; Gemini has run against a fake upstream only. The Inference hooks server against Anthropic’s live service: it has been tested only against signed sample frames built from Anthropic’s published schema. An Agent SDK service or a GitHub Actions run watched end to end, and the Python sidecar examples, which have not been executed. CRI-O, a managed cloud cluster, and the amd64 image run on a host.

Questions to ask of any guardrail

Whichever product sits in front of your AI app, these questions separate a check from a log line:


MoorAI is open-source (MIT) runtime guardrails for AI agents, apps and APIs. Every rule is mapped to the OWASP LLM, Agentic and MCP Top 10s, MITRE ATLAS and MITRE ATT&CK v20 in the threat rule-base. See also: Run it as a sidecar, MCP security, and The layer above the model.

AI security at the point.
Runtime guardrails for AI agents, apps and APIs. Open source under MIT; checks run where the agent runs, and the console gets content-free signals.
Run it as a sidecar → See MoorAI