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 +38 -36
- package/dist/adapters-entry.d.mts +48 -3
- package/dist/adapters-entry.d.ts +48 -3
- package/dist/adapters-entry.js +182 -74
- package/dist/adapters-entry.js.map +1 -1
- package/dist/adapters-entry.mjs +181 -75
- package/dist/adapters-entry.mjs.map +1 -1
- package/dist/cli/verify.js +45 -59
- package/dist/cli/verify.js.map +1 -1
- package/dist/cli/verify.mjs +45 -59
- 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 +16 -29
- package/dist/index.d.ts +16 -29
- package/dist/index.js +51 -144
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -144
- package/dist/index.mjs.map +1 -1
- package/dist/theme/index.d.mts +5 -3
- package/dist/theme/index.d.ts +5 -3
- package/dist/theme/index.js +23 -27
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/index.mjs +24 -25
- package/dist/theme/index.mjs.map +1 -1
- package/package.json +2 -1
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` |
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
215
|
+
### `docs_fetch`
|
|
211
216
|
|
|
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.
|
|
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": "
|
|
221
|
+
"name": "docs_fetch",
|
|
232
222
|
"arguments": {
|
|
233
|
-
"
|
|
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
|
-
| `
|
|
242
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
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 };
|