docusaurus-plugin-mcp-server 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -184,11 +184,11 @@ The button shows a dropdown with copy-to-clipboard configurations for all suppor
184
184
 
185
185
  ## MCP Tools
186
186
 
187
- The server exposes three tools for AI agents:
187
+ The server exposes two tools for AI agents:
188
188
 
189
189
  ### `docs_search`
190
190
 
191
- Search across documentation with relevance ranking.
191
+ Search across documentation with relevance ranking. Returns matching documents with URLs, snippets, and relevance scores.
192
192
 
193
193
  ```json
194
194
  {
@@ -205,41 +205,33 @@ Search across documentation with relevance ranking.
205
205
  | `query` | `string` | required | Search query |
206
206
  | `limit` | `number` | `5` | Max results (1-20) |
207
207
 
208
- ### `docs_get_page`
208
+ **Response includes:**
209
+ - Full URL for each result (use with `docs_fetch`)
210
+ - Title and relevance score
211
+ - Snippet of matching content
212
+ - Matching headings
209
213
 
210
- Retrieve full page content as markdown.
214
+ ### `docs_fetch`
211
215
 
212
- ```json
213
- {
214
- "name": "docs_get_page",
215
- "arguments": {
216
- "route": "/docs/authentication"
217
- }
218
- }
219
- ```
220
-
221
- | Parameter | Type | Description |
222
- |-----------|------|-------------|
223
- | `route` | `string` | Page route path |
224
-
225
- ### `docs_get_section`
226
-
227
- Retrieve a specific section by heading ID.
216
+ Retrieve full page content as markdown. Use this after searching to get the complete content of a specific page.
228
217
 
229
218
  ```json
230
219
  {
231
- "name": "docs_get_section",
220
+ "name": "docs_fetch",
232
221
  "arguments": {
233
- "route": "/docs/authentication",
234
- "headingId": "oauth-configuration"
222
+ "url": "https://docs.example.com/docs/authentication"
235
223
  }
236
224
  }
237
225
  ```
238
226
 
239
227
  | Parameter | Type | Description |
240
228
  |-----------|------|-------------|
241
- | `route` | `string` | Page route path |
242
- | `headingId` | `string` | Heading ID to extract |
229
+ | `url` | `string` | Full URL of the page (from search results) |
230
+
231
+ **Response includes:**
232
+ - Page title and description
233
+ - Table of contents with anchor links
234
+ - Full markdown content
243
235
 
244
236
  ## Plugin Options
245
237
 
@@ -398,8 +390,8 @@ The plugin operates in two phases:
398
390
 
399
391
  - **Full-text Search** - FlexSearch-powered search with relevance ranking
400
392
  - **Page Retrieval** - Get complete page content as clean markdown
401
- - **Section Extraction** - Retrieve specific sections by heading ID
402
393
  - **Platform Adapters** - Pre-built adapters for Vercel, Netlify, and Cloudflare Workers
394
+ - **CORS Support** - All adapters include CORS headers for browser-based clients
403
395
  - **Build-time Processing** - Extracts content from rendered HTML, capturing React component output
404
396
  - **Zero Runtime Docusaurus Dependency** - The MCP server runs independently
405
397
 
@@ -424,19 +416,23 @@ const server = new McpDocsServer({
424
416
  });
425
417
 
426
418
  http.createServer(async (req, res) => {
419
+ if (req.method === 'OPTIONS') {
420
+ res.writeHead(204, {
421
+ 'Access-Control-Allow-Origin': '*',
422
+ 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
423
+ 'Access-Control-Allow-Headers': 'Content-Type',
424
+ });
425
+ res.end();
426
+ return;
427
+ }
428
+
427
429
  if (req.method !== 'POST') {
428
430
  res.writeHead(405);
429
431
  res.end();
430
432
  return;
431
433
  }
432
434
 
433
- let body = '';
434
- req.on('data', (chunk) => (body += chunk));
435
- req.on('end', async () => {
436
- const response = await server.handleRequest(JSON.parse(body));
437
- res.writeHead(200, { 'Content-Type': 'application/json' });
438
- res.end(JSON.stringify(response));
439
- });
435
+ await server.handleHttpRequest(req, res);
440
436
  }).listen(3456, () => {
441
437
  console.log('MCP server at http://localhost:3456');
442
438
  });
@@ -461,8 +457,7 @@ import {
461
457
 
462
458
  // Tool definitions
463
459
  docsSearchTool,
464
- docsGetPageTool,
465
- docsGetSectionTool,
460
+ docsFetchTool,
466
461
 
467
462
  // Utilities
468
463
  htmlToMarkdown,
@@ -470,6 +465,12 @@ import {
470
465
  extractHeadingsFromMarkdown,
471
466
  buildSearchIndex,
472
467
 
468
+ // Provider types (for custom implementations)
469
+ loadIndexer,
470
+ loadSearchProvider,
471
+ FlexSearchIndexer,
472
+ FlexSearchProvider,
473
+
473
474
  // Default options
474
475
  DEFAULT_OPTIONS,
475
476
  } from 'docusaurus-plugin-mcp-server';
@@ -1,5 +1,5 @@
1
- import { IncomingMessage, ServerResponse } from 'node:http';
2
- import { M as McpServerConfig, P as ProcessedDoc } from './index-4g0ZZK3z.mjs';
1
+ import { IncomingMessage, ServerResponse, Server } from 'node:http';
2
+ import { M as McpServerConfig, P as ProcessedDoc, a as McpServerFileConfig } from './index-j-CdaS6k.mjs';
3
3
 
4
4
  /**
5
5
  * Vercel adapter for MCP server
@@ -177,4 +177,49 @@ interface GeneratedFile {
177
177
  */
178
178
  declare function generateAdapterFiles(options: GeneratorOptions): GeneratedFile[];
179
179
 
180
- export { type CloudflareAdapterConfig, type GeneratedFile, type GeneratorOptions, type NetlifyContext, type NetlifyEvent, type Platform, type VercelRequest, type VercelResponse, createCloudflareHandler, createNetlifyHandler, createVercelHandler, generateAdapterFiles };
180
+ /**
181
+ * Node.js adapter for MCP server
182
+ *
183
+ * Creates a standalone HTTP server for local development and testing.
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * import { createNodeServer } from 'docusaurus-plugin-mcp-server/adapters';
188
+ *
189
+ * const server = createNodeServer({
190
+ * docsPath: './build/mcp/docs.json',
191
+ * indexPath: './build/mcp/search-index.json',
192
+ * name: 'my-docs',
193
+ * });
194
+ *
195
+ * server.listen(3456, () => {
196
+ * console.log('MCP server running at http://localhost:3456');
197
+ * });
198
+ * ```
199
+ */
200
+
201
+ /**
202
+ * Options for the Node.js MCP server
203
+ */
204
+ interface NodeServerOptions extends McpServerFileConfig {
205
+ /**
206
+ * CORS origin to allow. Defaults to '*' (all origins).
207
+ * Set to a specific origin or false to disable CORS headers.
208
+ */
209
+ corsOrigin?: string | false;
210
+ }
211
+ /**
212
+ * Create a Node.js request handler for the MCP server.
213
+ *
214
+ * This returns a handler function compatible with `http.createServer()`.
215
+ * For a complete server, use `createNodeServer()` instead.
216
+ */
217
+ declare function createNodeHandler(options: NodeServerOptions): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
218
+ /**
219
+ * Create a complete Node.js HTTP server for the MCP server.
220
+ *
221
+ * This is the simplest way to run an MCP server locally for development.
222
+ */
223
+ declare function createNodeServer(options: NodeServerOptions): Server;
224
+
225
+ export { type CloudflareAdapterConfig, type GeneratedFile, type GeneratorOptions, type NetlifyContext, type NetlifyEvent, type NodeServerOptions, type Platform, type VercelRequest, type VercelResponse, createCloudflareHandler, createNetlifyHandler, createNodeHandler, createNodeServer, createVercelHandler, generateAdapterFiles };
@@ -1,5 +1,5 @@
1
- import { IncomingMessage, ServerResponse } from 'node:http';
2
- import { M as McpServerConfig, P as ProcessedDoc } from './index-4g0ZZK3z.js';
1
+ import { IncomingMessage, ServerResponse, Server } from 'node:http';
2
+ import { M as McpServerConfig, P as ProcessedDoc, a as McpServerFileConfig } from './index-j-CdaS6k.js';
3
3
 
