NEWOur agents now make the SEO fixes on your site and check what worked →

SEO CLI for AI Agents

Any AI agent that can run a shell command can use SEOmatic through the seomatic CLI: Claude Code, Codex, Cursor, OpenClaw, Hermes Agent, nanoclaw, Paperclip, Grok Build, Kimi Code, DeepSeek Harness, Manus and the rest. The agent reads your Search Console data, audits pages and calls the full tool surface, the same as REST and MCP. Node 18+, zero dependencies, no install.

Set up an agent#

Three steps, all in the shell your agent already uses. The seomatic skill teaches the agent which commands to run and when; the CLI does the work.

# 1. Give the agent the seomatic skill
npx skills add Minh42/seomatic-mcp

# 2. Sign in without a local browser: approve a short code from any device
npx -y seomatic login --device

#    or, in a container or CI, use a key from Settings > AI Agents > Use SEOmatic From Your Own Tools
export SEOMATIC_API_KEY=smk_live_...

# 3. Check the connection, then let the agent work
npx -y seomatic me --json
npx -y seomatic tools --json

Every command takes --json, which puts exactly one JSON value on stdout so an agent can parse it. Exit code 1 means the call was wrong and 2 means it could not complete, so an agent knows when a retry is worth it.

Agents that use the SEOmatic CLI#

Quick start#

Two commands need no account and no key. Copy any line and run it.

# 1. Audit any URL. No account.
npx seomatic audit https://example.com

# 2. Find crawl-budget waste in a server log. No account.
npx seomatic logs /var/log/nginx/access.log

# 3. Sign in (creates a free account if you have none), then read
#    your own Search Console data.
npx seomatic login
npx seomatic gsc top-queries --days 28

Sign in#

seomatic login opens your browser on SEOmatic's approval screen, the same one Claude and ChatGPT use. Pick the workspace, approve, and the key comes back to the terminal. Nothing to copy from the dashboard.

  • The key is kept in the macOS Keychain, the Linux keyring, or encrypted with Windows DPAPI; where none is available, in ~/.config/seomatic/credentials.json, readable only by you. It is valid for one year.
  • Each computer gets its own key. It shows in Settings > AI Agents > Use SEOmatic From Your Own Tools, under your computer's name. seomatic logout revokes it.
  • Choosing a workspace needs the admin role there, the same right as creating a key in Settings.
  • Over SSH or on a server, seomatic login --device shows a short code to approve from any browser, on any device (chosen automatically when there is no local browser).
  • In CI, set SEOMATIC_API_KEY to a key from Settings instead.
npx seomatic login            # opens the browser
npx seomatic login --device   # SSH / servers: approve a code anywhere
npx seomatic me               # workspace, scopes, Search Console state
npx seomatic logout           # revoke and forget

# Tab completion (needs a global install: npm i -g seomatic)
seomatic completion zsh > "${fpath[1]}/_seomatic"

# CI: a key from Settings > AI Agents > Use SEOmatic From Your Own Tools
export SEOMATIC_API_KEY=smk_live_...

Several client workspaces? Give each a profile: seomatic login --profile acme, then add --profile acme to any command. The key is only ever sent over https.

Key order: --key, then SEOMATIC_API_KEY, then your login.

Commands#

CommandAuthDescription
npx seomatic audit <url>no accountAgent-readiness + SEO surface check for any URL.
npx seomatic logs <access.log>no accountCrawl-budget analysis from a server access log (or - for stdin).
npx seomatic loginfree accountSign in with your browser: approve on SEOmatic and the key comes back to the terminal. Over SSH or on a server it shows a code to approve from any browser (--device). Creates a free account if you have none.
npx seomatic logoutfree accountRevoke the saved key and remove it from this computer.
npx seomatic mesigned inIntrospect the key: workspace, scopes, what the plan allows, GSC connection.
npx seomatic gsc top-queriessigned inTop Search Console queries. Flags: --days N, --limit N.
npx seomatic gsc top-pagessigned inTop Search Console pages. Flags: --days N, --limit N.
npx seomatic toolssigned inList every tool this key can call (the full surface). --group read|acts to filter.
npx seomatic tools describe <name>signed inOne tool's description and parameters.
npx seomatic tools call <name>signed inInvoke any tool with --data '{...}', @file.json or - (stdin). Proxies POST /v1/tools/{name}, the same surface as REST and MCP. Every call carries an Idempotency-Key: retries never run an acting tool twice, and a slow tool is waited for (--wait).
npx seomatic completion <shell>no accountTab completion for bash, zsh, fish or PowerShell, including tool names. Needs a global install (npm i -g seomatic).

Flags#

FlagMeaning
--jsonJSON to stdout. Works on every command.
--key <key>API key. Overrides SEOMATIC_API_KEY and your login.
--profile <name>Use a separate saved login, one per client workspace. Or env SEOMATIC_PROFILE.
--devicelogin with a code you approve from any browser (automatic over SSH and on headless Linux).
--browserlogin opens a browser even over SSH.
--wait <seconds>How long tools call waits for a slow tool (default 300).
--idempotency-key <k>Collect the answer of an earlier tools call, or repeat it safely (an acting tool never runs twice).
--no-browserlogin prints the sign-in link instead of opening a browser.
--api <base>API base URL. Default https://app.seomatic.ai/api/v1.
--days <n>Lookback window for gsc commands (default 28).
--limit <n>Max rows for gsc commands (default 25).
--data <json>Body for `tools call`: inline JSON, @file.json, or - for stdin.
--group read|actsFilter `tools` by read-only vs acting.
--version, -vPrint the version and exit 0.
--help, -hUsage and exit 0.

