mcp-docs-service 0.1.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 +214 -0
- package/dist/cli/bin.d.ts +6 -0
- package/dist/cli/bin.js +49 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/index.d.ts +16 -0
- package/dist/cli/index.js +96 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/docAnalyzer.d.ts +25 -0
- package/dist/core/docAnalyzer.js +118 -0
- package/dist/core/docAnalyzer.js.map +1 -0
- package/dist/core/docManager.d.ts +48 -0
- package/dist/core/docManager.js +257 -0
- package/dist/core/docManager.js.map +1 -0
- package/dist/core/docProcessor.d.ts +20 -0
- package/dist/core/docProcessor.js +127 -0
- package/dist/core/docProcessor.js.map +1 -0
- package/dist/core/mcpDocsServer.d.ts +61 -0
- package/dist/core/mcpDocsServer.js +395 -0
- package/dist/core/mcpDocsServer.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +53 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +60 -0
- package/dist/utils/index.js +152 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +45 -0
@@ -0,0 +1,395 @@
|
|
1
|
+
"use strict";
|
2
|
+
/**
|
3
|
+
* MCP Documentation Management Server
|
4
|
+
* This server implements the Model Context Protocol for managing documentation
|
5
|
+
*/
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
7
|
+
exports.MCPDocsServer = void 0;
|
8
|
+
const docManager_js_1 = require("./docManager.js");
|
9
|
+
const docAnalyzer_js_1 = require("./docAnalyzer.js");
|
10
|
+
class MCPDocsServer {
|
11
|
+
constructor(docsDir = "./docs", options = {}) {
|
12
|
+
this.docManager = new docManager_js_1.DocManager(docsDir, options);
|
13
|
+
this.docAnalyzer = new docAnalyzer_js_1.DocAnalyzer(this.docManager);
|
14
|
+
// Log initialization info
|
15
|
+
console.error(`MCP Documentation Service initialized with docs directory: ${docsDir}`);
|
16
|
+
if (options.createIfNotExists) {
|
17
|
+
console.error("Directory will be created if it doesn't exist");
|
18
|
+
}
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* Execute a query using the MCP protocol
|
22
|
+
*/
|
23
|
+
async executeQuery(sql) {
|
24
|
+
try {
|
25
|
+
// Parse the SQL-like query to extract command and parameters
|
26
|
+
const { command, params } = this.parseQuery(sql);
|
27
|
+
// Execute the appropriate command
|
28
|
+
switch (command) {
|
29
|
+
case "list_files":
|
30
|
+
return await this.listFiles(params);
|
31
|
+
case "list_directories":
|
32
|
+
return await this.listDirectories(params);
|
33
|
+
case "get_document":
|
34
|
+
return await this.getDocument(params);
|
35
|
+
case "search_documents":
|
36
|
+
return await this.searchDocuments(params);
|
37
|
+
case "create_document":
|
38
|
+
return await this.createDocument(params);
|
39
|
+
case "update_document":
|
40
|
+
return await this.updateDocument(params);
|
41
|
+
case "delete_document":
|
42
|
+
return await this.deleteDocument(params);
|
43
|
+
case "analyze_docs":
|
44
|
+
return await this.analyzeDocumentation(params);
|
45
|
+
case "get_health_score":
|
46
|
+
return await this.getHealthScore();
|
47
|
+
case "get_suggestions":
|
48
|
+
return await this.getSuggestions();
|
49
|
+
default:
|
50
|
+
return {
|
51
|
+
success: false,
|
52
|
+
error: `Unknown command: ${command}`,
|
53
|
+
};
|
54
|
+
}
|
55
|
+
}
|
56
|
+
catch (error) {
|
57
|
+
console.error("Error executing query:", error);
|
58
|
+
return {
|
59
|
+
success: false,
|
60
|
+
error: error instanceof Error ? error.message : String(error),
|
61
|
+
};
|
62
|
+
}
|
63
|
+
}
|
64
|
+
/**
|
65
|
+
* Parse a query string into command and parameters
|
66
|
+
*/
|
67
|
+
parseQuery(query) {
|
68
|
+
// Default to empty parameters
|
69
|
+
const params = {};
|
70
|
+
// Handle simple command syntax
|
71
|
+
if (query.indexOf("(") === -1) {
|
72
|
+
return { command: query.trim(), params };
|
73
|
+
}
|
74
|
+
// Extract command name
|
75
|
+
const commandMatch = query.match(/^\s*(\w+)\s*\(/);
|
76
|
+
if (!commandMatch) {
|
77
|
+
throw new Error(`Invalid query format: ${query}`);
|
78
|
+
}
|
79
|
+
const command = commandMatch[1];
|
80
|
+
// Extract parameters between parentheses
|
81
|
+
const paramsMatch = query.match(/\(\s*(.*)\s*\)/s);
|
82
|
+
if (!paramsMatch) {
|
83
|
+
return { command, params };
|
84
|
+
}
|
85
|
+
// Parse parameter string
|
86
|
+
const paramsStr = paramsMatch[1];
|
87
|
+
// Handle JSON object parameters
|
88
|
+
if (paramsStr.trim().startsWith("{") && paramsStr.trim().endsWith("}")) {
|
89
|
+
try {
|
90
|
+
return { command, params: JSON.parse(paramsStr) };
|
91
|
+
}
|
92
|
+
catch (e) {
|
93
|
+
throw new Error(`Invalid JSON parameters: ${e instanceof Error ? e.message : String(e)}`);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
// Parse key=value parameters
|
97
|
+
let currentKey = "";
|
98
|
+
let currentValue = "";
|
99
|
+
let inQuotes = false;
|
100
|
+
let inObject = false;
|
101
|
+
let inArray = false;
|
102
|
+
let objectDepth = 0;
|
103
|
+
let arrayDepth = 0;
|
104
|
+
for (let i = 0; i < paramsStr.length; i++) {
|
105
|
+
const char = paramsStr[i];
|
106
|
+
const nextChar = paramsStr[i + 1] || "";
|
107
|
+
// Handle quotes
|
108
|
+
if (char === '"' && paramsStr[i - 1] !== "\\") {
|
109
|
+
inQuotes = !inQuotes;
|
110
|
+
currentValue += char;
|
111
|
+
continue;
|
112
|
+
}
|
113
|
+
// Handle objects
|
114
|
+
if (char === "{" && !inQuotes) {
|
115
|
+
inObject = true;
|
116
|
+
objectDepth++;
|
117
|
+
currentValue += char;
|
118
|
+
continue;
|
119
|
+
}
|
120
|
+
if (char === "}" && !inQuotes) {
|
121
|
+
objectDepth--;
|
122
|
+
if (objectDepth === 0)
|
123
|
+
inObject = false;
|
124
|
+
currentValue += char;
|
125
|
+
continue;
|
126
|
+
}
|
127
|
+
// Handle arrays
|
128
|
+
if (char === "[" && !inQuotes) {
|
129
|
+
inArray = true;
|
130
|
+
arrayDepth++;
|
131
|
+
currentValue += char;
|
132
|
+
continue;
|
133
|
+
}
|
134
|
+
if (char === "]" && !inQuotes) {
|
135
|
+
arrayDepth--;
|
136
|
+
if (arrayDepth === 0)
|
137
|
+
inArray = false;
|
138
|
+
currentValue += char;
|
139
|
+
continue;
|
140
|
+
}
|
141
|
+
// Handle key=value separator
|
142
|
+
if (char === "=" &&
|
143
|
+
!inQuotes &&
|
144
|
+
!inObject &&
|
145
|
+
!inArray &&
|
146
|
+
currentKey === "") {
|
147
|
+
currentKey = currentValue.trim();
|
148
|
+
currentValue = "";
|
149
|
+
continue;
|
150
|
+
}
|
151
|
+
// Handle parameter separator
|
152
|
+
if (char === "," && !inQuotes && !inObject && !inArray) {
|
153
|
+
if (currentKey && currentValue) {
|
154
|
+
// Try to parse the value
|
155
|
+
try {
|
156
|
+
if (currentValue.startsWith('"') && currentValue.endsWith('"')) {
|
157
|
+
// String value
|
158
|
+
params[currentKey] = JSON.parse(currentValue);
|
159
|
+
}
|
160
|
+
else if (currentValue.toLowerCase() === "true" ||
|
161
|
+
currentValue.toLowerCase() === "false") {
|
162
|
+
// Boolean value
|
163
|
+
params[currentKey] = currentValue.toLowerCase() === "true";
|
164
|
+
}
|
165
|
+
else if (!isNaN(Number(currentValue))) {
|
166
|
+
// Number value
|
167
|
+
params[currentKey] = Number(currentValue);
|
168
|
+
}
|
169
|
+
else if (currentValue.startsWith("[") &&
|
170
|
+
currentValue.endsWith("]")) {
|
171
|
+
// Array value
|
172
|
+
params[currentKey] = JSON.parse(currentValue);
|
173
|
+
}
|
174
|
+
else if (currentValue.startsWith("{") &&
|
175
|
+
currentValue.endsWith("}")) {
|
176
|
+
// Object value
|
177
|
+
params[currentKey] = JSON.parse(currentValue);
|
178
|
+
}
|
179
|
+
else {
|
180
|
+
// Everything else as string
|
181
|
+
params[currentKey] = currentValue;
|
182
|
+
}
|
183
|
+
}
|
184
|
+
catch (e) {
|
185
|
+
// If parsing fails, use as string
|
186
|
+
params[currentKey] = currentValue;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
currentKey = "";
|
190
|
+
currentValue = "";
|
191
|
+
continue;
|
192
|
+
}
|
193
|
+
// Add character to current value
|
194
|
+
currentValue += char;
|
195
|
+
}
|
196
|
+
// Handle the last parameter
|
197
|
+
if (currentKey && currentValue) {
|
198
|
+
try {
|
199
|
+
if (currentValue.startsWith('"') && currentValue.endsWith('"')) {
|
200
|
+
// String value
|
201
|
+
params[currentKey] = JSON.parse(currentValue);
|
202
|
+
}
|
203
|
+
else if (currentValue.toLowerCase() === "true" ||
|
204
|
+
currentValue.toLowerCase() === "false") {
|
205
|
+
// Boolean value
|
206
|
+
params[currentKey] = currentValue.toLowerCase() === "true";
|
207
|
+
}
|
208
|
+
else if (!isNaN(Number(currentValue))) {
|
209
|
+
// Number value
|
210
|
+
params[currentKey] = Number(currentValue);
|
211
|
+
}
|
212
|
+
else if (currentValue.startsWith("[") && currentValue.endsWith("]")) {
|
213
|
+
// Array value
|
214
|
+
params[currentKey] = JSON.parse(currentValue);
|
215
|
+
}
|
216
|
+
else if (currentValue.startsWith("{") && currentValue.endsWith("}")) {
|
217
|
+
// Object value
|
218
|
+
params[currentKey] = JSON.parse(currentValue);
|
219
|
+
}
|
220
|
+
else {
|
221
|
+
// Everything else as string
|
222
|
+
params[currentKey] = currentValue;
|
223
|
+
}
|
224
|
+
}
|
225
|
+
catch (e) {
|
226
|
+
// If parsing fails, use as string
|
227
|
+
params[currentKey] = currentValue;
|
228
|
+
}
|
229
|
+
}
|
230
|
+
return { command, params };
|
231
|
+
}
|
232
|
+
/**
|
233
|
+
* List all markdown files
|
234
|
+
*/
|
235
|
+
async listFiles(params) {
|
236
|
+
const directory = params.directory || "";
|
237
|
+
const files = await this.docManager.listMarkdownFiles(directory);
|
238
|
+
return {
|
239
|
+
success: true,
|
240
|
+
data: files,
|
241
|
+
};
|
242
|
+
}
|
243
|
+
/**
|
244
|
+
* List all directories
|
245
|
+
*/
|
246
|
+
async listDirectories(params) {
|
247
|
+
const directory = params.directory || "";
|
248
|
+
const directories = await this.docManager.listDirectories(directory);
|
249
|
+
return {
|
250
|
+
success: true,
|
251
|
+
data: directories,
|
252
|
+
};
|
253
|
+
}
|
254
|
+
/**
|
255
|
+
* Get a document by path
|
256
|
+
*/
|
257
|
+
async getDocument(params) {
|
258
|
+
if (!params.path) {
|
259
|
+
return {
|
260
|
+
success: false,
|
261
|
+
error: "Document path is required",
|
262
|
+
};
|
263
|
+
}
|
264
|
+
const document = await this.docManager.getDocument(params.path);
|
265
|
+
if (!document) {
|
266
|
+
return {
|
267
|
+
success: false,
|
268
|
+
error: `Document not found: ${params.path}`,
|
269
|
+
};
|
270
|
+
}
|
271
|
+
return {
|
272
|
+
success: true,
|
273
|
+
data: document,
|
274
|
+
};
|
275
|
+
}
|
276
|
+
/**
|
277
|
+
* Search for documents
|
278
|
+
*/
|
279
|
+
async searchDocuments(params) {
|
280
|
+
const options = {
|
281
|
+
query: params.query || "",
|
282
|
+
tags: params.tags,
|
283
|
+
status: params.status,
|
284
|
+
directory: params.directory,
|
285
|
+
};
|
286
|
+
const results = await this.docManager.searchDocuments(options);
|
287
|
+
return {
|
288
|
+
success: true,
|
289
|
+
data: results,
|
290
|
+
};
|
291
|
+
}
|
292
|
+
/**
|
293
|
+
* Create a new document
|
294
|
+
*/
|
295
|
+
async createDocument(params) {
|
296
|
+
if (!params.path) {
|
297
|
+
return {
|
298
|
+
success: false,
|
299
|
+
error: "Document path is required",
|
300
|
+
};
|
301
|
+
}
|
302
|
+
if (!params.content) {
|
303
|
+
return {
|
304
|
+
success: false,
|
305
|
+
error: "Document content is required",
|
306
|
+
};
|
307
|
+
}
|
308
|
+
if (!params.metadata || typeof params.metadata !== "object") {
|
309
|
+
return {
|
310
|
+
success: false,
|
311
|
+
error: "Document metadata is required",
|
312
|
+
};
|
313
|
+
}
|
314
|
+
const createParams = {
|
315
|
+
path: params.path,
|
316
|
+
content: params.content,
|
317
|
+
metadata: params.metadata,
|
318
|
+
};
|
319
|
+
const success = await this.docManager.createDocument(createParams);
|
320
|
+
return {
|
321
|
+
success,
|
322
|
+
data: { created: success },
|
323
|
+
};
|
324
|
+
}
|
325
|
+
/**
|
326
|
+
* Update an existing document
|
327
|
+
*/
|
328
|
+
async updateDocument(params) {
|
329
|
+
if (!params.path) {
|
330
|
+
return {
|
331
|
+
success: false,
|
332
|
+
error: "Document path is required",
|
333
|
+
};
|
334
|
+
}
|
335
|
+
const updateParams = {
|
336
|
+
path: params.path,
|
337
|
+
content: params.content,
|
338
|
+
metadata: params.metadata,
|
339
|
+
};
|
340
|
+
const success = await this.docManager.updateDocument(updateParams);
|
341
|
+
return {
|
342
|
+
success,
|
343
|
+
data: { updated: success },
|
344
|
+
};
|
345
|
+
}
|
346
|
+
/**
|
347
|
+
* Delete a document
|
348
|
+
*/
|
349
|
+
async deleteDocument(params) {
|
350
|
+
if (!params.path) {
|
351
|
+
return {
|
352
|
+
success: false,
|
353
|
+
error: "Document path is required",
|
354
|
+
};
|
355
|
+
}
|
356
|
+
const success = await this.docManager.deleteDocument(params.path);
|
357
|
+
return {
|
358
|
+
success,
|
359
|
+
data: { deleted: success },
|
360
|
+
};
|
361
|
+
}
|
362
|
+
/**
|
363
|
+
* Analyze documentation
|
364
|
+
*/
|
365
|
+
async analyzeDocumentation(params) {
|
366
|
+
const directory = params.directory;
|
367
|
+
const analysis = await this.docAnalyzer.analyzeDocumentation(directory);
|
368
|
+
return {
|
369
|
+
success: true,
|
370
|
+
data: analysis,
|
371
|
+
};
|
372
|
+
}
|
373
|
+
/**
|
374
|
+
* Get documentation health score
|
375
|
+
*/
|
376
|
+
async getHealthScore() {
|
377
|
+
const score = await this.docAnalyzer.calculateHealthScore();
|
378
|
+
return {
|
379
|
+
success: true,
|
380
|
+
data: { score },
|
381
|
+
};
|
382
|
+
}
|
383
|
+
/**
|
384
|
+
* Get suggestions for improving documentation
|
385
|
+
*/
|
386
|
+
async getSuggestions() {
|
387
|
+
const suggestions = await this.docAnalyzer.generateSuggestions();
|
388
|
+
return {
|
389
|
+
success: true,
|
390
|
+
data: { suggestions },
|
391
|
+
};
|
392
|
+
}
|
393
|
+
}
|
394
|
+
exports.MCPDocsServer = MCPDocsServer;
|
395
|
+
//# sourceMappingURL=mcpDocsServer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"mcpDocsServer.js","sourceRoot":"","sources":["../../src/core/mcpDocsServer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mDAA6C;AAC7C,qDAA+C;AAQ/C,MAAa,aAAa;IAIxB,YACE,UAAkB,QAAQ,EAC1B,UAGI,EAAE;QAEN,IAAI,CAAC,UAAU,GAAG,IAAI,0BAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACnD,IAAI,CAAC,WAAW,GAAG,IAAI,4BAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAEpD,0BAA0B;QAC1B,OAAO,CAAC,KAAK,CACX,8DAA8D,OAAO,EAAE,CACxE,CAAC;QACF,IAAI,OAAO,CAAC,iBAAiB,EAAE;YAC7B,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;SAChE;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAAC,GAAW;QAC5B,IAAI;YACF,6DAA6D;YAC7D,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YAEjD,kCAAkC;YAClC,QAAQ,OAAO,EAAE;gBACf,KAAK,YAAY;oBACf,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;gBACtC,KAAK,kBAAkB;oBACrB,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC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AO;YACL,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,QAAQ;SACf,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,cAAc;QAC1B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE,CAAC;QAE5D,OAAO;YACL,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,EAAE,KAAK,EAAE;SAChB,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,cAAc;QAC1B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC;QAEjE,OAAO;YACL,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,EAAE,WAAW,EAAE;SACtB,CAAC;IACJ,CAAC;CACF;AA/cD,sCA+cC"}
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
/**
|
2
|
+
* MCP Documentation Management Service
|
3
|
+
* Main entry point for the package
|
4
|
+
*/
|
5
|
+
export * from "./core/docManager.js";
|
6
|
+
export * from "./core/docProcessor.js";
|
7
|
+
export * from "./core/docAnalyzer.js";
|
8
|
+
export * from "./core/mcpDocsServer.js";
|
9
|
+
export * from "./types/index.js";
|
10
|
+
export * from "./utils/index.js";
|
11
|
+
import { MCPDocsServer } from "./core/mcpDocsServer.js";
|
12
|
+
/**
|
13
|
+
* MCP Query function that can be registered with Cursor's MCP system
|
14
|
+
* @param sql - The SQL-like query to execute
|
15
|
+
* @param options - Options for the MCP server
|
16
|
+
* @returns The query result
|
17
|
+
*/
|
18
|
+
export declare function query(sql: string, options?: {
|
19
|
+
docsDir?: string;
|
20
|
+
createIfNotExists?: boolean;
|
21
|
+
fileExtensions?: string[];
|
22
|
+
}): Promise<import("./types/index.js").MCPQueryResult>;
|
23
|
+
declare const mcpDocsServer: MCPDocsServer;
|
24
|
+
export default mcpDocsServer;
|
package/dist/index.js
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
"use strict";
|
2
|
+
/**
|
3
|
+
* MCP Documentation Management Service
|
4
|
+
* Main entry point for the package
|
5
|
+
*/
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
7
|
+
if (k2 === undefined) k2 = k;
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
11
|
+
}
|
12
|
+
Object.defineProperty(o, k2, desc);
|
13
|
+
}) : (function(o, m, k, k2) {
|
14
|
+
if (k2 === undefined) k2 = k;
|
15
|
+
o[k2] = m[k];
|
16
|
+
}));
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
19
|
+
};
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
21
|
+
exports.query = void 0;
|
22
|
+
// Export core functionality
|
23
|
+
__exportStar(require("./core/docManager.js"), exports);
|
24
|
+
__exportStar(require("./core/docProcessor.js"), exports);
|
25
|
+
__exportStar(require("./core/docAnalyzer.js"), exports);
|
26
|
+
__exportStar(require("./core/mcpDocsServer.js"), exports);
|
27
|
+
// Export types
|
28
|
+
__exportStar(require("./types/index.js"), exports);
|
29
|
+
// Export utility functions
|
30
|
+
__exportStar(require("./utils/index.js"), exports);
|
31
|
+
// Import core components
|
32
|
+
const mcpDocsServer_js_1 = require("./core/mcpDocsServer.js");
|
33
|
+
/**
|
34
|
+
* MCP Query function that can be registered with Cursor's MCP system
|
35
|
+
* @param sql - The SQL-like query to execute
|
36
|
+
* @param options - Options for the MCP server
|
37
|
+
* @returns The query result
|
38
|
+
*/
|
39
|
+
async function query(sql, options = {}) {
|
40
|
+
// Create a server instance with the specified options
|
41
|
+
const server = new mcpDocsServer_js_1.MCPDocsServer(options.docsDir || "./docs", {
|
42
|
+
createIfNotExists: options.createIfNotExists,
|
43
|
+
fileExtensions: options.fileExtensions,
|
44
|
+
});
|
45
|
+
// Execute the query
|
46
|
+
return await server.executeQuery(sql);
|
47
|
+
}
|
48
|
+
exports.query = query;
|
49
|
+
// Create and export singleton instance with default options
|
50
|
+
const mcpDocsServer = new mcpDocsServer_js_1.MCPDocsServer("./docs", { createIfNotExists: true });
|
51
|
+
exports.default = mcpDocsServer;
|
52
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;AAEH,4BAA4B;AAC5B,uDAAqC;AACrC,yDAAuC;AACvC,wDAAsC;AACtC,0DAAwC;AAExC,eAAe;AACf,mDAAiC;AAEjC,2BAA2B;AAC3B,mDAAiC;AAEjC,yBAAyB;AACzB,8DAAwD;AAExD;;;;;GAKG;AACI,KAAK,UAAU,KAAK,CACzB,GAAW,EACX,UAII,EAAE;IAEN,sDAAsD;IACtD,MAAM,MAAM,GAAG,IAAI,gCAAa,CAAC,OAAO,CAAC,OAAO,IAAI,QAAQ,EAAE;QAC5D,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;QAC5C,cAAc,EAAE,OAAO,CAAC,cAAc;KACvC,CAAC,CAAC;IAEH,oBAAoB;IACpB,OAAO,MAAM,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;AACxC,CAAC;AAhBD,sBAgBC;AAED,4DAA4D;AAC5D,MAAM,aAAa,GAAG,IAAI,gCAAa,CAAC,QAAQ,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;AAC/E,kBAAe,aAAa,CAAC"}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/**
|
2
|
+
* Types for the MCP Documentation Management Service
|
3
|
+
*/
|
4
|
+
export interface DocMetadata {
|
5
|
+
title: string;
|
6
|
+
description?: string;
|
7
|
+
tags?: string[];
|
8
|
+
lastUpdated?: string;
|
9
|
+
status?: "draft" | "review" | "published";
|
10
|
+
globs?: string[];
|
11
|
+
alwaysApply?: boolean;
|
12
|
+
}
|
13
|
+
export interface DocContent {
|
14
|
+
metadata: DocMetadata;
|
15
|
+
content: string;
|
16
|
+
path: string;
|
17
|
+
}
|
18
|
+
export interface SearchOptions {
|
19
|
+
query: string;
|
20
|
+
tags?: string[];
|
21
|
+
status?: "draft" | "review" | "published";
|
22
|
+
directory?: string;
|
23
|
+
}
|
24
|
+
export interface DocUpdateParams {
|
25
|
+
path: string;
|
26
|
+
content?: string;
|
27
|
+
metadata?: Partial<DocMetadata>;
|
28
|
+
}
|
29
|
+
export interface DocCreateParams {
|
30
|
+
path: string;
|
31
|
+
content: string;
|
32
|
+
metadata: DocMetadata;
|
33
|
+
}
|
34
|
+
export interface MCPQueryResult {
|
35
|
+
success: boolean;
|
36
|
+
data?: any;
|
37
|
+
error?: string;
|
38
|
+
}
|
39
|
+
export interface DocSummary {
|
40
|
+
title: string;
|
41
|
+
description?: string;
|
42
|
+
path: string;
|
43
|
+
lastUpdated?: string;
|
44
|
+
tags?: string[];
|
45
|
+
status?: "draft" | "review" | "published";
|
46
|
+
}
|
47
|
+
export interface DocAnalysisResult {
|
48
|
+
documentCount: number;
|
49
|
+
byStatus?: Record<string, number>;
|
50
|
+
byDirectory?: Record<string, number>;
|
51
|
+
recentlyUpdated?: DocSummary[];
|
52
|
+
missingDescriptions?: DocSummary[];
|
53
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
/**
|
2
|
+
* Utility functions for the MCP Documentation Service
|
3
|
+
*/
|
4
|
+
/**
|
5
|
+
* Check if a path is valid
|
6
|
+
* @param path - Path to check
|
7
|
+
* @returns True if the path is valid, false otherwise
|
8
|
+
*/
|
9
|
+
export declare function isValidPath(path: string): boolean;
|
10
|
+
/**
|
11
|
+
* Normalize a path
|
12
|
+
* @param path - Path to normalize
|
13
|
+
* @returns Normalized path
|
14
|
+
*/
|
15
|
+
export declare function normalizePath(path: string): string;
|
16
|
+
/**
|
17
|
+
* Get file extension
|
18
|
+
* @param path - Path to get extension from
|
19
|
+
* @returns File extension
|
20
|
+
*/
|
21
|
+
export declare function getFileExtension(path: string): string;
|
22
|
+
/**
|
23
|
+
* Get file name
|
24
|
+
* @param path - Path to get name from
|
25
|
+
* @returns File name
|
26
|
+
*/
|
27
|
+
export declare function getFileName(path: string): string;
|
28
|
+
/**
|
29
|
+
* Get directory name
|
30
|
+
* @param path - Path to get directory name from
|
31
|
+
* @returns Directory name
|
32
|
+
*/
|
33
|
+
export declare function getDirectoryName(path: string): string;
|
34
|
+
/**
|
35
|
+
* Join paths
|
36
|
+
* @param paths - Paths to join
|
37
|
+
* @returns Joined path
|
38
|
+
*/
|
39
|
+
export declare function joinPaths(...paths: string[]): string;
|
40
|
+
/**
|
41
|
+
* Escape regex special characters
|
42
|
+
* @param str - String to escape
|
43
|
+
* @returns Escaped string
|
44
|
+
*/
|
45
|
+
export declare function escapeRegex(str: string): string;
|
46
|
+
/**
|
47
|
+
* Calculate relevance score
|
48
|
+
* @param text - Text to search in
|
49
|
+
* @param query - Query to search for
|
50
|
+
* @returns Relevance score (0-1)
|
51
|
+
*/
|
52
|
+
export declare function calculateRelevance(text: string, query: string): number;
|
53
|
+
/**
|
54
|
+
* Generate excerpt
|
55
|
+
* @param text - Text to generate excerpt from
|
56
|
+
* @param query - Query to highlight
|
57
|
+
* @param length - Excerpt length
|
58
|
+
* @returns Excerpt
|
59
|
+
*/
|
60
|
+
export declare function generateExcerpt(text: string, query: string, length?: number): string;
|