返回市场
MCP文档服务器

MCP文档服务器

作者:mastra-ai18452 星标更新:2025-11-24

项目介绍

@mastra/mcp-docs-server

一个模型上下文协议(MCP)服务器,提供AI助手直接访问Mastra.ai的完整知识库。这包括支持MDX的综合文档、一系列生产就绪的代码示例、技术博客文章以及详细的包更改日志。该服务器与流行的AI开发环境如Cursor和Windsurf以及Mastra代理集成,使得构建了解文档的AI助手变得容易,这些助手可以提供关于Mastra.ai生态系统准确且最新的信息。

安装

在Cursor中

在项目根目录创建或更新.cursor/mcp.json

MacOS/Linux

{
  "mcpServers": {
    "mastra": {
      "command": "npx",
      "args": ["-y", "@mastra/mcp-docs-server"]
    }
  }
}

Windows

{
  "mcpServers": {
    "mastra": {
      "command": "cmd",
      "args": ["/c", "npx", "-y", "@mastra/mcp-docs-server"]
    }
  }
}

这将使所有Mastra文档工具在你的Cursor工作区中可用。请注意,MCP服务器默认情况下不会启用。你需要进入Cursor设置 -> MCP设置,并点击“启用”Mastra MCP服务器。

在Windsurf中

创建或更新~/.codeium/windsurf/mcp_config.json

MacOS/Linux

{
  "mcpServers": {
    "mastra": {
      "command": "npx",
      "args": ["-y", "@mastra/mcp-docs-server"]
    }
  }
}

Windows

{
  "mcpServers": {
    "mastra": {
      "command": "cmd",
      "args": ["/c", "npx", "-y", "@mastra/mcp-docs-server"]
    }
  }
}

这将使所有Mastra文档工具在你的Windsurf工作区中可用。请注意,Windsurf调用MCP工具的效果不佳。添加后,你需要完全退出并重新打开Windsurf。如果工具调用失败,你需要进入Windsurf MCP设置并重新启动MCP服务器。

在Claude Code中

安装Claude Code后运行:

claude mcp add mastra-docs -- npx -y @mastra/mcp-docs-server

在Mastra代理中

import { MCPClient } from '@mastra/mcp';
import { Agent } from '@mastra/core/agent';
import { openai } from '@ai-sdk/openai';

// 使用文档服务器配置MCP
const mcp = new MCPClient({
  servers: {
    mastra: {
      command: 'npx',
      args: ['-y', '@mastra/mcp-docs-server'],
    },
  },
});

// 创建一个具有访问所有文档工具权限的代理
const agent = new Agent({
  id: 'doc-assistant',
  name: '文档助手',
  instructions: '你帮助用户查找和理解Mastra.ai文档。',
  model: openai('gpt-4'),
  tools: await mcp.listTools(),
});

// 或者在generate/stream中动态使用工具集
const response = await agent.stream('给我看快速入门示例', {
  toolsets: await mcp.listToolsets(),
});

工具

文档工具 (mastraDocs)

  • 通过请求特定路径获取Mastra.ai文档
  • 探索通用指南和API参考文档
  • 当请求的路径未找到时,自动列出可用路径

示例工具 (mastraExamples)

  • 访问展示Mastra.ai实现模式的代码示例
  • 列出所有可用示例
  • 获取特定示例的详细源代码

博客工具 (mastraBlog)

  • 访问技术博客文章和文章
  • 文章经过正确格式化,包括代码块处理
  • 支持博客元数据中的多种日期格式

更改工具 (mastraChanges)

  • 访问包更改日志
  • 列出所有可用的包更改日志
  • 获取特定包的详细更改日志内容

迁移工具 (mastraMigration)

  • 获取Mastra版本升级和重大变更的迁移指导
  • 探索所有可用的迁移指南(例如,升级到v1/,代理网络)
  • 列出章节标题以查看涵盖哪些重大变更
  • 获取特定部分或整个迁移指南
  • 根据关键词搜索所有迁移指南 </中文翻译>