> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiI4NzUyZTg3My01YzRiLTQyMTctOTE0OC1iM2I1NjBkZmVhOTciLCJleHAiOjE3NzgyNTkyOTMsImlhdCI6MTc3ODI1ODk5M30.gyjcw2YSu9s8RgyAkmCmTQZTi13coK9a4RLy1Uo3g-I
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# MCP 服务器

> 连接 AI 客户端如 Claude Code 和 Cursor 到您的文档站点的 MCP 服务器，获取即时答案。

Fern 会自动为每个启用了 [Ask Fern](/learn/docs/ai-features/ask-fern/overview) 的文档站点生成并托管一个生产就绪的 [Model Context Protocol (MCP)](https://modelcontextprotocol.io) 服务器。该服务器将 AI 客户端（如 Claude Code、Cursor 和 Windsurf）连接到您的文档作为外部数据源，这样开发者就可以直接在开发环境中获得关于您产品的即时答案。

您的 MCP 服务器位于 `your-documentation-site.com/_mcp/server`。例如，本站的 MCP 服务器位于 [https://buildwithfern.com/learn/\_mcp/server](https://buildwithfern.com/learn/_mcp/server)。

## 从您的文档站点连接

[页面操作](/learn/docs/configuration/site-level-settings#page-actions-configuration)按钮让用户可以一键连接到您的 MCP 服务器：

* **连接到 Claude Code** 会复制一个 `claude mcp add` 命令到剪贴板，用于注册服务器。
* **连接到 Cursor** 会打开 Cursor 并预填服务器 URL，实现一键安装。

启用了 Ask Fern 的站点默认启用这两个按钮。对于其他客户端（Claude Desktop、Windsurf 等），用户可以将 `your-documentation-site.com/_mcp/server` 添加到他们的 MCP 配置中。

## AI 代理的直接 API 访问

AI 代理可以通过 HTTP 直接访问您的文档。Fern 以清洁的 Markdown 格式提供内容，以提高令牌效率。

对于需要身份验证的站点，代理可以通过 Fern API 密钥使用 [`/api/fern-docs/get-jwt`](/learn/docs/fern-api-reference/get-jwt) 获取 JWT，以访问受保护的文档内容和搜索功能。

```bash Access protected content
curl https://docs.example.com/platform/overview \
  -H 'Accept: text/plain' \
  -H 'x-fern-host: docs.example.com' \
  -H 'FERN_TOKEN: your-jwt-here'
```