User guideDeveloper guideConnect your agent
Developer guide

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

bash
export VW_GATEWAY_URL=http://localhost:8100   # your gateway URL
export VW_AGENT_KEY=sk-mcp-...                 # the key you just copied

3. 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.

json
{
  "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.

json
{
  "version": 1,
  "hooks": {
    "preToolUse": [
      { "command": "scripts/vw-tool-hook.sh",
        "matcher": "Shell|Write|Edit" }
    ]
  }
}
How deny works in Cursor
The script blocks a denied call by exiting with code 2, which Cursor honors as a block. Cursor then shows its own generic block message rather than the gateway reason. The call is still blocked and recorded.

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.

Fail-open by default
If the gateway is unreachable, the hook lets the call run so your workflow is never blocked by an outage. Set VW_FAIL_MODE=closed to block instead.
PreviousAgent Control: how it works
NextConnect any agent
Connect your agent - Developer guide - VerifyWise User Guide