Logo van docusaurus-plugin-mcp-server

docusaurus-plugin-mcp-server

Community
scalvert

Docusaurus plugin that publishes your documentation as an MCP server

Uitgeverscalvert
Repositorydocusaurus-plugin-mcp-server
TaalTypeScript
Forks
6
Sterren
32
Beschikbare tools
0
Transporttypestreamable-http
Categorieën
LicentieMIT
Links
  • Koppel tools aan AI-workflows

    docusaurus-plugin-mcp-server biedt MCP-functionaliteit die compatibele AI-clients en agenten kunnen gebruiken.

  • 0 beschikbare tools

    Bekijk hieronder de aanroepbare acties, inclusief namen en beschrijvingen als de server die beschikbaar stelt.

  • Configuratie om direct te kopiëren

    Gebruik de installatievoorbeelden om deze server in je favoriete MCP-client te configureren.

  • Indicatoren van opensource-interesse

    32 sterren en 6 forks in de gekoppelde repository.

docusaurus-plugin-mcp-server

CI Build npm version License

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.

Installation

bash
npm install docusaurus-plugin-mcp-server

Quick Start

1. Add the Plugin

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

2. Create the API Endpoint

The MCP server runs on any web-standard serverless or edge runtime — Cloudflare Workers, modern Netlify functions, Vercel Edge, Deno, Bun. Import the build artifacts and pass them to createWebRequestHandler, which returns a standard (request: Request) => Promise<Response>. (These runtimes can't read the filesystem, so the data is imported as modules rather than loaded from disk.)

javascript
import { createWebRequestHandler } from 'docusaurus-plugin-mcp-server/adapters';
import docs from '../build/mcp/docs.json';
import searchIndex from '../build/mcp/search-index.json';

export default {
  fetch: createWebRequestHandler({
    docs,
    searchIndexData: searchIndex,
    name: 'my-docs',
    baseUrl: 'https://docs.example.com',
  }),
};

The export default { fetch } form works on Cloudflare Workers, Deno, and Bun. Other runtimes use their own entry convention (e.g. modern Netlify functions export default async (request) => Response) — the handler is identical, only the export wrapper differs.

The handler is unauthenticated and allows all origins (Access-Control-Allow-Origin: *) by default, since a docs MCP endpoint is meant to be public — pass corsOrigin to restrict it.

For local development, run the server over Node's http with createNodeServer from docusaurus-plugin-mcp-server/adapters/node (see Adapter Exports).

3. Build and Deploy

bash
npm run build
# Deploy to your platform

4. Connect Your AI Tool

Claude Code:

bash
claude mcp add --transport http my-docs https://docs.example.com/mcp

Cursor / VS Code:

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

5. Add an Install Button (Optional)

Add a dropdown button to your docs site so users can easily install the MCP server in their AI tool:

tsx
import { McpInstallButton } from 'docusaurus-plugin-mcp-server/theme';

function NavbarItems() {
  return <McpInstallButton serverUrl="https://docs.example.com/mcp" serverName="my-docs" />;
}

The button shows a dropdown with copy-to-clipboard configurations for all supported MCP clients.

Light ModeDark Mode
MCP Install Button - Light ModeMCP Install Button - Dark Mode

Props:

PropTypeDefaultDescription
serverUrlstring(plugin config)MCP server endpoint URL. Falls back to the plugin's global data when omitted
serverNamestring(plugin config)MCP server name. Falls back to the plugin's global data when omitted
labelstring(none)Button label. If omitted, shows only the MCP icon
headerTextstring"Choose your AI tool:"Text shown at the top of the dropdown
classNamestring""Optional CSS class
clientsClientId[]All HTTP-capableWhich clients to show

MCP Tools

The server exposes two tools for AI agents:

docs_search

Search across documentation with relevance ranking. Returns matching documents with URLs, snippets, and relevance scores.

json
{
  "name": "docs_search",
  "arguments": {
    "query": "authentication",
    "limit": 16
  }
}
ParameterTypeDefaultDescription
querystringrequiredSearch query
limitnumber16Max results (1-20)

Response includes:

  • Full URL for each result (use with docs_fetch)
  • Title and relevance score
  • Snippet of matching content
  • Matching headings

docs_fetch

Retrieve full page content as markdown. Use this after searching to get the complete content of a specific page.

json
{
  "name": "docs_fetch",
  "arguments": {
    "url": "https://docs.example.com/docs/authentication"
  }
}
ParameterTypeDescription
urlstringFull URL of the page (from search results)

Response includes:

  • Page title and description
  • Table of contents with anchor links
  • Full markdown content

Plugin Options

OptionTypeDefaultDescription
outputDirstring'mcp'Output directory for MCP artifacts (relative to build dir)
contentSelectorsstring[]['article', 'main', ...]CSS selectors for finding content
excludeSelectorsstring[]['nav', 'header', ...]CSS selectors for elements to remove
minContentLengthnumber50Minimum content length to consider a page valid
server.namestring'docs-mcp-server'Name of the MCP server
server.versionstring'1.0.0'Version of the MCP server
server.urlstring(derived)Explicit MCP HTTP endpoint URL for the install button
server.urlBase'origin' | 'site''origin'How to derive the MCP URL when server.url is not set. 'origin' → {siteUrl}/{outputDir}; 'site' → under Docusaurus baseUrl
excludeRoutesstring[]['/404*', '/search*']Routes to exclude (glob patterns)
indexersstring[] | false['flexsearch']Indexers to run during build. Use false to disable. Supports built-in ('flexsearch'), relative paths, or npm packages.
searchstring'flexsearch'Search provider module for runtime queries. Supports built-in ('flexsearch'), relative paths, or npm packages.
flexsearchFlexSearchConfig(tuned defaults)Tuning for the built-in FlexSearch index (tokenize, resolution, context, fieldWeights). Must be the same at build and runtime, or the index deserializes wrong.

Build-time options control artifact generation and the install-button URL (server.url / server.urlBase). Runtime-only options such as instructions, tools, and baseUrl belong on the adapter/handler config — see Server Configuration.

Default Selectors

Content selectors (in priority order):

javascript
['article', 'main', '.main-wrapper', '[role="main"]'];

Exclude selectors:

javascript
[
  'nav',
  'header',
  'footer',
  'aside',
  '[role="navigation"]',
  '[role="banner"]',
  '[role="contentinfo"]',
];

Custom Providers

The plugin uses a two-phase provider model: indexers run at build time to process documents, and search providers handle queries at runtime. Both are pluggable.

ContentIndexer

Implement ContentIndexer to push documents to an external system during build:

typescript
import type { ContentIndexer, ProviderContext, ProcessedDoc } from 'docusaurus-plugin-mcp-server';

export default class AlgoliaIndexer implements ContentIndexer {
  readonly name = 'algolia';

  shouldRun(): boolean {
    return process.env.ALGOLIA_SYNC === 'true';
  }

  async initialize(context: ProviderContext): Promise<void> {
    console.log(`[Algolia] Initializing for ${context.baseUrl}`);
  }

  async indexDocuments(docs: ProcessedDoc[]): Promise<void> {
    // Push docs to Algolia
  }

  async finalize(): Promise<Map<string, unknown>> {
    // No local artifacts needed
    return new Map();
  }
}

SearchProvider

Implement SearchProvider to delegate runtime search to an external service:

typescript
import type {
  SearchProvider,
  ProviderContext,
  SearchOptions,
  SearchResult,
} from 'docusaurus-plugin-mcp-server';

export default class GleanSearchProvider implements SearchProvider {
  readonly name = 'glean';

  private apiEndpoint = process.env.GLEAN_API_ENDPOINT!;
  private apiToken = process.env.GLEAN_API_TOKEN!;

  async initialize(context: ProviderContext): Promise<void> {
    if (!this.apiEndpoint || !this.apiToken) {
      throw new Error('GLEAN_API_ENDPOINT and GLEAN_API_TOKEN required');
    }
  }

  isReady(): boolean {
    return !!this.apiEndpoint && !!this.apiToken;
  }

  async search(query: string, options?: SearchOptions): Promise<SearchResult[]> {
    // Call Glean Search API and transform results
    return [];
  }
}

Configuring Custom Providers

javascript
// docusaurus.config.js
module.exports = {
  plugins: [
    [
      'docusaurus-plugin-mcp-server',
      {
        // Run both the built-in FlexSearch indexer and a custom one
        indexers: ['flexsearch', './my-algolia-indexer.js'],
        // Use a custom search provider at runtime
        search: '@myorg/glean-search',
      },
    ],
  ],
};

Server Configuration

These options apply to createWebRequestHandler, createNodeServer, and createNodeHandler — where the MCP server actually runs. They are not McpServerPluginOptions; the Docusaurus plugin only builds docs.json and the search index at build time.

OptionTypeRequiredDescription
docsPathstringYes*Path to docs.json
indexPathstringYes*Path to search-index.json
docsobjectYes*Pre-loaded docs (web handler)
searchIndexDataobjectYes*Pre-loaded search index (web handler)
namestringYesServer name
versionstringNoServer version
baseUrlstringNoBase URL for full page URLs in responses
instructionsstringNoInstructions describing how to use the server, surfaced to MCP clients in the initialize response
toolsobjectNoPer-tool overrides. Supports docs_search.description and docs_fetch.description to customize tool descriptions

*Use file paths (createNodeServer, local dev) or pre-loaded data (createWebRequestHandler, serverless/edge).

Example with extended configuration:

javascript
export default {
  fetch: createWebRequestHandler({
    docs,
    searchIndexData: searchIndex,
    name: 'my-docs',
    baseUrl: 'https://docs.example.com',
    instructions: 'Search the Acme product docs. Use docs_search to find pages, then docs_fetch for full content.',
    tools: {
      docs_search: { description: 'Search the Acme product documentation.' },
      docs_fetch: { description: 'Fetch the full markdown of an Acme docs page.' },
    },
  }),
};

Verifying Your Build

After running npm run build, use the included CLI to verify the MCP output:

bash
npx docusaurus-mcp-verify

This checks that:

  • All required files exist (docs.json, search-index.json, manifest.json)
  • Document structure is valid
  • The MCP server can initialize and load the content

You can specify a custom build directory:

bash
npx docusaurus-mcp-verify ./custom-build

Example output:

sh
🔍 MCP Build Verification
==================================================
Build directory: /path/to/your/project/build

📁 Checking build output...
   ✓ Found 42 documents
   ✓ All required files present
   ✓ File structure valid

🚀 Testing MCP server...
   ✓ Server initialized with 42 documents

✅ All checks passed!

Testing the Endpoint

The easiest way to test your MCP server is with the official MCP Inspector:

bash
npx @modelcontextprotocol/inspector

This opens a visual interface where you can:

  • Connect to your server URL
  • Browse available tools
  • Execute tool calls interactively
  • View responses in a formatted display

Alternatively, test with curl:

bash
# List available tools
curl -X POST https://docs.example.com/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

# Search documentation
curl -X POST https://docs.example.com/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc":"2.0",
    "id":2,
    "method":"tools/call",
    "params":{
      "name":"docs_search",
      "arguments":{"query":"getting started"}
    }
  }'

