docusaurus-plugin-mcp-server 0.5.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/LICENSE +21 -0
- package/README.md +505 -0
- package/dist/adapters-entry.d.mts +180 -0
- package/dist/adapters-entry.d.ts +180 -0
- package/dist/adapters-entry.js +918 -0
- package/dist/adapters-entry.js.map +1 -0
- package/dist/adapters-entry.mjs +908 -0
- package/dist/adapters-entry.mjs.map +1 -0
- package/dist/cli/verify.d.mts +1 -0
- package/dist/cli/verify.d.ts +1 -0
- package/dist/cli/verify.js +710 -0
- package/dist/cli/verify.js.map +1 -0
- package/dist/cli/verify.mjs +702 -0
- package/dist/cli/verify.mjs.map +1 -0
- package/dist/index-CzA4FjeE.d.mts +190 -0
- package/dist/index-CzA4FjeE.d.ts +190 -0
- package/dist/index.d.mts +234 -0
- package/dist/index.d.ts +234 -0
- package/dist/index.js +1070 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1037 -0
- package/dist/index.mjs.map +1 -0
- package/dist/theme/index.d.mts +87 -0
- package/dist/theme/index.d.ts +87 -0
- package/dist/theme/index.js +299 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/index.mjs +291 -0
- package/dist/theme/index.mjs.map +1 -0
- package/package.json +145 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { M as McpServerConfig, P as ProcessedDoc } from './index-CzA4FjeE.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Vercel adapter for MCP server
|
|
6
|
+
*
|
|
7
|
+
* Creates a Vercel serverless function handler for the MCP server.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // api/mcp.js
|
|
11
|
+
* const { createVercelHandler } = require('docusaurus-plugin-mcp-server/adapters');
|
|
12
|
+
* const path = require('path');
|
|
13
|
+
*
|
|
14
|
+
* module.exports = createVercelHandler({
|
|
15
|
+
* docsPath: path.join(__dirname, '../build/mcp/docs.json'),
|
|
16
|
+
* indexPath: path.join(__dirname, '../build/mcp/search-index.json'),
|
|
17
|
+
* name: 'my-docs',
|
|
18
|
+
* baseUrl: 'https://docs.example.com',
|
|
19
|
+
* });
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Vercel request object (extends Node.js IncomingMessage)
|
|
24
|
+
*/
|
|
25
|
+
interface VercelRequest extends IncomingMessage {
|
|
26
|
+
body?: unknown;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Vercel response object (extends Node.js ServerResponse)
|
|
30
|
+
*/
|
|
31
|
+
interface VercelResponse extends ServerResponse {
|
|
32
|
+
status(code: number): VercelResponse;
|
|
33
|
+
json(data: unknown): void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a Vercel serverless function handler for the MCP server
|
|
37
|
+
*
|
|
38
|
+
* Uses the MCP SDK's StreamableHTTPServerTransport for proper protocol handling.
|
|
39
|
+
*/
|
|
40
|
+
declare function createVercelHandler(config: McpServerConfig): (req: VercelRequest, res: VercelResponse) => Promise<void>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Netlify adapter for MCP server
|
|
44
|
+
*
|
|
45
|
+
* Creates a Netlify serverless function handler for the MCP server.
|
|
46
|
+
* Converts Netlify's AWS Lambda-style events to Web Standard Request
|
|
47
|
+
* and uses the MCP SDK's transport for proper protocol handling.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* // netlify/functions/mcp.js
|
|
51
|
+
* const { createNetlifyHandler } = require('docusaurus-plugin-mcp-server/adapters');
|
|
52
|
+
* const path = require('path');
|
|
53
|
+
*
|
|
54
|
+
* exports.handler = createNetlifyHandler({
|
|
55
|
+
* docsPath: path.join(__dirname, '../../build/mcp/docs.json'),
|
|
56
|
+
* indexPath: path.join(__dirname, '../../build/mcp/search-index.json'),
|
|
57
|
+
* name: 'my-docs',
|
|
58
|
+
* baseUrl: 'https://docs.example.com',
|
|
59
|
+
* });
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Netlify event object (simplified interface)
|
|
64
|
+
*/
|
|
65
|
+
interface NetlifyEvent {
|
|
66
|
+
httpMethod: string;
|
|
67
|
+
headers: Record<string, string | undefined>;
|
|
68
|
+
body: string | null;
|
|
69
|
+
isBase64Encoded?: boolean;
|
|
70
|
+
path?: string;
|
|
71
|
+
rawUrl?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Netlify context object (simplified interface)
|
|
75
|
+
*/
|
|
76
|
+
interface NetlifyContext {
|
|
77
|
+
functionName: string;
|
|
78
|
+
functionVersion?: string;
|
|
79
|
+
invokedFunctionArn?: string;
|
|
80
|
+
memoryLimitInMB?: string;
|
|
81
|
+
awsRequestId?: string;
|
|
82
|
+
logGroupName?: string;
|
|
83
|
+
logStreamName?: string;
|
|
84
|
+
getRemainingTimeInMillis?: () => number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Netlify function response
|
|
88
|
+
*/
|
|
89
|
+
interface NetlifyResponse {
|
|
90
|
+
statusCode: number;
|
|
91
|
+
headers?: Record<string, string>;
|
|
92
|
+
body?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Create a Netlify serverless function handler for the MCP server
|
|
96
|
+
*
|
|
97
|
+
* Uses the MCP SDK's WebStandardStreamableHTTPServerTransport for
|
|
98
|
+
* proper protocol handling.
|
|
99
|
+
*/
|
|
100
|
+
declare function createNetlifyHandler(config: McpServerConfig): (event: NetlifyEvent, _context: NetlifyContext) => Promise<NetlifyResponse>;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Cloudflare Workers adapter for MCP server
|
|
104
|
+
*
|
|
105
|
+
* Creates a Cloudflare Workers fetch handler for the MCP server.
|
|
106
|
+
* Since Workers can't access the filesystem, this adapter requires
|
|
107
|
+
* pre-loaded docs and search index data.
|
|
108
|
+
*
|
|
109
|
+
* Uses the MCP SDK's WebStandardStreamableHTTPServerTransport for proper
|
|
110
|
+
* protocol handling with Web Standard Request/Response.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* // src/worker.js
|
|
114
|
+
* import { createCloudflareHandler } from 'docusaurus-plugin-mcp-server/adapters';
|
|
115
|
+
* import docs from '../build/mcp/docs.json';
|
|
116
|
+
* import searchIndex from '../build/mcp/search-index.json';
|
|
117
|
+
*
|
|
118
|
+
* export default {
|
|
119
|
+
* fetch: createCloudflareHandler({
|
|
120
|
+
* docs,
|
|
121
|
+
* searchIndexData: searchIndex,
|
|
122
|
+
* name: 'my-docs',
|
|
123
|
+
* baseUrl: 'https://docs.example.com',
|
|
124
|
+
* }),
|
|
125
|
+
* };
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Config for Cloudflare Workers adapter
|
|
130
|
+
*/
|
|
131
|
+
interface CloudflareAdapterConfig {
|
|
132
|
+
/** Pre-loaded docs data (imported from docs.json) */
|
|
133
|
+
docs: Record<string, ProcessedDoc>;
|
|
134
|
+
/** Pre-loaded search index data (imported from search-index.json) */
|
|
135
|
+
searchIndexData: Record<string, unknown>;
|
|
136
|
+
/** Server name */
|
|
137
|
+
name: string;
|
|
138
|
+
/** Server version */
|
|
139
|
+
version?: string;
|
|
140
|
+
/** Base URL for constructing full page URLs */
|
|
141
|
+
baseUrl?: string;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Create a Cloudflare Workers fetch handler for the MCP server
|
|
145
|
+
*
|
|
146
|
+
* Uses the MCP SDK's WebStandardStreamableHTTPServerTransport for
|
|
147
|
+
* proper protocol handling.
|
|
148
|
+
*/
|
|
149
|
+
declare function createCloudflareHandler(config: CloudflareAdapterConfig): (request: Request) => Promise<Response>;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Adapter file generator
|
|
153
|
+
*
|
|
154
|
+
* Generates platform-specific adapter files for deploying the MCP server.
|
|
155
|
+
*/
|
|
156
|
+
type Platform = 'vercel' | 'netlify' | 'cloudflare';
|
|
157
|
+
interface GeneratorOptions {
|
|
158
|
+
/** Target platform */
|
|
159
|
+
platform: Platform;
|
|
160
|
+
/** Server name */
|
|
161
|
+
name: string;
|
|
162
|
+
/** Base URL for the documentation site */
|
|
163
|
+
baseUrl: string;
|
|
164
|
+
/** Output path for the generated files (defaults to current directory) */
|
|
165
|
+
outputPath?: string;
|
|
166
|
+
}
|
|
167
|
+
interface GeneratedFile {
|
|
168
|
+
/** Relative path for the file */
|
|
169
|
+
path: string;
|
|
170
|
+
/** File contents */
|
|
171
|
+
content: string;
|
|
172
|
+
/** Description of the file */
|
|
173
|
+
description: string;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Generate adapter files for a specific platform
|
|
177
|
+
*/
|
|
178
|
+
declare function generateAdapterFiles(options: GeneratorOptions): GeneratedFile[];
|
|
179
|
+
|
|
180
|
+
export { type CloudflareAdapterConfig, type GeneratedFile, type GeneratorOptions, type NetlifyContext, type NetlifyEvent, type Platform, type VercelRequest, type VercelResponse, createCloudflareHandler, createNetlifyHandler, createVercelHandler, generateAdapterFiles };
|