Claude Code CLI
Connect Akto with Claude Code CLI
Overview
Prerequisites
Steps to Connect
1
mkdir -p ~/.claude/hooks
cd ~/.claude/hooks
# Download the hook files
curl -O https://raw.githubusercontent.com/akto-api-security/akto/master/apps/mcp-endpoint-shield/claude-cli-hooks/validate-prompt.py
curl -O https://raw.githubusercontent.com/akto-api-security/akto/master/apps/mcp-endpoint-shield/claude-cli-hooks/validate-response.py2
# Akto Data Ingestion Service URL (required)
export AKTO_DATA_INGESTION_URL="http://your-ingestion-service-url"
# Operation mode: true = block violating prompts, false = allow but still send to Akto (default: true)
export AKTO_SYNC_MODE=truesource ~/.zshrc # or source ~/.bashrc3
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "python3 ~/.claude/hooks/validate-prompt.py",
"timeout": 10
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "python3 ~/.claude/hooks/validate-response.py",
"timeout": 10
}
]
}
]
}
}4
claude5
How It Works
Request Flow (AKTO_SYNC_MODE=true)
Request Flow (AKTO_SYNC_MODE=false)
Environment Reference
Variable
Required
Default
Description
Get Support for your Akto setup
Last updated