Set up Expand for Claude Code with the WebFetch hook and MCP tools.
Route Claude Code's WebFetch through Expand so pages return as rendered Markdown, and register the Expand MCP server in the same step. One install command does both.
expandai login
expandai hook install claude-code projectRun this from your project root. Project setup writes .claude/settings.json and .mcp.json. The hook install also registers MCP, so you do not run a separate mcp install.
Verify it worked:
Use Expand to fetch https://news.ycombinator.com.
Show me the first 10 lines of Markdown and confirm the Fetch succeeded.Optional auth check:
| Piece | What it does |
|---|---|
| WebFetch hook | Adds a Claude Code PreToolUse hook for WebFetch that runs expandai hook claude-code, falling back to npx -y expandai when the CLI is not installed globally. |
WebFetch deny rule | Adds WebFetch to permissions.deny in the same settings.json, which removes Claude Code's built-in WebFetch from the toolset for that scope. Global scope means every Claude Code session on the machine. Uninstall restores it. |
With the deny rule in place, Claude Code does not offer WebFetch at all, so the model reaches for Expand's fetch tool and reads a clean, rendered version of the page instead of raw HTML. Denying the tool rather than intercepting each call is what keeps the transcript free of a refusal error on every fetch. The hook remains installed as a fallback: if the deny rule is removed or overridden, the hook catches WebFetch and routes it through Expand instead. The MCP server adds native fetch and fetch_search tools for follow-up fetches and Highlights search across your snapshots.
For Claude Code, the hook path is the recommended full setup. It handles WebFetch and installs MCP in one command.
Project scope is the default. Use global scope when you want Expand in every Claude Code session.
| Scope | Command | Hook config | MCP config | Use when |
|---|---|---|---|---|
| Project | expandai hook install claude-code project | <project root>/.claude/settings.json | <project root>/.mcp.json | You want Expand enabled for one repo. |
| Global |
Commit project-scoped config only if the team wants Expand enabled for collaborators. Collaborators do not need a global CLI install: the hook falls back to npx -y expandai at runtime. They still need to authenticate once with npx expandai login.
| Integration | Claude Code support | Use it when |
|---|---|---|
| Hook | Recommended | You want Claude Code WebFetch to use Expand automatically. |
| MCP | Installed by hook setup | You want native tools such as fetch and fetch_search. |
| Skill |
The hook is the recommended full setup, and it installs MCP for you. The Skill is an optional add-on for shell-based CLI use, not a replacement for the hook.
expandai skill install claude-code projectRead Expand Skill for Skill behavior and lifecycle.
Remove the Expand WebFetch hook, the WebFetch deny rule, and the Expand MCP entry for a scope. A WebFetch deny rule you added yourself is left in place. The hook is what marks the rule as ours — install writes both together — so uninstall removes the rule only when it also removes the hook. If you delete the hook by hand first, clear the deny rule yourself:
expandai hook uninstall claude-code projectFor global setup:
expandai hook uninstall claude-code global<project root>/.claude/settings.json contains expandai hook claude-code.WebFetch.Run expandai login from your terminal, then try the verification prompt again. Confirm your session with expandai whoami.
Do not paste API keys into Claude Code config for normal local setup.
<project root>/.mcp.json contains an expandai server.~/.claude.json contains an expandai server.Use expandai hook install claude-code project. The stale command expandai hook claude is not correct and will not install the hook.
| MCP server | Registers the Expand MCP server as expandai with expandai mcp run (written as npx -y expandai mcp run when the CLI is not on PATH at install time). |
| Shared auth | Uses local Expand CLI auth from expandai login; no API key is written into Claude Code config. |
expandai hook install claude-code global |
~/.claude/settings.json |
~/.claude.json |
| You want Expand across projects. |
| Optional |
| You want extra instructions for shell-based CLI use. |