4
4
  /**
5
5
  * Vercel adapter for MCP server
@@ -177,4 +177,49 @@ interface GeneratedFile {
177
177
  */
178
178
  declare function generateAdapterFiles(options: GeneratorOptions): GeneratedFile[];
179
179
 
180
- export { type CloudflareAdapterConfig, type GeneratedFile, type GeneratorOptions, type NetlifyContext, type NetlifyEvent, type Platform, type VercelRequest, type VercelResponse, createCloudflareHandler, createNetlifyHandler, createVercelHandler, generateAdapterFiles };
180
+ /**
181
+ * Node.js adapter for MCP server
182
+ *
183
+ * Creates a standalone HTTP server for local development and testing.
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * import { createNodeServer } from 'docusaurus-plugin-mcp-server/adapters';
188
+ *
189
+ * const server = createNodeServer({
190
+ * docsPath: './build/mcp/docs.json',
191
+ * indexPath: './build/mcp/search-index.json',
192
+ * name: 'my-docs',
193
+ * });
194
+ *
195
+ * server.listen(3456, () => {
196
+ * console.log('MCP server running at http://localhost:3456');
197
+ * });
198
+ * ```
199
+ */
200
+
201
+ /**
202
+ * Options for the Node.js MCP server
203
+ */
204
+ interface NodeServerOptions extends McpServerFileConfig {
205
+ /**
206
+ * CORS origin to allow. Defaults to '*' (all origins).
207
+ * Set to a specific origin or false to disable CORS headers.
208
+ */
209
+ corsOrigin?: string | false;
210
+ }
211
+ /**
212
+ * Create a Node.js request handler for the MCP server.
213
+ *
214
+ * This returns a handler function compatible with `http.createServer()`.
215
+ * For a complete server, use `createNodeServer()` instead.
216
+ */
217
+ declare function createNodeHandler(options: NodeServerOptions): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
218
+ /**
219
+ * Create a complete Node.js HTTP server for the MCP server.
220
+ *
221
+ * This is the simplest way to run an MCP server locally for development.
222
+ */
223
+ declare function createNodeServer(options: NodeServerOptions): Server;
224
+
225
+ export { type CloudflareAdapterConfig, type GeneratedFile, type GeneratorOptions, type NetlifyContext, type NetlifyEvent, type NodeServerOptions, type Platform, type VercelRequest, type VercelResponse, createCloudflareHandler, createNetlifyHandler, createNodeHandler, createNodeServer, createVercelHandler, generateAdapterFiles };