> ## Documentation Index
> Fetch the complete documentation index at: https://docs.safefetch.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Agents

> Use SafeFetch through MCP tools from AI agents.

## Why use MCP with SafeFetch?

MCP gives agents safe, structured primitives for background execution instead of direct long-running HTTP calls.

## MCP server setup (Claude Desktop)

See full setup in [MCP Setup](/mcp/setup). Once configured, your agent can call SafeFetch tools directly.

## All 6 tools

<CardGroup cols={2}>
  <Card title="send_action">Send an action with approval, dedupe, and idempotency.</Card>
  <Card title="get_action">Fetch status, results, errors, and next actions.</Card>
  <Card title="cancel">Cancel pending/awaiting\_approval actions.</Card>
  <Card title="approve">Approve an action awaiting human review.</Card>
  <Card title="retry">Create a retry copy from failed/cancelled action.</Card>
  <Card title="list_actions">List/filter recent actions.</Card>
</CardGroup>

## Conversation example

<Frame>
  ```text theme={null}
  User: Send a charge request to the billing API for customer 42.
  Agent: I'll send that for your approval first.
  Agent (tool: send_action): {"url":"https://api.example.com/charge","approve":true, ...}
  Agent: Action queued as act_123. Awaiting your approval before delivery.
  ```
</Frame>

## Polling pattern for async action results

<CodeGroup>
  ```text Pseudocode theme={null}
  1) send_action
  2) store returned action id
  3) poll get_action every 2-5s
  4) stop when status in [completed, failed, cancelled]
  ```

  ```bash Example theme={null}
  ACT_ID=$(curl -s -X POST http://localhost:3000/v1/actions ... | jq -r .id)

  while true; do
    STATUS=$(curl -s http://localhost:3000/v1/actions/$ACT_ID -H "Authorization: Bearer <API_KEY>" | jq -r '.status')
    echo "status=$STATUS"
    case "$STATUS" in
      completed|failed|cancelled) break ;;
    esac
    sleep 3
  done
  ```
</CodeGroup>
