← Back to Learn
mcp-safetytutorialdeploymentguardrails

Setting up Authensor with Claude Code

Authensor

Claude Code is an AI coding agent that uses MCP to interact with your filesystem, run shell commands, and manage git repositories. By routing Claude Code through Authensor's MCP gateway, you can enforce safety policies on every action it takes.

Why add guardrails to Claude Code

Claude Code has access to powerful tools: file read/write, shell execution, git operations, and web requests. In most configurations, these tools are unrestricted. Adding a safety layer lets you:

  • Block destructive shell commands (rm -rf, mkfs, dd)
  • Restrict file writes to specific directories
  • Require approval for git push operations
  • Log every action for audit purposes
  • Scan tool arguments for injection patterns

Set up the MCP gateway

Install and configure the Authensor MCP server:

pnpm add -g @authensor/mcp-server

Create a policy for Claude Code:

# claude-code-policy.yaml
version: "1"
rules:
  - tool: "shell.execute"
    action: block
    when:
      args.command:
        matches: "rm -rf|mkfs|dd if=|shutdown|reboot|format"
    reason: "Destructive commands blocked"

  - tool: "file.write"
    action: allow
    when:
      args.path:
        startsWith: "/Users/you/projects/"

  - tool: "file.write"
    action: block
    reason: "Writes outside project directory blocked"

  - tool: "git.push"
    action: escalate
    reason: "Push requires approval"

  - tool: "*"
    action: allow

Configure Claude Code to use the gateway

Add the MCP gateway to your Claude Code configuration:

{
  "mcpServers": {
    "authensor-gateway": {
      "command": "npx",
      "args": ["@authensor/mcp-server", "--policy", "./claude-code-policy.yaml"]
    }
  }
}

What this gives you

With the gateway in place, Claude Code operates within your defined boundaries. If it tries to run rm -rf /, the command is blocked before it reaches the shell. If it tries to write outside your project directory, the write is denied. If it tries to push to a remote, the action is held for your approval.

All of this happens transparently. Claude Code sees the same MCP tools and does not know the gateway exists. It receives error messages for blocked actions and can adapt its approach.

Reviewing the audit trail

Every action Claude Code takes is recorded as a receipt. You can review the audit trail to see exactly what happened during a session:

npx authensor receipts list --session latest

This is useful for code review: you can verify what the agent actually did versus what it said it did.

Keep learning

Explore more guides on AI agent safety, prompt injection, and building secure systems.

View All Guides