Expand AI logo
DocsDocs
Glow Active
API Reference
Login

Documentation

Get started

IntroductionWhy ExpandQuickstartAuthenticationConnect your agent (MCP)

Products

OverviewFetching a URLBatched Fetch
API reference

SDKs & tools

TypeScript SDK
CommandsSkill & hooks
MCP tools & resourcesDocs for agents

Reference

API referenceErrors & retriesPricing & UsageLimitsConcurrency tiersFAQ
Browse docs

Get started

IntroductionWhy ExpandQuickstartAuthenticationConnect your agent (MCP)

Products

OverviewFetching a URLBatched Fetch
API reference

SDKs & tools

TypeScript SDK
CommandsSkill & hooks
MCP tools & resourcesDocs for agents

Reference

API referenceErrors & retriesPricing & UsageLimitsConcurrency tiersFAQ

CLI commands

Every expandai command, argument, flag, and default. Fetch a page, highlight it, read its Appendix, sign in, set up a coding agent, and clean up.

expandai is the Expand command line. You give it a URL and get Markdown text back on stdout, or a JSON object with --format json. The same binary signs you in, runs the local MCP server, and installs the Expand Skill and hooks into coding agents.

npm install -g expandai

Every command also runs without a global install, through npx -y expandai <command>.

Most common

expandai fetch https://news.ycombinator.com



expandai fetch https://www.figma.com/pricing/ --format json
expandai fetch https://docs.stripe.com/webhooks --highlights "signature verification"
expandai login
expandai whoami

Command index

CommandDefinition
expandai fetch <url>Fetch a page and print Markdown text. --format json prints a JSON object.
expandai fetch <url> --highlights <query>Fetch a page and print Fetch Highlights for the query.
expandai snapshots get <snapshotId>Read the public Snapshot catalog.
Note
Batched Fetch has no CLI command. Start and poll a run through the TypeScript SDK or the API. See Batched Fetch.

Fetch

expandai fetch <url>

Fetch a page and print it.

expandai fetch https://www.figma.com/pricing/
ArgumentDefinition
urlThe page to fetch. http or https only. Input without a scheme gets https:// added. The hostname needs a dot, or is localhost.
OptionDefinitionDefault
--formattext prints Markdown text. json prints a JSON object.text
--highlightsA query. Prints Fetch Highlights for it instead of the page.None
Note
The CLI has no --include flag, so the include options stay at their defaults. To choose layers, use the TypeScript SDK or the API.

Without --highlights, --format text is Markdown Mode: the CLI calls POST /v1/fetch and prints the Markdown text, frontmatter first. --format json is JSON Mode: the CLI calls POST /v1/fetch/json and prints the JSON object, with the Main Markdown in markdown, the State JSON in json, and the Snapshot in meta.

expandai fetch https://www.figma.com/pricing/ --format json
Note
When the Fetch returns no Markdown, the command fails with No markdown content was returned. When the origin never answered, --format text fails with the reason, and --format json prints the origin error object instead of content. See Errors & retries.

Highlights

Two commands return snippets. expandai fetch --highlights makes a new Fetch and highlights it in the same request. expandai snapshots get highlights a Snapshot you already have. How they differ, and how to tune --max-results and --min-score, is on Two ways to highlight.

expandai fetch <url> --highlights <query>

Fetch a page and print Fetch Highlights for the query.

expandai fetch https://docs.stripe.com/webhooks --highlights "signature verification" --max-results 5

With --highlights, the CLI always calls POST /v1/fetch/json, whatever --format says. --format text prints each snippet with its source, its score, and a citation link. --format json prints the whole JSON object, with the snippets under data.highlights.snippets and a citationUrl added to each one.

Note
Zero snippets is an error on the command line. --format text fails with No snippets were returned. Lower --min-score and try again.

expandai snapshots get <snapshotId>

Read the public Snapshot catalog without authentication. The default text output is Markdown; --format json returns the catalog as JSON.

expandai snapshots get <snapshotId>

Add --highlights "query" to get relevant passages. This requires authentication and costs one Highlights credit.

expandai snapshots get <snapshotId> --highlights <query>

Print Snapshot Highlights for a page you already fetched. The CLI calls POST /v1/snapshots/<snapshotId>/highlights, so the page is not fetched again.

expandai snapshots get 019c0000-0000-7000-8000-000000000020 --highlights "retry policy"
ArgumentDefinition
snapshotIdmeta.snapshotId from an earlier --format json Fetch, or the Snapshot ID in the note a hook prepends.
OptionDefinitionDefault
--highlightsQuery for relevant passages in the Snapshot.None
--formattext prints the snippets. json prints the JSON object.text

