每个 Movk Nuxt Docs 实例内置 Model Context Protocol (MCP) 服务器,任何 MCP 客户端(Claude、Cursor、VS Code 等)均可连接。
当连接到 AI 工具时,LLM 能够根据对话上下文智能地判断何时需要访问文档工具,从而在开发过程中为您提供更准确的文档引用和技术支持。
您的 MCP 服务器可通过文档网址的 /mcp 路径自动访问。
https://docs.example.com,则您的 MCP 服务器 URL 为 https://docs.example.com/mcp。在 nuxt.config.ts 中禁用 MCP 服务器:
export default defineNuxtConfig({
mcp: {
enabled: false
}
})
export default defineNuxtConfig({
mcp: {
name: 'My Docs'
}
})
MOVK Docs MCP 提供两个开箱即用的工具:
list-pages列出所有可用的文档页面及分类信息。
使用场景:
get-page检索特定文档页面的完整内容。
参数:
path (必需) - 页面路径,例如 /docs/getting-started/installation使用场景:
MCP 服务器采用 HTTP 传输协议,可安装于不同 AI 助手中。
使用 CLI 命令添加服务器:
claude mcp add --transport http my-docs https://docs.example.com/mcp
claude_desktop_config.json 文件:{
"mcpServers": {
"my-docs": {
"command": "npx",
"args": [
"mcp-remote",
"https://docs.example.com/mcp"
]
}
}
}
或者在项目根目录创建或更新 .cursor/mcp.json:
{
"mcpServers": {
"my-docs": {
"type": "http",
"url": "https://docs.example.com/mcp"
}
}
}
或者在项目的 .vscode 文件夹中创建或编辑 mcp.json 文件:
{
"servers": {
"my-docs": {
"type": "http",
"url": "https://docs.example.com/mcp"
}
}
}
My Docshttps://docs.example.com/mcpNoneMy Docs 连接器将在对话期间出现在撰写器的「开发者模式」工具中。
在项目根目录创建 opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"my-docs": {
"type": "remote",
"url": "https://docs.example.com/mcp",
"enabled": true
}
}
}
配置完成后,您可以向 AI 助手提出如下问题,它们将自动使用 MCP 服务器查询文档:
AI 助手将在生成响应时主动搜索文档,根据对话上下文智能判断何时需要查询工具,为您提供准确的文档引用和技术支持。
您可以通过创建自定义组件来扩展 MCP 服务器的功能。
在 server/mcp/tools/ 目录中创建自定义工具文件:
import { z } from 'zod/v4'
export default defineMcpTool({
description: '工具的详细描述,帮助 AI 理解何时使用此工具',
inputSchema: {
param: z.string().describe('参数说明')
},
cache: '1h', // 可选:设置缓存时间
handler: async ({ param }) => {
// 工具逻辑
return {
content: [{ type: 'text', text: '返回内容' }]
}
}
})
在 server/mcp/resources/ 目录中创建可被发现的资源:
export default defineMcpResource({
file: 'CHANGELOG.md',
metadata: {
description: '项目的变更日志',
},
})
这会自动处理 URI 生成、MIME 类型检测和文件读取。
在 server/mcp/prompts/ 目录中创建可重用的提示:
export default defineMcpPrompt({
name: 'greeting',
title: '问候',
description: '生成个性化问候消息',
handler: async () => {
const hour = new Date().getHours()
const timeOfDay = hour < 12 ? '早上' : hour < 18 ? '下午' : '晚上'
return {
messages: [{
role: 'user',
content: {
type: 'text',
text: `${timeOfDay}好!有什么可以帮您的吗?`,
},
}],
}
},
})
可以在 server/mcp/ 目录下创建自定义处理器:
import { z } from 'zod/v4'
const migrationTool = defineMcpTool({
name: 'migrate-v3-to-v4',
title: '将 v3 迁移到 v4',
description: '将代码从版本 3 迁移到版本 4',
inputSchema: {
code: z.string().describe('要迁移的代码'),
},
handler: async ({ code }) => {
const migrated = code.replace(/v3/g, 'v4')
return {
content: [{
type: 'text',
text: migrated,
}],
}
},
})
export default defineMcpHandler({
name: 'migration',
version: '0.1.0',
route: '/mcp/migration',
tools: [migrationTool],
browserRedirect: '/',
})
要覆盖内置的 list-pages 或 get-page 工具,只需在 server/mcp/tools/ 目录中创建同名文件即可。
import { z } from 'zod/v4'
export default defineMcpTool({
description: '自定义列表页实现',
inputSchema: {
locale: z.string().optional(),
category: z.string().optional(),
},
handler: async ({ locale, category }) => {
const pages = await getCustomPageList(locale, category)
return {
content: [{ type: 'text', text: JSON.stringify(pages) }],
}
},
})