> ## Documentation Index
> Fetch the complete documentation index at: https://docs.morphllm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# morph CLI

> One binary for WarpGrep search, Fast Apply edits, Compact, and chat. Agents call it through their shell.

Coding agents reach Morph through `morph`, a single binary. A [skill](https://docs.morphllm.com/skills.md) tells the agent when to run it; nothing sits in the prompt until it is needed. The MCP server is still published for hosts that cannot run commands ([legacy MCP](https://docs.morphllm.com/mcpquickstart.md)).

```bash Terminal theme={null}
curl -fsSL https://www.morphllm.com/install.sh | bash
morph token set --api-key sk-...      # https://www.morphllm.com/dashboard/api-keys
morph install                         # skills into Claude Code, Codex, Cursor, OpenCode
morph search "where are API keys validated"
```

Signed in? `npx -y @morphllm/morph-setup --morph-api-key YOUR_KEY` does the same three steps in one command.

## Install

| | |
| - | - |
| **Platforms** | macOS arm64/x64, Linux x64/arm64 |
| **Location** | `~/.local/bin/morph` (override with `MORPH_INSTALL=/path`) |
| **Updates** | Checked on every run; re-run the installer to upgrade |
| **Key resolution** | `--api-key` flag → `MORPH_API_KEY` env → active profile in `~/.config/morph/config.json` |

## Search a codebase

```bash theme={null}
morph search "how does the billing webhook retry" [--repo ../other] [--json] [--timeout 120]
morph search "where is the app router entry" --github vercel/next.js [--branch canary]
```

WarpGrep runs grep → read → follow-imports turns against the repo and returns the files and line ranges that answer the question. `--github` shallow-clones into `~/.cache/morph/github` on first use (needs `git`; private repos use your git credentials) and searches that checkout, so result paths can be read directly.

Output: a summary, then `── <file>:<lines>` blocks with the code. Progress goes to stderr. `--json` returns:

```json theme={null}
{ "success": true, "summary": "...", "contexts": [{ "file": "src/billing/webhook.ts", "lines": "40-88", "content": "..." }], "timing": { "totalMs": 2127 } }
```

| Flag | Default | |
| - | - | - |
| `--repo <path>` | current directory | Local repository root |
| `--github <owner/repo\|url>` | | Search a GitHub repo instead of `--repo` |
| `--branch <name>` | repo default | With `--github` |
| `--include`, `--exclude <globs>` | | Comma-separated |
| `--json` | off | Structured result on stdout |
| `--timeout <s>` | 120 | Cancels the search and exits 1 |

## Apply an edit

```bash theme={null}
cat > /tmp/edit.txt <<'EDIT'
// ... existing code ...
export async function fetchUser(id: string) {
  return withRetry(() => client.get(`/users/${id}`), { attempts: 3 });
}
// ... existing code ...
EDIT
morph apply src/users.ts -i "I am adding retries to fetchUser" -u /tmp/edit.txt [--dry-run]
```

Fast Apply merges the snippet into the file at 10,500 tok/s and writes it back. `// ... existing code ...` marks unchanged regions; omitting it deletes what it stood for. `--dry-run` prints the merged file. `-m morph-v3-large` for the larger model.

## Other commands

| Command | |
| - | - |
| `morph chat [-m model] "prompt"` | Streams a completion from a fast general model; reads stdin without a prompt |
| `morph compact [file]` | Compresses a context or conversation file (stdin without a file) |
| `morph curl /v1/... [-X POST] [-d json]` | Authenticated request to `https://api.morphllm.com` |
| `morph models` | Live model list and prices (same data as `/api/models/json`) |
| `morph token set\|new\|info`, `morph profile ...` | Keys and accounts |
| `morph install [--agent a] [--mcp]` | Skills into detected agents; `--mcp` also registers `morph mcp` |
| `morph skills install\|update\|show [name]` | Manage the published skills |
| `morph mcp` | Legacy: serve the MCP tools on stdio |

## Errors

| | |
| - | - |
| Exit 1, `[morph] No API key` | Run `morph token set --api-key sk-...` or set `MORPH_API_KEY` |
| `401` | Key invalid: `morph token info` shows which key is active |
| `429` | Rate limited; honor `Retry-After`. Limits rise once a billing method is on the account |
| `search failed: Timed out after 120s` | Raise `--timeout` or narrow the question |
| `git is required for --github` | Install git; `--github` clones locally |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.