Use the CLI with AI agents
Give Claude Code, Cursor, or any terminal-capable AI agent safe, scoped access to your Zanfia workspace.
The CLI is designed to be driven by AI agents as much as by humans: every command has a --json mode, errors carry machine-readable reasons, and authentication works from an environment variable. An agent that can run terminal commands can run your whole workspace.
Prefer MCP when your client supports it
If your AI client speaks MCP (Claude, Cursor, VS Code, ChatGPT), the MCP connection is the more direct route — typed tools, no shell required. The CLI approach below works everywhere else, and is the right choice for scripted pipelines and CI.
Setup
Create a scoped API key
In the dashboard, Integrations → API, MCP and CLI → create a key with only the permissions the agent needs (see Authentication). For a content agent that's typically Products read/write; add Communities only if it should post.
Install the CLI where the agent runs
npm install -g @zanfia/cli
export ZANFIA_API_KEY=YOUR_SCOPED_KEYTell the agent how to use it
Paste instructions like the block below into your agent's configuration (a CLAUDE.md, Cursor
rules, a system prompt, …).
Instruction block to give your agent
Adjust the confirmation rules to your risk tolerance — the key's scopes are the hard boundary; the instructions are the soft one.
Patterns that work well
- Content pipelines — agent drafts lessons in Markdown files, then
courses lesson update … --content-fileand a final humancourses publish. - Community digests —
communities posts --jsonon a schedule, summarize, post the digest withcommunities post create. - Sales reporting —
stats overview --period 7d --jsonpiped into whatever writes your Monday report. - Bulk operations — anything repetitive over ids from a
listcommand; the strict-permutation reorder commands make ordering changes safe to script.
Your agent as a community member
The CLI also works from the other side of a community: a member key lets an agent read and post in a creator's community as that member — its own channels, posts, comments, chat and support tickets, and nothing in the creator's workspace. Public communities with a join handle need no account and no browser:
npx zanfia join crew-of-one
# email → the 6-digit code from the email → member key saved to ~/.config/zanfia/credentials.json
For any other community, generate a key on the creator's platform under Settings → Developer and paste the zanfia auth set-key … command it shows.
The same key is an MCP server at https://app.zanfia.com/mcp (Authorization: Bearer <key>) with a member-scoped tool set, if your client prefers MCP over a shell.
Was this article helpful?

