> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt.

# MCP server for your site

> Give your readers' AI clients an MCP server that answers questions about your product from your documentation site.

Fern automatically generates and hosts a production-ready [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server for every documentation site with [Ask Fern](/learn/docs/ai-features/ask-fern/overview) enabled. The server connects AI clients like Claude Code, Cursor, and Windsurf to your documentation as an external data source, so your readers can get instant answers about your product directly within their development environment.

This is the server your readers connect to, and it serves your content. To point your own agent at Fern's product documentation while you build your site, or at your organization's Fern data, use [Fern's MCP server](/learn/docs/ai-features/fern-mcp-servers).

Your MCP server is available at `your-documentation-site.com/_mcp/server`. For example, the MCP server for this site is at [https://buildwithfern.com/learn/\_mcp/server](https://buildwithfern.com/learn/_mcp/server).

## Connect to your MCP server

For Claude Code and Cursor, [page action](/learn/docs/configuration/site-level-settings#page-actions-configuration) buttons let users connect in one click:

* **Connect to Claude Code** copies a `claude mcp add` command to the clipboard to register the server.
* **Connect to Cursor** opens Cursor with the server URL pre-filled for one-click install.

Both buttons are enabled by default on sites with Ask Fern.

All other clients (including Claude Desktop, Windsurf, and VS Code) connect using the server URL directly. Add `your-documentation-site.com/_mcp/server` to your MCP configuration. For CLI clients, that looks like:

```bash
claude mcp add --transport http \
  fern_mcp_docs.example.com https://docs.example.com/_mcp/server
```

## Authenticated sites

On sites with [authentication](/learn/docs/authentication/overview) enabled, MCP clients must include a `FERN_TOKEN` header containing a valid JWT. Without it, the server only returns publicly visible content (if any).

#### Get a token

Exchange your credentials for a JWT. The endpoint depends on how your site authenticates users.

#### API key (JWT / OAuth)

Exchange a [Fern API key](/learn/cli-api-reference/cli-reference/general-commands#fern-token) for a JWT via the [get-jwt endpoint](/learn/docs/fern-api-reference/get-jwt):

```bash
curl https://docs.example.com/api/fern-docs/get-jwt \
  -H "FERN_API_KEY: $FERN_TOKEN"
# → { "fern_token": "eyJ...", "roles": [] }
```

#### Password protection

Exchange the site password for a JWT:

```bash
curl -s -D - https://docs.example.com/api/fern-docs/auth/password \
  -H "Content-Type: application/json" \
  -d '{"password": "your-site-password"}'
```

Extract the `fern_token` value from the `Set-Cookie` header in the response.

#### Configure your MCP client

Register the server manually, as the [page action](/learn/docs/configuration/site-level-settings#page-actions-configuration) buttons can't carry credentials. Then, add the JWT as a `FERN_TOKEN` header. In Claude Code:

```bash
claude mcp add --transport http \
  --header "FERN_TOKEN: <jwt>" \
  fern_mcp_docs.example.com https://docs.example.com/_mcp/server
```

For Cursor, VS Code, and other clients, add `FERN_TOKEN: <jwt>` to the `headers` field in your MCP server configuration if the client supports custom headers.

JWTs expire. Re-run the token exchange when the token lapses. There is no automatic refresh mechanism in the MCP transport.

## Disable the MCP server

To turn the server off entirely, set `mcp` to `false` in your [`page-actions` configuration](/learn/docs/configuration/site-level-settings#page-actionsoptions.mcp):

```yaml docs.yml
page-actions:
  options:
    mcp: false
```

This is especially useful on [authenticated sites](/learn/docs/authentication/overview) because unauthenticated agents can discover the MCP endpoint but can't read its content. Disabling the server returns 404 from the endpoint, hides the connection buttons, and stops agents from discovering it through `llms.txt` or agent prompts.

## Other ways agents can access your docs

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.