# Get a push when the agent finishes.

> Get a push when an AI agent or LLM run finishes, needs approval, or fails. Pocket Alert ships an MCP create_message tool and a plain HTTP POST to your phone.

<!-- source: https://pocketalert.app/use-cases/ai-agent-alerts -->

A long-running LLM agent should not need you watching it. Your phone buzzes when the job is done, stuck waiting on approval, or broken — so you can step away and trust it to reach you.

## Three steps to hands-off agent alerts

1. **Pick MCP or HTTP** — Create an API key, or add the Pocket Alert MCP server to your client for the no-code route.
2. **Send on finish** — Call create_message, or POST a title and message from a LangChain callback or agent tool.
3. **Walk away** — Give each agent its own application for failures and approvals. Now you can leave the desk while it works.

## Built for agents that run unattended

Two paths, same result: the agent calls an MCP tool or POSTs once, and your phone buzzes.

- **MCP server built in** — MCP clients like Claude Code, Claude Desktop, and Cursor push a notification by calling the create_message tool.
- **Plain HTTP fallback** — No MCP client? One authenticated POST to the messages API does the same job from any agent or script.
- **Stop-hook ready** — Fire the alert from a Stop hook so it runs when the agent finishes, not when you remember to check.
- **Status in the message** — Send the agent status and result text right in the message, so "needs approval" reads clearly.
- **Per-agent channels** — A separate application per agent or project keeps the refactor bot and the cron job on their own channels.
- **Sub-second delivery** — Pushes land in under a second, so you hear back the instant a long job ends or stalls on input.

## Wire an agent to your phone

### 1. Get an API key

Create a key on the [API Keys](https://pocketalert.app/account/apikeys) page. The agent sends it in the `Token` header.

### 2. POST from a LangChain callback (Python)

```
import requests
from langchain.callbacks.base import BaseCallbackHandler

class PocketAlert(BaseCallbackHandler):
    def on_agent_finish(self, finish, **kwargs):
        requests.post(
            "https://api.pocketalert.app/v1/messages",
            headers={"Token": "YOUR_API_KEY"},
            json={"title": "Agent finished", "message": finish.return_values["output"][:200]},
        )

agent.invoke({"input": task}, config={"callbacks": [PocketAlert()]})
```

### 3. Or as an OpenAI tool the agent calls (Node)

```
async function notifyHuman({ title, message }) {
  await fetch("https://api.pocketalert.app/v1/messages", {
    method: "POST",
    headers: { Token: "YOUR_API_KEY", "Content-Type": "application/json" },
    body: JSON.stringify({ title, message, level: "high" }),
  });
}
```

Expose `notifyHuman` as a function/tool so the agent calls it when it needs approval or hits an error.

### 4. Or skip the code with MCP

If your client speaks MCP (Claude Code, Claude Desktop, Cursor), add the Pocket Alert MCP server and let the agent call the `create_message` tool. No code on your side.

The [docs](https://info.pocketalert.app/getting-started.html) cover targeting, applications, and the rest of the MCP tools.

## FAQ

### How does an agent send me a push?

Two ways. MCP clients like Claude Code, Claude Desktop, or Cursor call the create_message tool and the push lands on your phone. Anything else does a single HTTP POST to the messages API. A Stop hook at end-of-run is the usual trigger.

### What is the no-code MCP path?

Add the Pocket Alert MCP server to your client and call create_message with a title and message. No code, no curl. There is also create_message_with_attachment if the agent has a file or screenshot to send.

### Can I tell failures from completions at a glance?

Give each agent its own application so a "needs approval" from your refactor bot and a "task done" from the nightly pipeline arrive on separate channels. Word the title so an approval request or a failure reads clearly at a glance.

### How do I keep agents from one project separate?

Give each agent or project its own application. A push from your refactor bot and one from the nightly data pipeline arrive on separate channels, so you know which job spoke without reading the body.

### Is it fast enough to be worth checking the phone?

Delivery runs under a second. When a coding agent has churned for fifteen minutes and you have wandered off to make coffee, the push reaches you before you sit back down.

### How do I keep completions quiet but failures loud?

Send a level with each message. A routine "task done" ping can go at silent — no sound or vibration, but still in your history — while a failure or approval request goes at high and arrives as a time-sensitive push that breaks through iPhone Focus. The MCP create_message tool takes the same level field, so the agent picks the volume per message.
