# Start here as an agent

Discover the installation, obtain consent and verify the destination before selecting files.

![Agent connection](../media/agents.webp)

## Connect to the studio

Desktop 0.1.1 includes the CLI and MCP. The first command starts the service and connects to the personal studio of the operating system user. For a self-hosted server or Cloud, select the profile and run `opensocial login` to approve access in the browser. The remote delegation is stored in the system credential vault.

```sh
opensocial doctor --json
opensocial accounts list --json
```

For another installation select the same origin with `--url` or `OPENSOCIAL_URL` on subsequent commands. An existing `OPENSOCIAL_TOKEN` takes precedence over the vault. Check `agents_connection`, the workspace zone and `projects_list`. Retain the account and project IDs, handle, network and `expiresAt`. In **Configurações → Integrações → Limitar acesso**, an owner can restrict accounts and actions across existing and future tools. Restoring defaults returns each connection to its originally authorized access.

## Agent instructions

Install the connector and skills with `opensocial agents setup codex`, `opensocial agents setup claude` or `opensocial agents setup antigravity`. List the bundled guides with `opensocial skills list` and choose the one for your task. Read the `publish` article for the single-post CLI format. MCP clients can read the same bundled instructions as resources at `opensocial://skills/{name}`, for example `opensocial://skills/opensocial-tt-caption-writer`.

For scheduling, call `publications_suggest_time` for each account and the workspace time zone. Show the video, account, final caption and proposed time. After confirmation, pass the reviewed time to `publications_schedule` with `mode: best`, the current version and a stable request key. Hand the TikTok review link to the user. Use immediate delivery for explicit requests. For metrics, query `analytics_list` or `analytics_publication_counts` and include source, period and availability.

## Remote and local MCP

In an HTTP MCP client, configure the studio URL ending in `/mcp` and complete OAuth with PKCE. For local Codex, configure the TOML below with absolute paths. Start a new session, list tools and call `agents_connection`. Doctor checks HTTP connectivity separately from connector registration in your session.

```toml
[mcp_servers.opensocial]
command = "opensocial"
args = ["mcp"]

[mcp_servers.opensocial.env]
OPENSOCIAL_MEDIA_ROOT = "/path/to/videos"
```

Use `resources/list` and `resources/read`, or call `docs_search` with `{"query":"schedule","lang":"en"}` and `docs_read` with `{"id":"campaign","lang":"en"}`. Setting the permitted directory enables `media_upload_file`, `batches_plan_file` and `batches_upload_file` in local MCP. With HTTP MCP, upload bytes to the temporary URL issued by the studio.

## Send files through local MCP

Set `OPENSOCIAL_MEDIA_ROOT` to your media directory and restart the connector. Paths in the examples are relative to that directory. Use an account delegation with media access. Scheduling also requires publish access for the selected accounts.

1. For a single file, call `media_upload_file` with `{"path":"video-01.mp4","projectId":"PROJECT_ID","requestKey":"upload-video-01"}`. Read the JSON in `content[0].text` and keep the media ID. Retry the same upload with the same key.
2. Before scheduling a batch, call `batches_plan_file` with `{"path":"campaign.json"}`. Its `structuredContent` contains the normalized manifest and the plan. Check every destination and pass the returned manifest to `batches_register` when ready.
3. Call `batches_upload_file` with `{"path":"video-01.mp4","batchId":"BATCH_UUID","itemId":"video-01"}`. The result contains `mediaId` and `state: ready`. Repeat for each item, then apply each destination using the campaign guide. If an input is unavailable, check the authorized directory and the filename. If the manifest changed, generate a new batch ID.

## Read offline

```sh
opensocial docs list --lang en
opensocial docs search schedule --lang en --json
opensocial docs read campaign --lang en
opensocial docs path campaign --lang en
```

If MCP is unavailable, use the offline CLI manual and check connector configuration. If a delegation expired, sign in again and look up the existing batch ID.

## Audit delivery

Run `opensocial login --url <origin> --scopes read --no-browser --json`. The first line contains the consent URL. Keep the command running while the owner confirms the connection. The last line reports the connection and expiry. Call `agents_connection` within the actual assistant session to verify the connector is available.

Run `opensocial delivery health --json` to inspect the worker heartbeat, last dispatch, storage availability and alerts. The dashboard displays overdue publications and cases requiring review. The CLI also supports:

```sh
opensocial publications list --account ACCOUNT_ID --from 2026-11-24T00:00:00Z --to 2026-11-25T00:00:00Z --json
opensocial publications get PUBLICATION_ID --json
opensocial accounts posts --account ACCOUNT_ID --from 2026-11-24T00:00:00Z --to 2026-11-27T00:00:00Z --json
```

The date range uses the effective schedule and excludes the end instant. The summary covers every accessible standalone or batch destination in the period, including later pages. Check `coverage` for account restrictions. The corresponding REST and MCP operations are `publications_list`, `publications_summary`, `publications_get`, `delivery_health` and `accounts_remote_posts`.

Inspect the stage, original schedule, next attempt and actions under `diagnosis`. A null cause indicates missing evidence. Call `publications_reconcile` only when `canReconcile` is true. The owner may need to continue the existing upload. If an uncertain delivery has no recoverable reference, open `reviewUrl`. The owner can link a verified remote video or confirm its absence before retrying the original destination. An uncertain retry may duplicate a post.

Remote queries return one page at a time. Pass `next` as `--cursor` to continue. TikTok returns public videos with the independent `video.list` permission. Posting also requires separate publication permission and individual consent. A partial or empty result requires owner verification.

To audit the original schedule after a shift, add `--time-basis original`. The default filter uses the effective schedule.
