Connect your agent
Get a tool call governed in about 5 minutes with the bundled hook, for Claude Code or Cursor.
Connect your agent
This gets one tool call governed in about 5 minutes using the bundled hook script. Steps 1, 2, 4 and 5 are the same for every agent. Step 3 shows the wiring for Claude Code and for Cursor, which share the same script. For any other terminal agent, see Connect any agent.
1. Create an agent key
In the UI, go to AI Gateway > Agent Control > Agent keys and create a key. Copy the value (it starts with sk-mcp-). You only see it once.
2. Set the environment variables
export VW_GATEWAY_URL=http://localhost:8100 # your gateway URL
export VW_AGENT_KEY=sk-mcp-... # the key you just copied3. Wire the hook
Both agents below run the same bundled script, scripts/vw-tool-hook.sh. The script needs curl and jq on the PATH. Pick the wiring for your agent.
Claude Code
Point Claude Code at the script in your .claude/settings.json. The PreToolUse hook asks for a decision before each tool runs; the PostToolUse hook reports the result afterward.
{
"hooks": {
"PreToolUse": [
{ "matcher": "Bash|Edit|Write|MultiEdit|NotebookEdit",
"hooks": [{ "type": "command", "command": "scripts/vw-tool-hook.sh" }] }
],
"PostToolUse": [
{ "matcher": "Bash|Edit|Write",
"hooks": [{ "type": "command", "command": "scripts/vw-tool-hook.sh" }] }
]
}
}Cursor
Add the same script to .cursor/hooks.json. Cursor runs the preToolUse hook before each tool; the matcher limits it to the tools you want to check.
{
"version": 1,
"hooks": {
"preToolUse": [
{ "command": "scripts/vw-tool-hook.sh",
"matcher": "Shell|Write|Edit" }
]
}
}4. Make a tool call
Run any Bash command in your agent. The hook calls the gateway, the gateway returns a decision, and the call runs only if it is allowed.
5. See it in Activity
Open AI Gateway > Agent Control > Activity. The call appears with its decision, latency and the agent key that made it.