How It Works

How It Works

The plugin operates in two phases:

Build Time: During docusaurus build, the plugin's postBuild hook processes all rendered HTML pages, extracts content, converts to markdown, builds a FlexSearch index, and outputs artifacts to build/mcp/.

Runtime: A serverless function loads the pre-built artifacts and handles MCP JSON-RPC requests from AI agents. The server is stateless and fast since all indexing happens at build time.

Features

  • Full-text Search - FlexSearch-powered search with relevance ranking
  • Page Retrieval - Get complete page content as clean markdown
  • Runs Anywhere - One web-standard handler (createWebRequestHandler) for any serverless/edge runtime — Cloudflare Workers, modern Netlify functions, Vercel Edge, Deno, Bun — plus a Node server (createNodeServer) for local development
  • CORS Support - The web and Node handlers send CORS headers for browser-based clients; restrict with corsOrigin
  • Build-time Processing - Extracts content from rendered HTML, capturing React component output
  • Zero Runtime Docusaurus Dependency - The MCP server runs independently

Local Development

Run a local MCP server for testing using the built-in Node adapter:

javascript
// mcp-server.mjs
import { createNodeServer } from 'docusaurus-plugin-mcp-server/adapters/node';

createNodeServer({
  docsPath: './build/mcp/docs.json',
  indexPath: './build/mcp/search-index.json',
  name: 'my-docs',
  baseUrl: 'http://localhost:3000',
}).listen(3456, () => {
  console.log('MCP server at http://localhost:3456');
});