What audit checks#

seomatic audit fetches one URL and runs 10 checks (11 with a robots.txt), covering classic SEO and whether an AI answer engine can read the page.

reachabletitlemeta_descriptioncanonicalh1json_ldrobots_txtai_bots_allowedsitemapllms_txtsecurity_txt

npx seomatic audit https://example.com --json
{
  "url": "https://example.com",
  "score": 30,
  "passed": 3,
  "total": 10,
  "checks": [{ "id": "reachable", "ok": true, "detail": "HTTP 200 in 133ms" }]
}

score is passed over total as a percentage. The command exits 0 even when checks fail, because a failing check is a finding rather than a CLI error. Branch on the score, not the exit code.

Exit codes#

The split that matters in CI: 1 means the call was wrong, 2 means we could not complete it. Retry on 2 only.

CodeMeaningWhen
0SuccessCommand ran. Includes an audit where checks FAILED: a failing check is a finding, not a CLI error.
1Usage or API errorUnknown command or flag, missing argument, no key, 401, 403, 402 plan gate. Also bare `seomatic` with no args.
2Runtime failureNetwork unreachable, DNS failure, timeout, HTTP 5xx, a rate limit still hit after waiting, or a tool still running after --wait (the error carries its idempotency_key). The CLI already retries what is safe; retry on 2, fix the call on 1.

Output and piping#

With --json, stdout carries exactly one JSON value: the result, or on failure an error object. Progress goes to stderr. Without it, errors go to stderr.

npx seomatic audit https://example.com --json | jq .score

Branch on code and status; error is a sentence for people and may change wording.

{
  "error": "Free monthly limit reached (5 questions). Upgrade ...",
  "status": 402,
  "code": "FREE_QUOTA_EXCEEDED",
  "upgrade_url": "https://app.seomatic.ai/..."
}

Scripting recipes#

Each of these is a complete, runnable snippet.

# Fail a build when a page regresses
score=$(npx seomatic audit "$URL" --json | jq -r .score)
[ "$score" -ge 80 ] || { echo "SEO score $score < 80"; exit 1; }

# List every check that failed
npx seomatic audit "$URL" --json | jq -r '.checks[] | select(.ok|not) | .id'

# Find AI crawlers wasting budget on errors
npx seomatic logs access.log --json   | jq -r '.bots[] | select(.isAiBot and .wastedCrawlPct > 20)
           | "(.bot) (.wastedCrawlPct)% wasted"'

# Retry only on runtime failures, never on your own bad call
for i in 1 2 3; do
  npx seomatic me --json && break
  [ $? -eq 2 ] || break
  sleep $((i * 2))
done

Troubleshooting#

SymptomCauseFix
not signed inNo login and no key.Run seomatic login, or export SEOMATIC_API_KEY=smk_live_...
saved sign-in is no longer validThe key was revoked in Settings, or is a year old.Run seomatic login again.
Signing in on a server or over SSHThere is no browser on that machine.seomatic login --device shows a code to approve from any browser (chosen automatically over SSH).
TOOL_STILL_RUNNING (exit 2)The tool ran past --wait. It was not stopped.Run the same command with --idempotency-key <the key in the error> to collect its answer (kept 24h for acting tools, 1h for reads).
Fails only behind a company proxyNode ignores HTTPS_PROXY by default.On Node 22.21+ or 24, export NODE_USE_ENV_PROXY=1.
Missing or invalid API keyA wrong or revoked --key or SEOMATIC_API_KEY.Check the key in Settings > AI Agents > Use SEOmatic From Your Own Tools, then run seomatic me.
A tool is missing from `tools`Scope, plan, or a missing connection.seomatic me shows scopes, plan and GSC state.
gsc returns nothingNo connected property, or the 2-3 day Google lag.Connect Search Console, or widen --days.
Acting tool returns a plan gateagents:act needs the Infrastructure plan.Upgrade, or use the read-only tools.
logs reports 0 botsThe log has no user-agent field.Use combined format, which ends with the quoted UA.
Exit 2 with could not reach ...Network, DNS, proxy, or a wrong --api.Check connectivity; omit --api unless self-hosting.

seomatic me --json is the fastest first report to include when asking for help.

digi-business-uk

Each local area page used to take us half a day to create and optimize.


With SEOmatic, we can create hundreds of pages in the same time, which helps our clients make the best use of their budget.


It's transformed how we deliver scalable SEO solutions.

will-hawkins

Will Hawkins

Marketing Director, Digi-Business UK

Give Your Site an SEO Team

Agents read your Search Console data, do the work, and prove what actually moved. You decide what ships.

  • You decide what ships
  • Verified live
  • One-click rollback

14-Day Trial for $1, credited to your first payment.