Snapshot Highlights uses the Main Markdown and State JSON. The Appendix is not searched from the CLI.

Warning
Pass meta.snapshotId, the capture's own ID. meta.resources.snapshotId is the public Snapshot ID and returns 404 FetchSnapshotHighlightsNotFound. See Two IDs.

Appendix

expandai appendix <snapshotId>

Read the Appendix of a page you already fetched. Where Fetch moved navigation, a footer, or related links out of the Main Markdown, the Markdown text carries a marker on its own line:

[appendix omitted: 14 links ยท ~320 tokens] {612}

{612} is the evidence ID of the first omitted block. Pass it with --id to read that block, or leave --id off for the whole Appendix.

expandai appendix 019c0000-0000-7000-8000-000000000020 --id 612
expandai appendix https://expand.land/s/019c0000-0000-7000-8000-000000000020/
ArgumentDefinition
snapshotIdmeta.snapshotId from a --format json Fetch, or the capture URL from the playground: frontmatter line of Markdown text.
OptionDefinitionDefault
--idThe evidence ID from a marker.The whole Appendix
--formattext prints a citation line, then the Markdown. json prints snapshotId, evidenceId, playground, , and .

The command reads the public Snapshot routes on the Playground host. It needs no API key and starts no new Fetch.

Note
A bare ID is resolved against EXPAND_PLAYGROUND_HOST, which defaults to the production Playground. Pass the capture URL when the Snapshot came from another stack.

Auth and configuration

Signing in versus API keys, and how each surface sends the key, is on Authentication.

expandai login

Store credentials for the CLI, the local MCP server, and the hooks.

expandai login

In a terminal the command asks how you want to authenticate. Browser Login opens a page where you approve the device. API Key prompts for a key and never shows it in your shell history. When credentials are already stored, the command asks before replacing them.

When no terminal is attached, or a coding agent is running the command, only expandai login --json is accepted. It starts or resumes one device authorization and prints one JSON result. status is authorization_required, with authorization.url and authorization.userCode to show the user, completed, or error. Run the same command again after the user approves.

expandai whoami

Show the account, organization, and credential the CLI is using.

expandai whoami
expandai whoami --format json
OptionDefinitionDefault
--formattext prints a short status. json prints authenticated, user, organization, and authentication. When not signed in, mode is preview, unauthenticated, credential-rejected, or identity-unavailable.

With no stored credentials, whoami reports Anonymous (free preview), and every Fetch runs against a free preview session until you sign in.

expandai logout

Clear stored credentials.

expandai logout

In a terminal the command also offers to remove installed hooks, Skills, and MCP entries. Outside a terminal it only clears credentials. Run expandai uninstall for the rest.

Environment and config

NameDefinition
EXPAND_API_KEYAn API key. A stored login from expandai login or expandai init takes precedence over it, unless the login was issued by a different API origin. The CLI logs a warning either way.
EXPAND_API_URLThe API origin. Overrides the config file.
EXPAND_APP_URLThe web app origin the CLI points agents at. Default .

Credentials and settings are stored in $XDG_CONFIG_HOME/expandai/config.json, which is ~/.config/expandai/config.json on every platform when XDG_CONFIG_HOME is unset.

Agent setup

These commands wire Expand into a coding agent. The hosted MCP server needs none of them. See Connect your agent (MCP) for that path, and CLI: Skill & hooks for what the local setup adds.

Every install takes a <host> and a <scope>. Hosts are claude-code, cursor, opencode, codex, and fx. Scope is global, for every session on the machine, or project, which writes into the current working directory. Run project installs from the project root.

Note
The CLI shows a smaller command set when a coding agent runs it. When stdout is not a terminal, or CLAUDECODE, CURSOR_TRACE_ID, or CODEX_RUN_ID is set, mcp install, mcp uninstall, skill, hook install, and hook uninstall are hidden, and expandai init --json is the setup command. EXPANDAI_CLI_CONTEXT=human or =agent overrides the detection.

expandai init

Sign in and configure the coding agents on this machine in one step.

expandai init
expandai init --detect
expandai init --harnesses claude-code,cursor --scope global
OptionDefinitionDefault
--detectPrint the agents setup would configure, and change nothing.Off
--harnessesComma-separated agents to configure, from claude-code, cursor, opencode, codex, fx.

