diff --git a/fern/products/cli-api-reference/pages/commands.mdx b/fern/products/cli-api-reference/pages/commands.mdx index be13bd1b3..267d62c49 100644 --- a/fern/products/cli-api-reference/pages/commands.mdx +++ b/fern/products/cli-api-reference/pages/commands.mdx @@ -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 | @@ -857,6 +858,54 @@ hideOnThisPage: true + + + 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: + + + ```bash + fern mcp install [--client claude|cursor|codex] [--org ] + ``` + + + From a machine with no Fern CLI yet: + + + ```bash + npm i -g fern-api + fern login + fern mcp install + ``` + + + 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//mcp`. Outside a Fern project, the command falls back to the unscoped `https://fai.buildwithfern.com/mcp`. + + ```bash + fern mcp install --org my-org + ``` + + + diff --git a/fern/products/docs/pages/ai/mcp-server.mdx b/fern/products/docs/pages/ai/mcp-server.mdx index 2e6373129..8631af618 100644 --- a/fern/products/docs/pages/ai/mcp-server.mdx +++ b/fern/products/docs/pages/ai/mcp-server.mdx @@ -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. +