API, MCP Server and the clarive CLI
Clarive publishes one set of operations, the Clarive API, three ways:
- a REST API at
/api/v2 - an MCP server at
/mcp, for AI agents such as Claude Code, Claude Desktop or any other Model Context Protocol client clarive, a command line program for people and scripts
The three are the same operations with the same names, parameters,
permissions and errors. An operation such as job.logs is a REST call
(POST /api/v2/call/job.logs), an MCP tool (job_logs) and a command
(clarive job logs). There are a few hundred of them, grouped in
namespaces: jobs and their logs, topics, rules (readable and writable as
HCL), resources (CIs) and their services, artifacts, git repositories,
remote execution and file shipping, workers, users, roles, projects and the
rest of the administration.
Authentication and tokens¶
Every client authenticates with an API token, a kind of personal access
token (clapat_..., see Personal Access Tokens).
Send it as a header:
Authorization: Bearer clapat_0123456789abcdef...
There are three ways to get one:
clarive loginasks for your username and password and stores a new token.- The
auth.loginoperation does the same over REST:
curl -s -X POST https://clarive.example.com/api/v2/call/auth.login \
-H 'Content-Type: application/json' \
-d '{"login":"jdoe","password":"...","expires_days":30}'
- An administrator runs
cla api-token --user jdoe --days 30on the server, for example for a CI system or an agent.
MCP clients that only speak OAuth (Microsoft Copilot Studio, Microsoft 365
Copilot agents) do not use API tokens: each user signs in to Clarive in the
browser and allows the client, which gets an OAuth token (claoat_...) that
only opens /mcp. See Microsoft Copilot and OAuth.
Tokens made for git in Preferences, and any token limited to some repositories, are git credentials only: the API refuses them. API tokens work for git too.
Tokens are either write or read. A read token can only call operations
that change nothing. The API marks every operation as read, write or
destructive.
Tokens expire (90 days by default, two years at most) and can be listed, disabled and revoked
by their owner (clarive auth list-tokens, clarive auth revoke-token) or by
a user administrator. clarive logout revokes the token in use.
Failed auth.login attempts are throttled per address with the same
Login settings as the web login (config.login.delay_attempts and
delay_duration).
The git-over-HTTP switch for personal access tokens (config.pat.access and
each repository's pat_access) applies to git only. It does not stop a token
from using the API.
Permissions¶
The API runs every operation as the token's user, with that user's roles,
exactly as the web interface would. An operation needs the same actions as
the screen that does the same thing. Where a screen forgot to check a
permission, the API checks it anyway. The permission of each operation is
listed in the catalog.
In maintenance mode only administrators can use the API.
REST API¶
| Request | What it does |
|---|---|
GET /api/v2/ping |
Server and API version, no token needed |
GET /api/v2/ops |
The catalog: every operation with its JSON schema, no token needed |
POST /api/v2/call/<op> |
Calls an operation. The JSON body holds its parameters |
GET /api/v2/call/<op>?a=1&b=2 |
The same, for operations that change nothing |
Answers are JSON:
{"ok": true, "data": ...} {"ok": false, "error": {"code": "not_found", "message": "Job `123` not found"}}
The HTTP status follows the error code: invalid_params and failed are
400, unauthorized 401, forbidden 403, not_found 404, conflict 409,
throttled 429, internal 500, unavailable 503.
Lists take limit (default 50, at most 1000) and skip, and answer
{"items": [...], "total": N, "skip": 0, "limit": 50}.
To upload files, send multipart/form-data with a params field holding the
JSON parameters and one part per file parameter. JSON clients can also send a
file inline as {"filename": "app.zip", "content_base64": "..."}.
Operations that return a file answer with the file itself and a
Content-Disposition header. Add ?inline=1 to get it as base64 in JSON.
MCP server¶
/mcp speaks the Model Context Protocol over Streamable HTTP. Every
operation the user may call, except logging in, is a tool, with a description, a JSON schema and
hints that say whether it is read-only or destructive. Every tool call fires
the event.mcp.call event, which records it and lets an event rule refuse it.
claude mcp add clarive -- clarive mcp claude mcp add --transport http clarive https://clarive.example.com/mcp \ --header "Authorization: Bearer clapat_..."
The MCP Server section covers connecting Claude Code, Claude Desktop, Cursor, VS Code and other clients, the tools and their answers, auditing and refusing calls, examples and the protocol details.
The clarive CLI¶
clarive is a single binary for Linux, macOS and Windows, published with
every Clarive release and downloadable from clarive.com (see
Install). Its commands come from the server's
catalog, so a new operation on the server is a new command without a new
CLI. It prints tables on a terminal and
JSON when its output is piped, which is what scripts and agents want.
clarive login --url https://clarive.example.com clarive api search job log # find an operation clarive job logs 1234 --follow clarive rule edit "Deploy web" # edit a rule as HCL in $EDITOR
The clarive CLI section covers installing it, logging in and profiles, commands and parameters, output and exit codes, the shortcuts, recipes for CI pipelines and day-to-day work, and troubleshooting.