docusaurus-plugin-mcp-server 0.10.0 → 0.10.2
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 +17 -7
- package/dist/adapters-entry.d.ts +12 -6
- package/dist/adapters-entry.js +30 -38
- package/dist/adapters-entry.js.map +1 -1
- package/dist/cli/verify.js +36 -44
- package/dist/cli/verify.js.map +1 -1
- package/dist/index.js +50 -86
- package/dist/index.js.map +1 -1
- package/dist/theme/index.js +48 -58
- package/dist/theme/index.js.map +1 -1
- package/package.json +10 -9
- package/dist/adapters-entry.d.mts +0 -225
- package/dist/adapters-entry.mjs +0 -1032
- package/dist/adapters-entry.mjs.map +0 -1
- package/dist/cli/verify.d.mts +0 -1
- package/dist/cli/verify.mjs +0 -705
- package/dist/cli/verify.mjs.map +0 -1
- package/dist/index-j-CdaS6k.d.mts +0 -216
- package/dist/index.d.mts +0 -479
- package/dist/index.mjs +0 -1056
- package/dist/index.mjs.map +0 -1
- package/dist/theme/index.d.mts +0 -90
- package/dist/theme/index.mjs +0 -440
- package/dist/theme/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -43,10 +43,13 @@ Choose your deployment platform:
|
|
|
43
43
|
Create `api/mcp.js`:
|
|
44
44
|
|
|
45
45
|
```javascript
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
import { createVercelHandler } from 'docusaurus-plugin-mcp-server/adapters';
|
|
47
|
+
import path from 'path';
|
|
48
|
+
import { fileURLToPath } from 'url';
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
51
|
+
|
|
52
|
+
export default createVercelHandler({
|
|
50
53
|
docsPath: path.join(__dirname, '../build/mcp/docs.json'),
|
|
51
54
|
indexPath: path.join(__dirname, '../build/mcp/search-index.json'),
|
|
52
55
|
name: 'my-docs',
|
|
@@ -77,10 +80,13 @@ Add to `vercel.json`:
|
|
|
77
80
|
Create `netlify/functions/mcp.js`:
|
|
78
81
|
|
|
79
82
|
```javascript
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
import { createNetlifyHandler } from 'docusaurus-plugin-mcp-server/adapters';
|
|
84
|
+
import path from 'path';
|
|
85
|
+
import { fileURLToPath } from 'url';
|
|
86
|
+
|
|
87
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
82
88
|
|
|
83
|
-
|
|
89
|
+
export const handler = createNetlifyHandler({
|
|
84
90
|
docsPath: path.join(__dirname, '../../build/mcp/docs.json'),
|
|
85
91
|
indexPath: path.join(__dirname, '../../build/mcp/search-index.json'),
|
|
86
92
|
name: 'my-docs',
|
|
@@ -170,7 +176,11 @@ function NavbarItems() {
|
|
|
170
176
|
}
|
|
171
177
|
```
|
|
172
178
|
|
|
173
|
-
The button shows a dropdown with copy-to-clipboard configurations for all supported MCP clients
|
|
179
|
+
The button shows a dropdown with copy-to-clipboard configurations for all supported MCP clients.
|
|
180
|
+
|
|
181
|
+
| Light Mode | Dark Mode |
|
|
182
|
+
|:----------:|:---------:|
|
|
183
|
+
|  |  |
|
|
174
184
|
|
|
175
185
|
**Props:**
|
|
176
186
|
|
package/dist/adapters-entry.d.ts
CHANGED
|
@@ -8,10 +8,13 @@ import { M as McpServerConfig, P as ProcessedDoc, a as McpServerFileConfig } fro
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* // api/mcp.js
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* import { createVercelHandler } from 'docusaurus-plugin-mcp-server/adapters';
|
|
12
|
+
* import path from 'path';
|
|
13
|
+
* import { fileURLToPath } from 'url';
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
+
* const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
*
|
|
17
|
+
* export default createVercelHandler({
|
|
15
18
|
* docsPath: path.join(__dirname, '../build/mcp/docs.json'),
|
|
16
19
|
* indexPath: path.join(__dirname, '../build/mcp/search-index.json'),
|
|
17
20
|
* name: 'my-docs',
|
|
@@ -48,10 +51,13 @@ declare function createVercelHandler(config: McpServerConfig): (req: VercelReque
|
|
|
48
51
|
*
|
|
49
52
|
* @example
|
|
50
53
|
* // netlify/functions/mcp.js
|
|
51
|
-
*
|
|
52
|
-
*
|
|
54
|
+
* import { createNetlifyHandler } from 'docusaurus-plugin-mcp-server/adapters';
|
|
55
|
+
* import path from 'path';
|
|
56
|
+
* import { fileURLToPath } from 'url';
|
|
57
|
+
*
|
|
58
|
+
* const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
53
59
|
*
|
|
54
|
-
*
|
|
60
|
+
* export const handler = createNetlifyHandler({
|
|
55
61
|
* docsPath: path.join(__dirname, '../../build/mcp/docs.json'),
|
|
56
62
|
* indexPath: path.join(__dirname, '../../build/mcp/search-index.json'),
|
|
57
63
|
* name: 'my-docs',
|
package/dist/adapters-entry.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var zod = require('zod');
|
|
9
|
-
var http = require('http');
|
|
10
|
-
|
|
11
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
|
|
13
|
-
var FlexSearch__default = /*#__PURE__*/_interopDefault(FlexSearch);
|
|
14
|
-
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
3
|
+
import { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
|
|
4
|
+
import FlexSearch from 'flexsearch';
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { createServer } from 'http';
|
|
15
8
|
|
|
16
9
|
// src/mcp/server.ts
|
|
17
10
|
var FIELD_WEIGHTS = {
|
|
@@ -25,7 +18,7 @@ function englishStemmer(word) {
|
|
|
25
18
|
return word.replace(/ing$/, "").replace(/tion$/, "t").replace(/sion$/, "s").replace(/([^aeiou])ed$/, "$1").replace(/([^aeiou])es$/, "$1").replace(/ly$/, "").replace(/ment$/, "").replace(/ness$/, "").replace(/ies$/, "y").replace(/([^s])s$/, "$1");
|
|
26
19
|
}
|
|
27
20
|
function createSearchIndex() {
|
|
28
|
-
return new
|
|
21
|
+
return new FlexSearch.Document({
|
|
29
22
|
// Use 'full' tokenization for substring matching
|
|
30
23
|
// This allows "auth" to match "authentication"
|
|
31
24
|
tokenize: "full",
|
|
@@ -162,13 +155,13 @@ var FlexSearchProvider = class {
|
|
|
162
155
|
return;
|
|
163
156
|
}
|
|
164
157
|
if (initData.docsPath && initData.indexPath) {
|
|
165
|
-
if (await
|
|
166
|
-
this.docs = await
|
|
158
|
+
if (await fs.pathExists(initData.docsPath)) {
|
|
159
|
+
this.docs = await fs.readJson(initData.docsPath);
|
|
167
160
|
} else {
|
|
168
161
|
throw new Error(`[FlexSearch] Docs file not found: ${initData.docsPath}`);
|
|
169
162
|
}
|
|
170
|
-
if (await
|
|
171
|
-
const indexData = await
|
|
163
|
+
if (await fs.pathExists(initData.indexPath)) {
|
|
164
|
+
const indexData = await fs.readJson(initData.indexPath);
|
|
172
165
|
this.searchIndex = await importSearchIndex(indexData);
|
|
173
166
|
} else {
|
|
174
167
|
throw new Error(`[FlexSearch] Search index not found: ${initData.indexPath}`);
|
|
@@ -260,8 +253,8 @@ function isSearchProvider(obj) {
|
|
|
260
253
|
return typeof provider.name === "string" && typeof provider.initialize === "function" && typeof provider.isReady === "function" && typeof provider.search === "function";
|
|
261
254
|
}
|
|
262
255
|
var docsSearchInputSchema = {
|
|
263
|
-
query:
|
|
264
|
-
limit:
|
|
256
|
+
query: z.string().min(1).describe("The search query string"),
|
|
257
|
+
limit: z.number().int().min(1).max(20).optional().default(5).describe("Maximum number of results to return (1-20, default: 5)")
|
|
265
258
|
};
|
|
266
259
|
var docsSearchTool = {
|
|
267
260
|
name: "docs_search",
|
|
@@ -289,7 +282,7 @@ function formatSearchResults(results) {
|
|
|
289
282
|
return lines.join("\n");
|
|
290
283
|
}
|
|
291
284
|
var docsFetchInputSchema = {
|
|
292
|
-
url:
|
|
285
|
+
url: z.string().url().describe(
|
|
293
286
|
'The full URL of the page to fetch (e.g., "https://docs.example.com/docs/getting-started")'
|
|
294
287
|
)
|
|
295
288
|
};
|
|
@@ -340,7 +333,7 @@ var McpDocsServer = class {
|
|
|
340
333
|
initialized = false;
|
|
341
334
|
constructor(config) {
|
|
342
335
|
this.config = config;
|
|
343
|
-
this.mcpServer = new
|
|
336
|
+
this.mcpServer = new McpServer(
|
|
344
337
|
{
|
|
345
338
|
name: config.name,
|
|
346
339
|
version: config.version ?? "1.0.0"
|
|
@@ -475,7 +468,7 @@ var McpDocsServer = class {
|
|
|
475
468
|
*/
|
|
476
469
|
async handleHttpRequest(req, res, parsedBody) {
|
|
477
470
|
await this.initialize();
|
|
478
|
-
const transport = new
|
|
471
|
+
const transport = new StreamableHTTPServerTransport({
|
|
479
472
|
sessionIdGenerator: void 0,
|
|
480
473
|
// Stateless mode - no session tracking
|
|
481
474
|
enableJsonResponse: true
|
|
@@ -499,7 +492,7 @@ var McpDocsServer = class {
|
|
|
499
492
|
*/
|
|
500
493
|
async handleWebRequest(request) {
|
|
501
494
|
await this.initialize();
|
|
502
|
-
const transport = new
|
|
495
|
+
const transport = new WebStandardStreamableHTTPServerTransport({
|
|
503
496
|
sessionIdGenerator: void 0,
|
|
504
497
|
// Stateless mode
|
|
505
498
|
enableJsonResponse: true
|
|
@@ -809,12 +802,14 @@ function generateVercelFiles(name, baseUrl) {
|
|
|
809
802
|
* Deploy to Vercel and this will be available at /api/mcp
|
|
810
803
|
*/
|
|
811
804
|
|
|
812
|
-
|
|
813
|
-
|
|
805
|
+
import { createVercelHandler } from 'docusaurus-plugin-mcp-server/adapters';
|
|
806
|
+
import path from 'path';
|
|
807
|
+
import { fileURLToPath } from 'url';
|
|
814
808
|
|
|
809
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
815
810
|
const projectRoot = path.join(__dirname, '..');
|
|
816
811
|
|
|
817
|
-
|
|
812
|
+
export default createVercelHandler({
|
|
818
813
|
docsPath: path.join(projectRoot, 'build/mcp/docs.json'),
|
|
819
814
|
indexPath: path.join(projectRoot, 'build/mcp/search-index.json'),
|
|
820
815
|
name: '${name}',
|
|
@@ -853,12 +848,14 @@ function generateNetlifyFiles(name, baseUrl) {
|
|
|
853
848
|
* Deploy to Netlify and this will be available at /.netlify/functions/mcp
|
|
854
849
|
*/
|
|
855
850
|
|
|
856
|
-
|
|
857
|
-
|
|
851
|
+
import { createNetlifyHandler } from 'docusaurus-plugin-mcp-server/adapters';
|
|
852
|
+
import path from 'path';
|
|
853
|
+
import { fileURLToPath } from 'url';
|
|
858
854
|
|
|
855
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
859
856
|
const projectRoot = path.join(__dirname, '../..');
|
|
860
857
|
|
|
861
|
-
|
|
858
|
+
export const handler = createNetlifyHandler({
|
|
862
859
|
docsPath: path.join(projectRoot, 'build/mcp/docs.json'),
|
|
863
860
|
indexPath: path.join(projectRoot, 'build/mcp/search-index.json'),
|
|
864
861
|
name: '${name}',
|
|
@@ -1015,7 +1012,7 @@ function createNodeHandler(options) {
|
|
|
1015
1012
|
}
|
|
1016
1013
|
function createNodeServer(options) {
|
|
1017
1014
|
const handler = createNodeHandler(options);
|
|
1018
|
-
return
|
|
1015
|
+
return createServer(handler);
|
|
1019
1016
|
}
|
|
1020
1017
|
async function parseRequestBody(req) {
|
|
1021
1018
|
return new Promise((resolve, reject) => {
|
|
@@ -1034,11 +1031,6 @@ async function parseRequestBody(req) {
|
|
|
1034
1031
|
});
|
|
1035
1032
|
}
|
|
1036
1033
|
|
|
1037
|
-
|
|
1038
|
-
exports.createNetlifyHandler = createNetlifyHandler;
|
|
1039
|
-
exports.createNodeHandler = createNodeHandler;
|
|
1040
|
-
exports.createNodeServer = createNodeServer;
|
|
1041
|
-
exports.createVercelHandler = createVercelHandler;
|
|
1042
|
-
exports.generateAdapterFiles = generateAdapterFiles;
|
|
1034
|
+
export { createCloudflareHandler, createNetlifyHandler, createNodeHandler, createNodeServer, createVercelHandler, generateAdapterFiles };
|
|
1043
1035
|
//# sourceMappingURL=adapters-entry.js.map
|
|
1044
1036
|
//# sourceMappingURL=adapters-entry.js.map
|