# Agents

Set up and manage a stream from your coding agent with the moq-pro skill.

Fetch [SKILL.md](https://moq.pro/.well-known/agent-skills/moq-pro/SKILL.md)
and install it in your agent's skills directory as `moq-pro/SKILL.md`.
The same skill ships in `@moq/pro` at `dist/skills/moq-pro/SKILL.md`.

In Claude Code, add the hosted marketplace and install its npm plugin:

```sh
claude plugin marketplace add https://moq.pro/.well-known/claude-plugin/marketplace.json
claude plugin install moq-pro@moq-pro
```

The plugin becomes available after the `@moq/pro` release containing it is
published. Node 22 or later is required for the CLI. The human signs up and
approves `npx @moq/pro login` in their browser; the agent can then create a
project, a signing key, and a scoped relay URL. Card entry stays in the
[dashboard](https://moq.pro/project).

For another tool's credential, use `npx @moq/pro token request --name NAME
--scope write [--projects PID,PID]`. `--scope` takes the presets `read` and
`write` or comma-separated `family:level` entries, such as
`media:write,usage:read`; the [API reference](/api) lists the families.
It prints an approval link and code to stderr and a request handle to stdout, then exits. The human has one hour
to approve; agents never approve their own requests. Collect it with
`npx @moq/pro token wait HANDLE | wrangler secret put MOQ_PRO_TOKEN`.
Waiting prints only the token and keeps the CLI's saved login untouched.
See [token requests](/cli) for endpoint
selection, multiple requests, and `--wait`.

## Billing notices

The SDK's hand-written `watchNotifications` async iterator opens
`GET /v1/projects/{pid}/notifications/live`. This WebSocket is excluded from
generated request/response operations, CLI commands and MCP tools. Reuse your
SDK client and supply an authenticated socket factory. In Node, install `ws`:

```ts
import WebSocket from "ws";
import { createClient, watchNotifications } from "@moq/pro";

const client = createClient({ auth: process.env.MOQ_API_TOKEN });
const stop = new AbortController();
for await (const frame of watchNotifications({
 client,
 path: { pid: "PROJECT_ID" },
 signal: stop.signal,
 webSocket: (url, { headers }) => new WebSocket(url, { headers: Object.fromEntries(headers) }),
})) {
 console.log(frame.notifications);
}
```

Bun can use its native `WebSocket` with the supplied headers. Browser and
Node native sockets cannot set bearer headers. The helper yields complete typed
snapshots, filters older sequences within each connection, and keeps only the
latest pending snapshot for a slow consumer. Heartbeats detect a dead socket;
explicitly transient failures reconnect until abort with capped shared backoff,
and healthy socket lifetime rotations authorize again with the client's current
token. Flaps retain escalation; a stable connection resets it, and `Retry-After`
is a floor. A factory may return a
`Response` refusal when its runtime exposes the handshake status; the helper
throws the API's `{ code, message }`. Deterministic refusals and unknown errors
stop the watch. A cause-free error event before open checks project access
through the same client and current auth before reconnecting; after open it
defers to its close code. Concrete factory/configuration errors remain permanent.
Abort the signal when finished, including while awaiting a snapshot; breaking
iteration also closes the socket.

## MCP

Any MCP client can manage your account remotely. Add the server
`https://api.moq.pro/mcp`; in Claude Code:

```sh
claude mcp add --transport http moq-pro https://api.moq.pro/mcp
```

The client opens a browser to sign you in and asks you to approve it. The
token it gets lasts 90 days and appears in
[account settings](https://moq.pro/settings/tokens), labelled `mcp` with the
host that publishes the client, where you can revoke it. Browser-based clients
work too: `/mcp`, its discovery documents, and the token endpoint allow any
origin, without cookies.
It has two tools: `search_api` finds management API operations and their
schemas, and `request` calls one under your token's permissions.

Approval picks what the token reaches, as the token form does: every project
or only some, and none, read, or write per permission. The client's `read` or
`write` scope only preselects the project permissions; account, billing,
members, and tokens start at none whatever it asks, so raise them only if you
want the agent to manage those too. The token response's `scope` lists what
you granted as `family:level` entries.
Any token can revoke itself with `DELETE /v1/account/tokens/current`, which
`npx @moq/pro logout` does.

[Quickstart](/quickstart), [CLI reference](/cli), and
[llms.txt](/llms.txt) carry the setup commands and management API docs.
Use the [upstream moq skill](https://github.com/moq-dev/moq/blob/main/skills/moq/SKILL.md)
for media publishing and watching.