In a terminal, init asks for the scope, shows the detected agents with all of them selected, and, when no usable credentials are stored, prints a URL and a code to approve in the browser. What each agent receives:

AgentWhat init configures
Claude CodeThe Expand Skill and the MCP server. Nothing is written to settings.json.
CursorThe Expand Skill and the MCP server.
CodexThe Expand Skill and the MCP server.
OpenCodeThe Expand Skill, the MCP server, and the web-fetch hook.

With --json, a sign-in that needs the browser returns status: "authorization_required" with authorization.url and authorization.userCode. Run the same command again after the user approves. Nothing is pasted back.

expandai status

Report what is configured for one agent and scope. The command reads and writes nothing.

expandai status --harness claude-code --scope global
expandai status --harness opencode --scope project --json
OptionDefinitionDefault
--harnessclaude-code, cursor, opencode, codex, or fx.Asked in a terminal. Required with --json.
--scope or .

The text output lists the auth state, any pending authorization, whether the Skill and the MCP server are configured, the web-fetch hook for OpenCode, and whether the agent needs a restart to pick the configuration up.

expandai mcp run

Run the Expand MCP server over stdio.

expandai mcp run
expandai mcp run --docs
OptionDefinitionDefault
--docsAlso serve the expand://about and expand://start resources.Off

Agents launch this command from their MCP config. You rarely run it by hand. It uses the credentials from expandai login, so no key is written into the agent's config. The tools are on MCP tools & resources.

expandai mcp install <host> <scope>

Register the MCP server in one agent's config. expandai mcp uninstall <host> <scope> removes it.

expandai mcp install cursor project
expandai mcp uninstall cursor project
HostGlobal configProject config
claude-code~/.claude.json.mcp.json
cursor~/.cursor/mcp.json.cursor/mcp.json

The entry is named expandai and runs expandai mcp run. When expandai is not on PATH at install time, the entry runs npx -y expandai mcp run instead.

In project scope, fx and Claude Code read the same .mcp.json. fx uses an entry Claude Code wrote, and uninstalling Claude Code's while fx is still set up in the project leaves fx an entry of its own. fx asks you to approve a project's servers before it connects them. fx mcp trust approve expandai approves Expand's ahead of time.

expandai skill install <host> <scope>

Copy the Expand Skill into one agent's skills directory. expandai skill uninstall <host> <scope> removes it.

expandai skill install claude-code project
expandai skill uninstall claude-code project
HostGlobal directoryProject directory
claude-code~/.claude/skills/expandai/.claude/skills/expandai/
cursor~/.cursor/skills/expandai/.cursor/skills/expandai/

The Skill is one SKILL.md. What it teaches is on CLI: Skill & hooks.

Recommendation
Commit a project-scoped Skill only when you want it enabled for everyone who clones the repository.

expandai hook install <host> <scope>

Install the Expand Skill, register the MCP server, and install the web-fetch hook for one agent, in that order. Hosts are claude-code and opencode. expandai hook uninstall <host> <scope> removes the hook and the MCP entry.

expandai hook install opencode project
expandai hook uninstall opencode project
HostHook
opencodeA plugin file, expandai-webfetch.js, in ~/.config/opencode/plugins/ or .opencode/plugins/.
claude-codeNone. The hook step prints a notice and writes nothing. The Skill and the MCP server are still installed.

What the hook does is on CLI: Skill & hooks.

expandai hook claude-code and expandai hook opencode

The protocol runners the hooks call. Each reads one JSON payload from stdin, fetches the URL in it through Expand, and writes the result to stdout.

expandai hook opencode

Agents run these when a hook fires. You do not call them yourself.

Cleanup

expandai uninstall [target] [host] [scope]

Remove hooks, Skills, and MCP entries.

expandai uninstall
expandai uninstall mcp codex project
expandai uninstall skill claude-code global
ArgumentDefinitionDefault
targetall, hook, skill, or mcp.all
hostclaude-code, , , , or .
Warning
Project-scoped files are looked up from the current working directory. Run uninstall from the same project root you installed from, or the files are not found.

Telemetry

The CLI sends anonymous usage events, and says so the first time you run it in a terminal.

expandai telemetry status
expandai telemetry disable
expandai telemetry enable

EXPANDAI_NO_TELEMETRY=1 or DO_NOT_TRACK=1 turns it off without changing the config file.

Crawl

expandai crawl <url> <directory> crawls a site into a folder of Markdown files you can resume. expandai sync [url] [directory] creates or upgrades a synchronized crawl and keeps the folder current. Its subcommands are sync status, sync run, sync install, which installs a systemd user timer on Linux or a launchd agent on macOS, and sync uninstall.

