docusaurus-plugin-mcp-server 0.8.0 → 0.10.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
@@ -178,17 +178,18 @@ The button shows a dropdown with copy-to-clipboard configurations for all suppor
178
178
  |------|------|---------|-------------|
179
179
  | `serverUrl` | `string` | required | Your MCP server endpoint URL |
180
180
  | `serverName` | `string` | required | Name for the MCP server |
181
- | `label` | `string` | `"Install MCP"` | Button label |
181
+ | `label` | `string` | (none) | Button label. If omitted, shows only the MCP icon |
182
+ | `headerText` | `string` | `"Choose your AI tool:"` | Text shown at the top of the dropdown |
182
183
  | `className` | `string` | `""` | Optional CSS class |
183
184
  | `clients` | `ClientId[]` | All HTTP-capable | Which clients to show |
184
185
 
185
186
  ## MCP Tools
186
187
 
187
- The server exposes three tools for AI agents:
188
+ The server exposes two tools for AI agents:
188
189
 
189
190
  ### `docs_search`
190
191
 
191
- Search across documentation with relevance ranking.
192
+ Search across documentation with relevance ranking. Returns matching documents with URLs, snippets, and relevance scores.
192
193
 
193
194
  ```json
194
195
  {
@@ -205,41 +206,33 @@ Search across documentation with relevance ranking.
205
206
  | `query` | `string` | required | Search query |
206
207
  | `limit` | `number` | `5` | Max results (1-20) |
207
208
 
208
- ### `docs_get_page`
209
+ **Response includes:**
210
+ - Full URL for each result (use with `docs_fetch`)
211
+ - Title and relevance score
212
+ - Snippet of matching content
213
+ - Matching headings
209
214
 
210
- Retrieve full page content as markdown.
215
+ ### `docs_fetch`
211
216
 
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.
217
+ Retrieve full page content as markdown. Use this after searching to get the complete content of a specific page.
228
218
 
229
219
  ```json
230
220
  {
231
- "name": "docs_get_section",
221
+ "name": "docs_fetch",
232
222
  "arguments": {
233
- "route": "/docs/authentication",
234
- "headingId": "oauth-configuration"
223
+ "url": "https://docs.example.com/docs/authentication"
235
224
  }
236
225
  }
237
226
  ```
238
227
 
239
228
  | Parameter | Type | Description |
240
229
  |-----------|------|-------------|
241
- | `route` | `string` | Page route path |
242
- | `headingId` | `string` | Heading ID to extract |
230
+ | `url` | `string` | Full URL of the page (from search results) |
231
+
232
+ **Response includes:**
233
+ - Page title and description
234
+ - Table of contents with anchor links
235
+ - Full markdown content
243
236
 
244
237
  ## Plugin Options
245
238
 
@@ -398,8 +391,8 @@ The plugin operates in two phases:
398
391
 
399
392
  - **Full-text Search** - FlexSearch-powered search with relevance ranking
400
393
  - **Page Retrieval** - Get complete page content as clean markdown
401
- - **Section Extraction** - Retrieve specific sections by heading ID
402
394
  - **Platform Adapters** - Pre-built adapters for Vercel, Netlify, and Cloudflare Workers
395
+ - **CORS Support** - All adapters include CORS headers for browser-based clients
403
396
  - **Build-time Processing** - Extracts content from rendered HTML, capturing React component output
404
397
  - **Zero Runtime Docusaurus Dependency** - The MCP server runs independently
405
398
 
@@ -424,19 +417,23 @@ const server = new McpDocsServer({
424
417
  });
425
418
 
426
419
  http.createServer(async (req, res) => {
420
+ if (req.method === 'OPTIONS') {
421
+ res.writeHead(204, {
422
+ 'Access-Control-Allow-Origin': '*',
423
+ 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
424
+ 'Access-Control-Allow-Headers': 'Content-Type',
425
+ });
426
+ res.end();
427
+ return;
428
+ }
429
+
427
430
  if (req.method !== 'POST') {
428
431
  res.writeHead(405);
429
432
  res.end();
430
433
  return;
431
434
  }
432
435
 
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
- });
436
+ await server.handleHttpRequest(req, res);
440
437
  }).listen(3456, () => {
441
438
  console.log('MCP server at http://localhost:3456');
442
439
  });
@@ -461,8 +458,7 @@ import {
461
458
 
462
459
  // Tool definitions
463
460
  docsSearchTool,
464
- docsGetPageTool,
465
- docsGetSectionTool,
461
+ docsFetchTool,
466
462
 
467
463
  // Utilities
468
464
  htmlToMarkdown,
@@ -470,6 +466,12 @@ import {
470
466
  extractHeadingsFromMarkdown,
471
467
  buildSearchIndex,
472
468
 
469
+ // Provider types (for custom implementations)
470
+ loadIndexer,
471
+ loadSearchProvider,
472
+ FlexSearchIndexer,
473
+ FlexSearchProvider,
474
+
473
475
  // Default options
474
476
  DEFAULT_OPTIONS,
475
477
  } 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 };