Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions fern/products/cli-api-reference/pages/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ hideOnThisPage: true
| [`fern downgrade`](#fern-downgrade) | Move the Fern CLI version in `fern.config.json` back to an older version |
| [`fern login`](#fern-login) | Login to Fern CLI via GitHub, Google, Postman, or enterprise SSO |
| [`fern logout`](#fern-logout) | Log out of the Fern CLI |
| [`fern mcp install`](#fern-mcp-install) | Connect Claude Code, Cursor, or Codex to Fern's MCP server |
| [`fern export`](#fern-export) | Export an OpenAPI spec for your API |
| [`fern api update`](#fern-api-update) | Manually update your OpenAPI spec |
| [`fern api enrich`](#fern-api-enrich) | Merge `x-fern-examples` from an overrides file into native OpenAPI examples |
Expand Down Expand Up @@ -857,6 +858,54 @@ hideOnThisPage: true

</Accordion>

<Accordion title="fern mcp install">

Use `fern mcp install` to connect a coding agent to Fern's MCP server, which exposes tools for searching your published documentation and reading your site configuration, analytics, and reader feedback. The command writes the token from [`fern login`](#fern-login) into the agent's config, so the agent doesn't go through a second OAuth flow:

<CodeBlock title="terminal">
```bash
fern mcp install [--client claude|cursor|codex] [--org <org>]
```
</CodeBlock>

From a machine with no Fern CLI yet:

<CodeBlock title="terminal">
```bash
npm i -g fern-api
fern login
fern mcp install
```
</CodeBlock>

Without flags, the command configures every supported agent installed on the machine, adding a `fern` server entry that holds the server URL and an `Authorization` header. Other entries and surrounding content in each file are preserved.

| Client | Config file |
|--------|-------------|
| Claude Code | `~/.claude.json` |
| Cursor | `~/.cursor/mcp.json` |
| Codex | `~/.codex/config.toml` |

The MCP server authenticates a user rather than an organization, so a `FERN_TOKEN` registry token is rejected: log in with [`fern login`](#fern-login) instead. The token written into the agent config doesn't refresh, so when the server starts returning 401s, run `fern login && fern mcp install` again.

### client

Use `--client` to configure specific agents instead of every one detected. Repeat the flag to name more than one.

```bash
fern mcp install --client claude --client cursor
```

### org

Use `--org` to override the organization ID from `fern.config.json`. The organization scopes the server URL to `https://fai.buildwithfern.com/organizations/<org>/mcp`. Outside a Fern project, the command falls back to the unscoped `https://fai.buildwithfern.com/mcp`.

```bash
fern mcp install --org my-org
```

</Accordion>

<Accordion title="fern token">

<Markdown src="/snippets/fern-token.mdx" />
Expand Down
2 changes: 2 additions & 0 deletions fern/products/docs/pages/ai/mcp-server.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@ This is especially useful on [authenticated sites](/learn/docs/authentication/ov

Agents can also fetch documentation directly over HTTP. Fern serves clean Markdown via [per-page URLs and `llms.txt`](/learn/docs/ai-features/markdown) — including on authenticated sites.

Fern hosts a separate MCP server for your Fern organization, which searches your published pages and reads your site configuration, analytics, and reader feedback. Run [`fern mcp install`](/learn/cli-api-reference/cli-reference/commands#fern-mcp-install) to connect Claude Code, Cursor, or Codex to it.

Loading