The Node adapter handles CORS, preflight requests, and health checks (GET) automatically.

Connect Claude Code:

bash
claude mcp add --transport http my-docs http://localhost:3456

API Reference

Main Exports

javascript
import {
  // Docusaurus plugin (also the default export)
  mcpServerPlugin,

  // MCP server class (advanced / custom runtimes)
  McpDocsServer,

  // Tool definitions
  docsSearchTool,
  docsFetchTool,

  // Provider loaders (built-in 'flexsearch' or custom indexers/providers)
  loadIndexer,
  loadSearchProvider,

  // Resolve the MCP endpoint URL the install button uses
  resolveServerUrl,

  // Default plugin options
  DEFAULT_PLUGIN_OPTIONS,
} from 'docusaurus-plugin-mcp-server';

resolveServerUrl

Derives the public MCP HTTP endpoint URL — the same logic the plugin uses for the install button and globalData. Use this when building custom theme UI that must stay in sync with plugin URL resolution.

Types ResolveServerUrlInput and ServerUrlBase are also exported from ..

typescript
import { resolveServerUrl, type ResolveServerUrlInput } from 'docusaurus-plugin-mcp-server';

const serverUrl = resolveServerUrl({
  siteUrl: 'https://docs.example.com',
  baseUrl: '/docs/',
  outputDir: 'mcp',
  server: { urlBase: 'site' },
});
// → 'https://docs.example.com/docs/mcp'
FieldTypeDescription
siteUrlstringDocusaurus siteConfig.url
baseUrlstringDocusaurus siteConfig.baseUrl
outputDirstringPlugin outputDir (default 'mcp')
server.urlstringExplicit endpoint; when set, urlBase is ignored
server.urlBaseServerUrlBase'origin' (default) → {siteUrl}/{outputDir}; 'site' → under baseUrl

