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 +36 -35
- package/dist/adapters-entry.d.mts +48 -3
- package/dist/adapters-entry.d.ts +48 -3
- package/dist/adapters-entry.js +182 -188
- package/dist/adapters-entry.js.map +1 -1
- package/dist/adapters-entry.mjs +181 -189
- package/dist/adapters-entry.mjs.map +1 -1
- package/dist/cli/verify.js +45 -173
- package/dist/cli/verify.js.map +1 -1
- package/dist/cli/verify.mjs +45 -173
- package/dist/cli/verify.mjs.map +1 -1
- package/dist/{index-4g0ZZK3z.d.mts → index-j-CdaS6k.d.mts} +8 -15
- package/dist/{index-4g0ZZK3z.d.ts → index-j-CdaS6k.d.ts} +8 -15
- package/dist/index.d.mts +19 -54
- package/dist/index.d.ts +19 -54
- package/dist/index.js +54 -274
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -270
- package/dist/index.mjs.map +1 -1
- package/dist/theme/index.d.mts +1 -1
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.js +0 -4
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/index.mjs +1 -2
- package/dist/theme/index.mjs.map +1 -1
- package/package.json +2 -1
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
|
|
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
|
-
|
|
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
|
-
|
|
214
|
+
### `docs_fetch`
|
|
211
215
|
|
|
212
|
-
|
|
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": "
|
|
220
|
+
"name": "docs_fetch",
|
|
232
221
|
"arguments": {
|
|
233
|
-
"
|
|
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
|
-
| `
|
|
242
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
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
|
-
|
|
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 };
|
package/dist/adapters-entry.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import { M as McpServerConfig, P as ProcessedDoc } from './index-
|
|
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
|
-
|
|
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 };
|