> For the complete documentation index, see [llms.txt](https://docs.mediafier.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mediafier.ai/connect/agent-lifecycle.md).

# Agent Lifecycle

Each stage of an agent's life on Mediafier (discover, provision, operate, monitor, recover, govern, deprovision) mapped to the MCP tools and app pages that handle it, plus what still needs a person.

> **One map from first discovery to deprovisioning.** For each stage, the MCP tools an agent calls itself and the app pages a person uses. Tool names are the ones `tools/list` returns today; take exact arguments from that live response.

The endpoint for every stage is `POST https://mcp.mediafier.ai/mcp`. What a call returns depends on who is calling: a signed-in person's session sees that person's permissions, and an Agent Credential sees the scopes it was issued with. Access is invite-only pre-launch — see [Getting Access](https://docs.mediafier.ai/overview/access.md).

## Stage by stage

| Stage           | The agent, over MCP                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | A person, in the app                                                                                                                                                                                                                                                                                                           |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Discover**    | `tools/list` returns the tools your authorization grants. `search_tools` finds a tool from a plain-language description of the task. `resources/list` lists governed resources for signed-in sessions.                                                                                                                                                                                                                                                                                      | **Agents & Tools → My Toolbox** shows the tools set up for the organization.                                                                                                                                                                                                                                                   |
| **Provision**   | OAuth sign-in from Claude, ChatGPT, and other [supported clients](https://docs.mediafier.ai/connect/compatibility.md); the client registers itself; the person picks the organization. `mediafier_account_list_api_keys` lists Agent Credentials (no secrets); `mediafier_account_create_api_key` and `mediafier_account_create_oauth_client` issue new ones once another admin approves. `billing_create_topup_handoff` prepares a top-up link for an owner or admin (signed-in sessions). | Sign up and create the organization. **Settings → Organization → Members** invites people. **Settings → Connect your client → API keys** issues Agent Credentials (admins). Any member buys credits (**Buy Credits**); **Billing & usage** sets the plan and auto top-up.                                                      |
| **Operate**     | Any tool from `tools/list`. `mediaclaw_list` and `mediaclaw_inspect` show which MediaClaws the organization can run; `mediaclaw_invoke` starts a run.                                                                                                                                                                                                                                                                                                                                       | The **Media Library** holds the files and results agents work on.                                                                                                                                                                                                                                                              |
| **Monitor**     | `get_job_status` reports a job's state and next actions. `get_run_result` returns what a run produced. `credit_status` reports operational status to any caller, with credit tier and forecast for signed-in sessions only. `billing_get_status` reports balances and spend limits (signed-in sessions). `get_spend_summary` totals spend (owners and admins). `tool_call_audit_search` searches tool-call history.                                                                         | **Usage & Logs → Usage** and **Activity Logs**. **Billing & usage → Usage Ledger** and **Billing History**.                                                                                                                                                                                                                    |
| **Recover**     | Errors carry a `trace_id`. `tool_call_audit_search` finds gateway-processed calls by it; earlier sign-in or request failures may need support. `get_tool_call_diagnostic_detail` explains a failed call (signed-in owners and admins). If an outcome is unknown, check `get_job_status` before retrying.                                                                                                                                                                                    | [Troubleshooting](https://docs.mediafier.ai/connect/troubleshooting.md) lists common errors. Quote the `trace_id` to support.                                                                                                                                                                                                  |
| **Govern**      | Discovery is authorization-scoped, and spend limits are checked before a call runs. Account-changing tools (creating, rotating, or revoking a credential, storing or deleting a secret) are requested by a signed-in person, not an Agent Credential, and wait for approval by another admin or owner.                                                                                                                                                                                      | **Members** sets roles. **Billing & usage → Spending Controls** sets limits. **Settings → Connect your client → Connected agents** shows the clients you have authorized. See [The Gateway](https://docs.mediafier.ai/platform/gateway.md) and [Credits & Billing](https://docs.mediafier.ai/overview/credits-and-billing.md). |
| **Deprovision** | `mediaclaw_cancel` stops a run; cancelling a finished run is a no-op. `mediafier_account_revoke_api_key` and `mediafier_account_revoke_oauth_client` disable a credential, and `mediafier_account_regenerate_api_key` and `mediafier_account_rotate_oauth_client_secret` issue a new secret, each once another admin approves. Media Library archive tools archive projects, collections, and bundles, and archiving can be undone.                                                         | **API keys**: **Revoke** disables a credential at once; **Regenerate** issues a new secret. **Connected agents**: **Disconnect** revokes your authorizations. **Members**: admins remove people. **General**: the owner deletes the organization (some cases go to support).                                                   |

## Agent Operations tools

The `agent_operations_*` tools supervise MediaClaw runs and the work around them. They are reachable over MCP today for signed-in members, each within its role limit and scoped to your own organization. The Agent Operations views in the app are not yet open for self-service — see [Agent Operations](https://docs.mediafier.ai/platform/agent-operations.md).

| Stage       | Tools                                                                                                                                                                                                                                |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Operate** | `agent_operations_create_workstream`, `agent_operations_advance_workstream_step`, `agent_operations_prepare_work_brief`, `agent_operations_commit_work_brief` (members).                                                             |
| **Monitor** | `agent_operations_query_overview`, `agent_operations_query_executions`, `agent_operations_query_run_timeline`, `agent_operations_query_workstreams`, `agent_operations_query_summary_spend`, and the other query reads (any member). |
| **Recover** | `agent_operations_retry_execution` and `agent_operations_cancel_execution` (owners and admins) preview by default; pass `dry_run: false` to apply. `agent_operations_request_human_review` hands a run to a person (members).        |
| **Govern**  | `agent_operations_approve_review`, `agent_operations_reject_review`, `agent_operations_override_review`, `agent_operations_approve_learning_ledger_entry` (owners and admins).                                                       |

Most tools that decide or change work — reviews, approvals, creating or committing work — need a signed-in person; an Agent Credential is refused.

## What still needs a person

These steps happen in a browser, by a person, today:

* **Getting invited.** An agent cannot request or accept an invitation.
* **Creating the organization**, inviting or removing members, and deleting the organization.
* **Approving Agent Credential changes.** A signed-in person can request issuing, rotating, or revoking a credential over MCP; another admin or owner approves it on the **Approvals** page. An organization with a single admin uses the API keys page instead.
* **Paying.** Any member can buy credits in the app. In a signed-in session an agent can prepare a top-up link; an owner or admin completes it. With auto top-up on, credits refill on their own and no one needs to step in.
* **Deleting your user account.** There is no self-serve control yet; contact support.

## Related

* [Agent Quickstart](https://docs.mediafier.ai/connect/agent-quickstart.md) — endpoint, sign-in, first call
* [Authentication & Agent Credentials](https://docs.mediafier.ai/connect/authentication.md) — OAuth sign-in and headless client credentials
* [Audit, Observability & Compliance](https://docs.mediafier.ai/trust/audit-observability-and-compliance.md) — what each audit record holds
* [Agent Operations](https://docs.mediafier.ai/platform/agent-operations.md) — the supervision model behind the `agent_operations_*` tools
