Connect an AI agent
An AI agent is a tool that can use commands or connected apps for you. Choose the connection based on where the agent runs. The agent must never receive, read, paste, print, or store a Mochi credential.
After choosing a connection, use the generated OpenAPI contract for current authentication requirements and exact operation details.
Choose a connection
| Workload | Use | Credential boundary |
|---|---|---|
| Interactive agent or developer on a local computer | Mochi CLI OAuth | mochi auth login opens Mochi in the browser and stores the approved connection in the OS keychain. The agent sees only structured command results. |
| Scheduled job, CI runner, or unattended server | Organization-scoped API key | An operator creates a key with only the needed permissions. The workload reads it from a server-side secret manager. |
| Agent already connected through Mochi MCP | Existing MCP connection | Keep using that connection. Do not export, exchange, or convert its credential. |
| Third-party browser application | Registered OAuth application | The application sends the user to Mochi for approval and manages its own redirect and refresh flow. |
OAuth is browser-based approval. MCP is the connection standard used by some AI tools. An existing Mochi browser session makes approval smoother because the customer may not need to enter a password again. It does not skip consent: the customer still chooses the organization and approves the requested Public API scopes.
Optional: give the agent the Mochi skill
Install the high-level skill from the public CLI repository:
npx skills add TheMochiApp/mochi-cli --skill mochi-apiThe skill teaches the agent to read /llms.txt, choose the smallest current task guide, and inspect OpenAPI for exact request details. It does not contain a copied endpoint reference or credentials. Installing it does not grant access or expose credentials. Skill installation is separate from publishing the @themochiapp/cli npm package.
Start with this safe prompt—before signing in, creating a credential, or making a request:
Read https://themochi.app/docs/llms.txt. I want to understand how to list up to ten leads for my organization. Do not make requests, sign in, or handle credentials. Tell me the smallest guide and minimum scope.
Connect on a trusted local computer
Use this path only when the agent and customer share a trusted local computer and Mochi has enabled Public API OAuth for that organization. The CLI npm package must also be published and its release instructions verified before this route is available. The Mochi CLI is a command-line tool for making approved, read-only requests.
- Install the Mochi CLI from its canonical repository using the currently published release instructions.
- Inspect the installed command surface with
mochi --help. - Run
mochi auth login, request only the read scopes needed for the task, and complete organization/scope approval in the browser. - Check non-secret state with
mochi auth status. - Run a read command and parse its single JSON result. Branch on
ok; do not scrape human output. - Remove the approved connection with
mochi auth logoutwhen it is no longer needed.
The CLI is intentionally read-only. For a write integration, read the relevant task guide and current OpenAPI
contract. Write a specific plan and use a separately approved direct API integration. Never invent a write-oriented
mochi command.
Connect a scheduled job or server
Use an API key for a scheduled job, CI runner, hosted agent, or server process:
- Name the exact job and organization.
- Request only the scopes used by that job.
- Store the key in the platform secret manager and inject it at runtime.
- Keep it out of prompts, command arguments, source control, logs, screenshots, browser code, and support messages.
- Verify the first request is read-only and organization-bound before enabling a schedule.
- Use separate keys for separate integrations so one workload can be rotated or revoked independently.
See Choose how to authenticate for key replacement and identity rules, Create and manage an API key for the controlled self-serve path, and Choose permissions for the current scope list.
Keep an existing MCP connection
If the customer already connected Mochi through MCP, continue through that connection. Installing the skill does
not require another browser sign-in. The skill may help the agent find public documentation, but it must not ask to
reveal an MCP token or assume that MCP supports every Public API operation. Read Already connected through MCP? before a task needs /v1/.
Confirm the connection safely
A successful setup proves only the intended boundary:
- the selected organization is correct;
- the granted scopes match the task;
- a read returns structured data;
- a disallowed scope or cross-organization resource is denied; and
- no authorization header, token, API key, contact value, or customer payload appears in agent context or logs.
If documentation, OpenAPI, installed CLI help, and observed behavior disagree, stop and record the sanitized X-Request-ID, status, method, path, and UTC time. Do not troubleshoot by printing the credential.