# history_search

Past tasks, tool calls and agent sessions by machine, author, task, time and text, newest first. Calls carry no arguments; journal_search on the machine has them.

**In short:** A [server tool](https://docs.cmdop.ai/reference/tools.md#server-tools): the server answers it from its own record, so it works while every machine is off. Over MCP call `history_search`; over HTTP send `"tool": "history_search"` to [`POST /api/v1/call`](https://docs.cmdop.ai/reference/http/post-call.md) without `machine`.

## Arguments

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `author` | `string` | no | Author or its start: `owner`, `agent:` (every agent), `agent:<name>`. |
| `kind` | `("tasks" \| "sessions" \| "calls")[]` | no | What to return. Default: tasks, sessions and calls. |
| `limit` | `integer` | no | At most this many of each kind, newest first (default 50, at most 200). |
| `machine` | `string` | no | Only this machine (name or id). |
| `since` | `integer` | no | Started (sessions: last changed) at or after this time, unix seconds. |
| `task` | `integer` | no | Only this task (its row and the calls that started or named it; no sessions). |
| `text` | `string` | no | Text, any case. Tasks: the command, the folder or the error (another author's only for an agent granted exec). Sessions: path, id, folder. Calls: the tool name. |
| `until` | `integer` | no | Started (sessions: last changed) before this time, unix seconds. |

## Result

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `calls` | `object[]` | no | Only calls the server could read: calls from a paired client, encrypted end to end, are left out. |
| `sessions` | `object[]` | no | Absent when `task` was given: a task has no sessions. |
| `tasks` | `object[]` | no |  |

## Examples

**MCP**

```json
{
  "name": "history_search",
  "arguments": {}
}
```

**HTTP**

```bash
curl -sS -X POST "https://<contour>.cmdop.dev/api/v1/call" \
  -H "Authorization: Bearer $CMDOP_TOKEN" \
  -H "x-cmdop: 1" \
  -H "Content-Type: application/json" \
  -d '{"tool":"history_search","args":{}}'
```

## Limits

The token is the only check: no risk class applies, and the call is not counted against the plan. A call with `machine` set, or with `sealed` instead of `args`, returns [`bad_args`](https://docs.cmdop.ai/reference/errors/bad_args.md). A refused call returns one of the [error codes](https://docs.cmdop.ai/reference/errors.md).

## Notes

Another author's command, folder and error are shown only to an agent whose grant includes `exec`; for other callers they are left out and `hidden` says why.
