Arcjet Learning Center

How-tos Guides

Short, framework-specific recipes for Eve, Mastra, Claude Agent SDK, OpenAI Agents SDK, LangGraph JS, LangChain Python, and the Vercel AI SDK.

What these guides cover

How-tos are short recipes for one enforcement point in a specific agent framework. They assume you already know the threat model and need the helper that sits on this channel, connection, or tool. Eve screens inbound channel text and gates connections that have no local execute. Mastra screens messages in processors and denies unwrapped MCP, workspace, and toolset tools on beforeToolCall. Claude Agent SDK screens prompts on UserPromptSubmit and denies unwrapped built-ins on PreToolUse. OpenAI Agents screens text with a direct guard() before run() and wraps authored invoke. LangGraph JS screens before graph.invoke and denies MCP inside ToolNode. LangChain Python and the Vercel AI SDK wrap authored tools. Each recipe names the helper, the deny shape, and the control that is not a policy gate.

Risks

  • Channel auth treated as a prompt-injection screen
  • Mounted MCP or OpenAPI connections left without a local gate
  • Built-in tools skipped by canUseTool or a bare allowedTools name
  • Authored-tool wraps assumed to cover tools you did not write

Control priorities

  • Inbound screen before the turn starts
  • Connection approval or hook deny before the host is called
  • PreToolUse for unwrapped built-in tools
  • One helper per surface so the guard is not double-called

Recommended reading order

Read the matching framework security guide in AI Security first. Then open the recipe for the surface you are wiring: inbound text, a connection, an authored tool, or an unwrapped MCP or built-in tool.

Guides in this collection

How-tos

How do I secure AI agents in production?

Screen inbound text, gate tools and MCP before side effects, and treat observe-only hooks as a diary.

Read guide
How-tos

How to detect prompt injection in an Eve agent

Screen Slack or GitHub bodies with guardInbound after the signature check, before the Eve agent starts.

Read guide
How-tos

How to secure Eve MCP connections

Secure Eve MCP and OpenAPI connections with guardApproval() on the connection's approval field.

Read guide
How-tos

How to secure Mastra MCP tools

Gate Mastra MCP, workspace, and toolset tools with guardHooks so beforeToolCall can deny.

Read guide
How-tos

How to screen inbound prompts in Claude Agent SDK

Screen inbound prompts on guardHooks({ inbound }) via UserPromptSubmit. A DENY erases the prompt before the model sees it.

Read guide
How-tos

How do I secure an OpenAI Agents SDK agent?

Screen text with guard() before run(), wrap authored tools with guardTool, and leave hosted tools off the deny list.

Read guide
How-tos

How do I screen inbound prompts in OpenAI Agents SDK?

Screen input with a direct guard() before run(). Native inputGuardrails are OpenAI tripwires, not Arcjet.

Read guide
How-tos

How do I secure a LangGraph JS agent?

Screen before graph.invoke, wrap authored tools with guardTool, and wrap ToolNode in place for MCP.

Read guide
How-tos

How do I secure MCP tools in LangGraph?

Wrap ToolNode with guardToolNode in place — MCP and unwrapped tools run inside it; graph hooks cannot stop them.

Read guide
How-tos

How do I secure a LangChain Python agent?

Use guard_action, guard_tool, or ArcjetMiddleware plus ToolPolicy. ArcjetCaptureHandler cannot deny.

Read guide
How-tos

How do I secure a Vercel AI SDK agent?

Wrap Vercel AI SDK tools with guardTool, pass run context through toolsContext, and guard app-invoked work.

Read guide
How-tos

needsApproval and LangGraph interrupt() are not a security policy

needsApproval, requireApproval, and interrupt() pause for a person. They are not a remote allow or deny.

Read guide