ServerUrlBase is 'origin' | 'site'. Mirrors the server.url / server.urlBase plugin options.

Adapter Exports

javascript
import { createWebRequestHandler } from 'docusaurus-plugin-mcp-server/adapters';
import { createNodeServer, createNodeHandler } from 'docusaurus-plugin-mcp-server/adapters/node';
  • createNodeServer(options) — Creates a complete Node.js HTTP server for local development. Returns an http.Server ready to .listen().
  • createNodeHandler(options) — Creates a request handler function compatible with http.createServer(). Use this when you need to integrate with an existing server.

Theme Exports

tsx
import {
  McpInstallButton,
  type McpInstallButtonProps,
  useMcpRegistry,
  createDocsRegistry,
  createDocsRegistryOptions,
  type McpConfig,
} from 'docusaurus-plugin-mcp-server/theme';
  • McpInstallButton — Dropdown button for users to install the MCP server in their AI tool.
  • useMcpRegistry() — React hook that returns the MCP config registry from plugin global data. Returns undefined if the plugin is not installed.
  • createDocsRegistry(config) — Creates a pre-configured MCPConfigRegistry for documentation servers.
  • createDocsRegistryOptions(config) — Returns registry options without creating the registry.
  • McpConfig — Type for { serverUrl: string; serverName: string }.

Requirements

  • Node.js >= 20
  • Docusaurus 3.x

License

MIT

Agent skills

This repository ships agent skill(s) under skills/. Install them into your AI agent with npx skills:

sh
npx skills add -g scalvert/docusaurus-plugin-mcp-server   # global — available in every repo
npx skills add scalvert/docusaurus-plugin-mcp-server      # or scoped to the current repo

Installatie

TypingMind
Vereisten:

Node.js 18+

{
  "mcpServers": {
    "scalvert-docusaurus-plugin-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "docusaurus-plugin-mcp-server"
      ]
    }
  }
}

Gebruik docusaurus-plugin-mcp-server MCP met meerdere AI-modellen

TypingMind koppelt MCP-tools aan de werkruimte. Zodra docusaurus-plugin-mcp-server is verbonden, kun je deze dus met verschillende AI-modellen in TypingMind gebruiken, zonder de verbinding voor elk model apart in te stellen. Deze MCP-integratie maakt in TypingMind verbinding via de URL van een gehoste MCP-server.

Voeg een MCP-server-URL toe

Gebruik dit als docusaurus-plugin-mcp-server al extern wordt gehost of als je team één gedeelde connector wil die meerdere gebruikers kunnen gebruiken.

1

Open MCP-connectoren

Ga in TypingMind naar Plug-ins, open MCP-connectoren en kies URL toevoegen.

  1. Open TypingMind in je browser.
  2. Ga naar Plug-ins.
  3. Open MCP-connectoren.
  4. Klik op URL toevoegen.
TypingMind-formulier om een eigen MCP-server-URL toe te voegen
2

Plak de server-URL