expandai crawl https://docs.stripe.com ./stripe-docs --include '/docs/**'
expandai sync https://docs.stripe.com ./stripe-docs --every 6h

Both commands exit 0 when nothing changed, 3 when at least one page changed, 2 on a usage error, and 1 on any other failure. expandai crawl --help and expandai sync --help list every flag. What a crawl is, and how it finds pages, is on Crawl and WebSync.

Next steps

  • CLI: Skill & hooks: what the local setup adds, and what the Skill teaches an agent.
  • MCP tools & resources: the tools behind expandai mcp run.
  • Two ways to highlight: Inline and Snapshot Highlights, and how to tune them.
  • Fetching a URL: the two modes and the include options the CLI leaves at their defaults.
PreviousTypeScript SDK
NextSkill & hooks

On This Page

Most commonCommand indexFetchexpandai fetch <url>Highlightsexpandai fetch <url> --highlights <query>expandai snapshots get <snapshotId>expandai snapshots get <snapshotId> --highlights <query>Appendixexpandai appendix <snapshotId>Auth and configurationexpandai loginexpandai whoamiexpandai logoutEnvironment and configAgent setupexpandai initexpandai statusexpandai mcp runexpandai mcp install <host> <scope>expandai skill install <host> <scope>expandai hook install <host> <scope>expandai hook claude-code and expandai hook opencodeCleanupexpandai uninstall [target] [host] [scope]TelemetryCrawlNext steps
expandai snapshots get <snapshotId> --highlights <query>
Snapshot Highlights on a page you already fetched. No new Fetch.
expandai appendix <snapshotId>Read the Appendix of a page you already fetched. No new Fetch.
expandai loginSign in with the browser, or store an API key.
expandai whoamiShow the account, organization, and credential the CLI is using.
expandai logoutClear stored credentials.
expandai initSign in and configure the coding agents on this machine.
expandai statusReport what is configured for one agent and scope. Changes nothing.
expandai mcp runRun the Expand MCP server over stdio.
expandai mcp install <host> <scope>Register the MCP server in one agent's config.
expandai skill install <host> <scope>Copy the Expand Skill into one agent's skills directory.
expandai hook install <host> <scope>Install the Skill, the MCP server, and the web-fetch hook for one agent.
expandai uninstall [target] [host] [scope]Remove hooks, Skills, and MCP entries.
expandai telemetry statusShow whether anonymous usage telemetry is on.
expandai crawl <url> <directory>Mirror a site into a folder of Markdown.
--max-results
Most snippets to print when --highlights is set, 1 to 50.
5
--min-scoreLowest relevance score a snippet needs when --highlights is set, 0 to 1.0.6
--max-results
Most snippets to print, 1 to 50.
5
--min-scoreLowest relevance score a snippet needs, 0 to 1.0.6
citationUrl
markdown
text
text
https://expand.ai
EXPAND_PLAYGROUND_HOSTThe Playground host used to resolve bare Snapshot IDs and build citation links.
HTTP_PROXY, HTTPS_PROXY, NO_PROXYStandard proxy variables. Upper or lower case.
XDG_CONFIG_HOMEWhere the config file lives.
EXPANDAI_CLI_CONTEXThuman or agent. Forces the command set described under Agent setup.
EXPANDAI_NO_TELEMETRYSet to 1 to turn off anonymous usage telemetry. DO_NOT_TRACK works too.
DEBUGSet to true for debug logging on stderr.
Every detected agent
--harnessThe agent running the command, as a detection hint.None
--scopeproject or global.Asked in a terminal. Required with --json.
--setup-tokenA short-lived, single-use token from the dashboard's Copy setup prompt. Authorizes setup with no browser step.None
--jsonPrint one JSON result. Required when an agent runs the command.Off
fxThe Expand Skill and the MCP server.
project
global
Asked in a terminal. Required with --json.
--jsonPrint one JSON result.Off
opencode
~/.config/opencode/opencode.json
opencode.json
codex~/.codex/config.toml.codex/config.toml
fx~/.fx/mcp.json.mcp.json, shared with Claude Code
opencode~/.config/opencode/skills/expandai/.opencode/skills/expandai/
codex~/.agents/skills/expandai/.agents/skills/expandai/
fx~/.fx/skills/expandai/.fx/skills/expandai/
cursor
opencode
codex
fx
Every host
scopeglobal or project.Both scopes