Hermes Hooks

Akto Guardrails for Hermes provides security validation for AI agent interactions. It intercepts prompts and tool calls before execution, validates against security policies, blocks risky behavior, and reports all events to your Akto dashboard.

Key Features

  • MCP & Non-MCP Tool Support - Validates both MCP server tools and non-MCP built-in tools

  • Real-time Protection - Validates every prompt and tool call before execution

  • JSON-RPC Compliance - Full JSON-RPC 2.0 support for MCP protocol

  • Device ID Tracking - Multi-device management with unique device identifiers

  • Audit Trail - Complete audit logging to Akto dashboard

  • Configurable Behavior - Blocking or observation modes

  • Fail-Safe Design - Graceful degradation if Akto server unavailable

How It Works

Hermes plugin hooks into four critical points in the AI agent lifecycle:

User Input

┌─────────────────────────────────────┐
│ pre_llm_call Hook                   │ ← Validate prompt, BLOCK if needed
│ (Runs BEFORE sending to Claude)     │
└────────────┬────────────────────────┘
             ↓ (if allowed)
        Claude LLM API

┌─────────────────────────────────────┐
│ post_llm_call Hook                  │ ← Log response for audit
│ (Runs AFTER LLM responds)           │
└────────────┬────────────────────────┘

       Tool Execution Request

┌─────────────────────────────────────┐
│ pre_tool_call Hook                  │ ← Validate tool, BLOCK if needed
│ (Runs BEFORE tool execution)        │
└────────────┬────────────────────────┘
             ↓ (if allowed)
       Tool Execution

┌──────────────────────────────────────┐
│ post_tool_call Hook                 │ ← Log result for audit
│ (Runs AFTER tool completes)         │
└──────────────────────────────────────┘

4 Hook Points:

  1. pre_llm_call - Validates user prompts before sending to Claude LLM

  2. post_llm_call - Logs Claude responses and audit trail

  3. pre_tool_call - Validates tool calls (MCP and non-MCP) before execution

  4. post_tool_call - Logs tool responses for audit trail

File Structure

Key Files:

  • __init__.py: Main plugin that registers 4 hooks with Hermes

  • akto_client.py: Handles all API communication (validation + ingestion)

    • Validation calls: /api/http-proxy?guardrails=true

    • Ingestion calls: /api/http-proxy?ingest_data=true

  • validators.py: Prompt and tool validation logic against Akto policies

  • mcp_util.py: Detects MCP tools and converts to JSON-RPC 2.0 format

  • akto_machine_id.py: Generates unique device identifiers for multi-device tracking

  • plugin.yaml: Hermes plugin manifest — metadata for plugin discovery

Setup Guide

Prerequisites

  • Hermes Agent installed and functional

  • Python 3.6+ available

  • Akto instance with guardrails API endpoint

  • Network access to your Akto server

  • Akto Data Ingestion URL (provided by your Akto admin)

Installation Steps

Step 1: Obtain Plugin Files

Clone the Akto repository or download the plugin files:

Alternatively, download individual files from GitHub:

Step 2: Copy Plugin to Hermes

Create the plugins directory and copy all files:

Verify installation:

Step 3: Configure Akto Server URL ⚠️ CRITICAL STEP

Set your Akto instance URL as an environment variable:

Verify the URL is set:

circle-exclamation

Step 4: Configure Hermes Plugin (Optional)

Edit or create ~/.hermes/config.yaml for additional plugin configuration:

What each setting means:

  • AKTO_SYNC_MODE: "true" - Block risky prompts/tools (recommended)

  • AKTO_SYNC_MODE: "false" - Logging only (no blocking)

  • LOG_LEVEL: "INFO" - Log important events only

  • LOG_LEVEL: "DEBUG" - Verbose logging with full payloads

  • AKTO_TIMEOUT: "5" - Wait max 5 seconds for Akto response

Step 5: Configure MCP Servers (Optional)

If you use MCP servers with Hermes, add them to ~/.hermes/config.yaml:

The plugin will automatically detect MCP tools (format: server_tool) and route them to the /mcp endpoint with JSON-RPC 2.0 format.

Step 6: Create Log Directory

Logs will be written to: ~/.config/hermes/akto/logs/hermes-guardrails.log

Step 7: Start Hermes

Start or restart Hermes:

Verify plugin is loaded:

Expected output:

Step 8: Verify Installation

Check all components are working:

Configuration Reference

Environment Variables

Set these to customize the plugin behavior:

Hermes Plugin Settings

Edit ~/.hermes/config.yaml to customize (optional):

Monitoring & Logs

View Real-time Activity

Log Format

Each log entry includes:

  • Timestamp: When the event occurred

  • Component: Which module generated the log (e.g., [HOOK: pre_llm_call])

  • Details: Relevant context (session ID, tool name, validation result)

Enable Debug Logging

For verbose logging with full payloads:

Troubleshooting

Plugin Not Loading

Symptom: No logs appear in ~/.config/hermes/akto/logs/

Solution:

Akto Server Unreachable

Symptom: Logs show "API CALL FAILED"

Solution:

MCP Tools Not Detected

Symptom: MCP tool doesn't appear as server_tool format

Solution:

Python Import Errors

Symptom: Errors in logs about missing modules

Solution:

No Events in Dashboard

Symptom: Plugin runs but events don't appear in Akto dashboard

Solution:

Quick Setup Summary

Data Flow

Prompt Validation & Logging

Tool Execution - Non-MCP Tools (e.g., web_search, terminal)

Tool Execution - MCP Tools (e.g., calculator_add, git_status)

Resources

Last updated