Voer je server-URL in het veld Server-URL in. Voeg een verbindingsnaam, beschrijving, icoon, aangepaste HTTP-headers of OAuth-clientinstellingen toe als de server die vereist.

  1. Plak je server-URL in het veld Server-URL.
  2. Voer een verbindingsnaam in voor docusaurus-plugin-mcp-server.
  3. Voeg een beschrijving en een icoon toe om de verbinding makkelijker te herkennen.
  4. Voeg aangepaste HTTP-headers of OAuth-clientgegevens toe als de server authenticatie vereist.
3

Maak de verbinding

Klik op Verbinding maken, ga terug naar de lijst met plug-ins en controleer of de nieuwe MCP-verbinding actief is.

  1. Klik op Verbinding maken.
  2. Ga terug naar de lijst met MCP-connectoren.
  3. Controleer of de verbinding met docusaurus-plugin-mcp-server als actief wordt weergegeven.
  4. Vernieuw de lijst met plug-ins als de verbinding niet meteen verschijnt.
4

Wissel van model zonder opnieuw verbinding te maken

Start een chat met je favoriete model, schakel de tools van docusaurus-plugin-mcp-server in via Plug-ins en wissel van model wanneer dat nodig is. De MCP-verbinding blijft beschikbaar in de TypingMind-werkruimte.

  1. Start een nieuwe chat in TypingMind.
  2. Selecteer het AI-model dat je wilt gebruiken.
  3. Schakel de tools van docusaurus-plugin-mcp-server in via Plug-ins.
  4. Vraag het model om de tool te gebruiken wanneer dat nodig is.
  5. Schakel over naar een ander AI-model en gebruik dezelfde MCP-verbinding opnieuw.
TypingMind-chat met ingeschakelde MCP-tools en een geselecteerd AI-model
Kun je docusaurus-plugin-mcp-server gebruiken om me hiermee te helpen?
docusaurus-plugin-mcp-server
Zeker. Ik heb het gelezen.
Dit vond ik met docusaurus-plugin-mcp-server.

Veelgestelde vragen

Waarvoor wordt de MCP-server docusaurus-plugin-mcp-server gebruikt?

docusaurus-plugin-mcp-server is een MCP-server waarmee compatibele AI-clients verbinding kunnen maken met externe tools en context. In TypingMind hoef je deze MCP-server maar één keer toe te voegen om de tools beschikbaar te maken in je AI-werkruimte.

Kan ik docusaurus-plugin-mcp-server MCP met meerdere AI-modellen in TypingMind gebruiken?

Ja. TypingMind verbindt MCP-tools op werkruimteniveau. Daardoor kun je docusaurus-plugin-mcp-server gebruiken met verschillende AI-modellen, zoals Claude, ChatGPT, Gemini of andere modellen die je in TypingMind hebt ingesteld, zonder de MCP-server voor elk model afzonderlijk in te stellen.

Waarom docusaurus-plugin-mcp-server MCP gebruiken met TypingMind?

TypingMind is een van de beste interfaces voor chats met LLM's, omdat het meerdere AI-modellen, prompts, plug-ins, AI-agenten, API-sleutels en MCP-tools samenbrengt in één werkruimte. Als docusaurus-plugin-mcp-server verbonden is, kun je de MCP-tools ervan gebruiken met je favoriete modellen en je chatworkflow overzichtelijk houden in TypingMind.

Hoe verbind ik docusaurus-plugin-mcp-server MCP met TypingMind?

Je kunt docusaurus-plugin-mcp-server met TypingMind verbinden door de URL van de gehoste MCP-server toe te voegen. Dit is handig als je een externe MCP-verbinding wilt die beschikbaar is vanuit je TypingMind-werkruimte.

Welke tools biedt docusaurus-plugin-mcp-server MCP in TypingMind?

docusaurus-plugin-mcp-server biedt MCP-functies die je kunt inschakelen via de pagina Plug-ins in TypingMind. Je kunt ze gebruiken in chats of toewijzen aan AI-agenten.

Moet ik mijn API-sleutels delen met TypingMind om docusaurus-plugin-mcp-server MCP te gebruiken?

Nee. TypingMind werkt in de eerste plaats lokaal en laat je de controle houden over je modelaanbieders, API-sleutels, prompts en MCP-configuratie. Als docusaurus-plugin-mcp-server authenticatie vereist, voeg je bij het maken van de verbinding de vereiste headers, OAuth-instellingen of lokale configuratie voor die MCP-server toe.

Gerelateerde MCP-servers

Toon alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