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 CHANGED
@@ -43,10 +43,13 @@ Choose your deployment platform:
43
43
  Create `api/mcp.js`:
44
44
 
45
45
  ```javascript
46
- const { createVercelHandler } = require('docusaurus-plugin-mcp-server/adapters');
47
- const path = require('path');
46
+ import { createVercelHandler } from 'docusaurus-plugin-mcp-server/adapters';
47
+ import path from 'path';
48
+ import { fileURLToPath } from 'url';
48
49
 
49
- module.exports = createVercelHandler({
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
- const { createNetlifyHandler } = require('docusaurus-plugin-mcp-server/adapters');
81
- const path = require('path');
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
- exports.handler = createNetlifyHandler({
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 (Claude Code, Cursor, VS Code, Windsurf, Claude Desktop).
179
+ The button shows a dropdown with copy-to-clipboard configurations for all supported MCP clients.
180
+
181
+ | Light Mode | Dark Mode |
182
+ |:----------:|:---------:|
183
+ | ![MCP Install Button - Light Mode](./img/mcp-button-light.png) | ![MCP Install Button - Dark Mode](./img/mcp-button-dark.png) |
174
184
 
175
185
  **Props:**
176
186
 
@@ -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
- * const { createVercelHandler } = require('docusaurus-plugin-mcp-server/adapters');
12
- * const path = require('path');
11
+ * import { createVercelHandler } from 'docusaurus-plugin-mcp-server/adapters';
12
+ * import path from 'path';
13
+ * import { fileURLToPath } from 'url';
13
14
  *
14
- * module.exports = createVercelHandler({
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
- * const { createNetlifyHandler } = require('docusaurus-plugin-mcp-server/adapters');
52
- * const path = require('path');
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
- * exports.handler = createNetlifyHandler({
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',
@@ -1,17 +1,10 @@
1
- 'use strict';
2
-
3
- var mcp_js = require('@modelcontextprotocol/sdk/server/mcp.js');
4
- var streamableHttp_js = require('@modelcontextprotocol/sdk/server/streamableHttp.js');
5
- var webStandardStreamableHttp_js = require('@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js');
6
- var FlexSearch = require('flexsearch');
7
- var fs = require('fs-extra');
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 FlexSearch__default.default.Document({
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 fs__default.default.pathExists(initData.docsPath)) {
166
- this.docs = await fs__default.default.readJson(initData.docsPath);
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 fs__default.default.pathExists(initData.indexPath)) {
171
- const indexData = await fs__default.default.readJson(initData.indexPath);
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: zod.z.string().min(1).describe("The search query string"),
264
- limit: zod.z.number().int().min(1).max(20).optional().default(5).describe("Maximum number of results to return (1-20, default: 5)")
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: zod.z.string().url().describe(
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 mcp_js.McpServer(
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 streamableHttp_js.StreamableHTTPServerTransport({
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 webStandardStreamableHttp_js.WebStandardStreamableHTTPServerTransport({
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
- const { createVercelHandler } = require('docusaurus-plugin-mcp-server/adapters');
813
- const path = require('path');
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
- module.exports = createVercelHandler({
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
- const { createNetlifyHandler } = require('docusaurus-plugin-mcp-server/adapters');
857
- const path = require('path');
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
- exports.handler = createNetlifyHandler({
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 http.createServer(handler);
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
- exports.createCloudflareHandler = createCloudflareHandler;
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