SD

scalvert/docusaurus-plugin-mcp-server

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

35 stars 6 forks 质量 82 趋势 32MIT

Docusaurus 插件,将你的文档发布为 MCP 服务器

概览

一个Docusaurus插件,可以暴露MCP(模型上下文协议)服务器端点,允许像Claude、Cursor及其他兼容MCP的工具等AI代理搜索和检索你的文档。 MCP 服务器运行在任何 Web 标准的无服务器或边缘运行时上——Cloudflare Workers、现代 Netlify 函数、Vercel Edge、Deno、Bun。导入构建工件并传递给 createWebRequestHandler,后者返回标准(请求:请求)=> 承诺。(这些运行时无法读取文件系统,因此数据以模块形式导入,而非从磁盘加载。) 导出默认的 { fetch } 表单适用于 Cloudflare Workers、Deno 和 Bun。其他运行时使用自己的条目规范(例如现代 Netlify 函数导出默认异步(请求)=> 响应)——处理程序相同,只有导出包装不同。

概述(AI 翻译)

文档入门指南 ·部署指南 ·参考文献

一个Docusaurus插件,可以暴露MCP(模型上下文协议)服务器端点,允许像Claude、Cursor及其他兼容MCP的工具等AI代理搜索和检索你的文档。

服务器使用 MCP 2026-07-28,仍通过 2025 时代版本(initialize)从同一端点服务客户端。它还能提供代理技能,教代理如何使用你的文档工具。

文档网站就是用这个插件构建的。把你的代理连接到它:

安装

快速启动

1.添加插件

在 docusaurus.config.js 中设置 url 为你的生产域名:工具结果中的页面 URL 就是基于它构建的。

2.创建API端点

docusaurus build 将工件丛写入 build/mcp/bundle.json。从函数 /mcp 处提供 createWebRequestHandler,返回任意无服务器或边缘运行时的标准 (request: Request) => Promise :

文件放哪里,/mcp 如何路由到它,取决于你的主机。每个指南都是完整的设置:

平台 导游
维塞尔 部署到维塞尔
Netlify 部署到 Netlify

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

A Docusaurus plugin that exposes an MCP (Model Context Protocol) server endpoint, allowing AI agents like Claude, Cursor, and other MCP-compatible tools to search and retrieve your documentation.

The server speaks MCP 2026-07-28 and still serves clients on 2025-era revisions (the initialize handshake) from the same endpoint. It can also serve Agent Skills that teach agents how to use your docs tools.

The documentation site is built with this plugin. Connect your agent to it:

claude mcp add --transport http docusaurus-plugin-mcp-server https://docusaurus-plugin-mcp-server.vercel.app/mcp

Installation

npm install docusaurus-plugin-mcp-server

Quick Start

1. Add the Plugin

// docusaurus.config.js
module.exports = {
  plugins: [
    [
      'docusaurus-plugin-mcp-server',
      {
        server: {
          name: 'my-docs',
          version: '1.0.0',
        },
      },
    ],
  ],
};

Set url in docusaurus.config.js to your production domain: page URLs in tool results are built from it.

2. Create the API Endpoint

docusaurus build writes the artifact bundle to build/mcp/bundle.json. Serve it from a function at /mcp with createWebRequestHandler, which returns a standard (request: Request) => Promise for any serverless or edge runtime:

import { createWebRequestHandler } from 'docusaurus-plugin-mcp-server/adapters';
import bundle from '../build/mcp/bundle.json' with { type: 'json' };

export default {
  // Name, version, and site URL come from the build; pass them here to override.
  fetch: createWebRequestHandler({ artifacts: bundle }),
};

Where that file goes and how /mcp is routed to it depends on your host. Each guide is a complete setup:

Platform Guide
在 GitHub 查看完整 README

安装

npx docusaurus-mcp-verify
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "my-docs": { "url": "https://docs.example.com/mcp" } } }