mcp-docs-service 0.2.0 → 0.2.3
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/CHANGELOG.md +52 -0
- package/LICENSE +1 -1
- package/README.md +30 -57
- package/dist/cli/bin.d.ts +5 -3
- package/dist/cli/bin.js +41 -37
- package/dist/cli/bin.js.map +1 -1
- package/dist/handlers/docs.d.ts +26 -0
- package/dist/handlers/docs.js +513 -0
- package/dist/handlers/docs.js.map +1 -0
- package/dist/handlers/file.d.ts +32 -0
- package/dist/handlers/file.js +222 -0
- package/dist/handlers/file.js.map +1 -0
- package/dist/handlers/index.d.ts +1 -0
- package/dist/handlers/index.js +3 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/index.d.ts +2 -24
- package/dist/index.js +473 -49
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/index.js +3 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/tools.d.ts +164 -0
- package/dist/schemas/tools.js +53 -0
- package/dist/schemas/tools.js.map +1 -0
- package/dist/types/docs.d.ts +74 -0
- package/dist/types/docs.js +2 -0
- package/dist/types/docs.js.map +1 -0
- package/dist/types/file.d.ts +21 -0
- package/dist/types/file.js +2 -0
- package/dist/types/file.js.map +1 -0
- package/dist/types/index.d.ts +34 -43
- package/dist/types/index.js +3 -5
- package/dist/types/index.js.map +1 -1
- package/dist/types/tools.d.ts +11 -0
- package/dist/types/tools.js +2 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/utils/file.d.ts +24 -0
- package/dist/utils/file.js +94 -0
- package/dist/utils/file.js.map +1 -0
- package/dist/utils/index.d.ts +1 -60
- package/dist/utils/index.js +2 -151
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/path.d.ts +16 -0
- package/dist/utils/path.js +70 -0
- package/dist/utils/path.js.map +1 -0
- package/package.json +20 -8
- package/dist/cli/index.d.ts +0 -16
- package/dist/cli/index.js +0 -108
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/jsonrpc.d.ts +0 -29
- package/dist/cli/jsonrpc.js +0 -121
- package/dist/cli/jsonrpc.js.map +0 -1
- package/dist/core/docAnalyzer.d.ts +0 -25
- package/dist/core/docAnalyzer.js +0 -118
- package/dist/core/docAnalyzer.js.map +0 -1
- package/dist/core/docManager.d.ts +0 -48
- package/dist/core/docManager.js +0 -257
- package/dist/core/docManager.js.map +0 -1
- package/dist/core/docProcessor.d.ts +0 -20
- package/dist/core/docProcessor.js +0 -127
- package/dist/core/docProcessor.js.map +0 -1
- package/dist/core/mcpDocsServer.d.ts +0 -61
- package/dist/core/mcpDocsServer.js +0 -395
- package/dist/core/mcpDocsServer.js.map +0 -1
package/dist/core/docAnalyzer.js
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
/**
|
3
|
-
* Document Analyzer for generating insights about documentation
|
4
|
-
*/
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.DocAnalyzer = void 0;
|
7
|
-
class DocAnalyzer {
|
8
|
-
constructor(docManager) {
|
9
|
-
this.docManager = docManager;
|
10
|
-
}
|
11
|
-
/**
|
12
|
-
* Analyze the documentation and generate insights
|
13
|
-
*/
|
14
|
-
async analyzeDocumentation(directory) {
|
15
|
-
const summaries = await this.docManager.getAllDocumentSummaries(directory);
|
16
|
-
// Count documents by status
|
17
|
-
const byStatus = {};
|
18
|
-
summaries.forEach((doc) => {
|
19
|
-
const status = doc.status || "undefined";
|
20
|
-
byStatus[status] = (byStatus[status] || 0) + 1;
|
21
|
-
});
|
22
|
-
// Count documents by directory
|
23
|
-
const byDirectory = {};
|
24
|
-
summaries.forEach((doc) => {
|
25
|
-
const dirPath = doc.path.split("/").slice(0, -1).join("/");
|
26
|
-
byDirectory[dirPath] = (byDirectory[dirPath] || 0) + 1;
|
27
|
-
});
|
28
|
-
// Find documents missing descriptions
|
29
|
-
const missingDescriptions = summaries.filter((doc) => !doc.description);
|
30
|
-
// Find recently updated documents (if lastUpdated is available)
|
31
|
-
let recentlyUpdated = [];
|
32
|
-
const docsWithDates = summaries.filter((doc) => doc.lastUpdated);
|
33
|
-
if (docsWithDates.length > 0) {
|
34
|
-
recentlyUpdated = docsWithDates
|
35
|
-
.sort((a, b) => {
|
36
|
-
const dateA = a.lastUpdated ? new Date(a.lastUpdated).getTime() : 0;
|
37
|
-
const dateB = b.lastUpdated ? new Date(b.lastUpdated).getTime() : 0;
|
38
|
-
return dateB - dateA;
|
39
|
-
})
|
40
|
-
.slice(0, 5); // Get the 5 most recently updated
|
41
|
-
}
|
42
|
-
return {
|
43
|
-
documentCount: summaries.length,
|
44
|
-
byStatus,
|
45
|
-
byDirectory,
|
46
|
-
recentlyUpdated,
|
47
|
-
missingDescriptions,
|
48
|
-
};
|
49
|
-
}
|
50
|
-
/**
|
51
|
-
* Find documentation gaps (directories with few or no documents)
|
52
|
-
*/
|
53
|
-
async findDocumentationGaps() {
|
54
|
-
const directories = await this.docManager.listDirectories();
|
55
|
-
const gaps = {};
|
56
|
-
for (const dir of directories) {
|
57
|
-
const files = await this.docManager.listMarkdownFiles(dir);
|
58
|
-
if (files.length < 2) {
|
59
|
-
// Consider a directory with less than 2 docs as a gap
|
60
|
-
gaps[dir] = files.length;
|
61
|
-
}
|
62
|
-
}
|
63
|
-
return gaps;
|
64
|
-
}
|
65
|
-
/**
|
66
|
-
* Calculate overall documentation health score (0-100)
|
67
|
-
*/
|
68
|
-
async calculateHealthScore() {
|
69
|
-
const summaries = await this.docManager.getAllDocumentSummaries();
|
70
|
-
if (summaries.length === 0) {
|
71
|
-
return 0; // No documents
|
72
|
-
}
|
73
|
-
// Calculate metrics
|
74
|
-
const withDescription = summaries.filter((doc) => doc.description).length;
|
75
|
-
const withTags = summaries.filter((doc) => doc.tags && doc.tags.length > 0).length;
|
76
|
-
const withStatus = summaries.filter((doc) => doc.status).length;
|
77
|
-
// Calculate score components (each worth up to 33.3 points)
|
78
|
-
const descriptionScore = (withDescription / summaries.length) * 33.3;
|
79
|
-
const tagsScore = (withTags / summaries.length) * 33.3;
|
80
|
-
const statusScore = (withStatus / summaries.length) * 33.3;
|
81
|
-
// Calculate the overall score
|
82
|
-
const healthScore = descriptionScore + tagsScore + statusScore;
|
83
|
-
return Math.round(healthScore);
|
84
|
-
}
|
85
|
-
/**
|
86
|
-
* Generate suggestions for improving documentation
|
87
|
-
*/
|
88
|
-
async generateSuggestions() {
|
89
|
-
const analysis = await this.analyzeDocumentation();
|
90
|
-
const gaps = await this.findDocumentationGaps();
|
91
|
-
const healthScore = await this.calculateHealthScore();
|
92
|
-
const suggestions = [];
|
93
|
-
// Suggest adding descriptions to documents that lack them
|
94
|
-
if (analysis.missingDescriptions &&
|
95
|
-
analysis.missingDescriptions.length > 0) {
|
96
|
-
suggestions.push(`Add descriptions to ${analysis.missingDescriptions.length} documents that are missing them.`);
|
97
|
-
}
|
98
|
-
// Suggest creating documents in empty or sparse directories
|
99
|
-
if (Object.keys(gaps).length > 0) {
|
100
|
-
for (const [dir, count] of Object.entries(gaps)) {
|
101
|
-
suggestions.push(`Add more documentation to the ${dir} directory (currently has ${count} documents).`);
|
102
|
-
}
|
103
|
-
}
|
104
|
-
// General suggestions based on health score
|
105
|
-
if (healthScore < 50) {
|
106
|
-
suggestions.push("Improve overall documentation quality by adding proper metadata to existing documents.");
|
107
|
-
}
|
108
|
-
// Suggestion for adding status to documents
|
109
|
-
if (analysis.byStatus &&
|
110
|
-
analysis.byStatus["undefined"] &&
|
111
|
-
analysis.byStatus["undefined"] > 0) {
|
112
|
-
suggestions.push(`Add status (draft, review, or published) to ${analysis.byStatus["undefined"]} documents.`);
|
113
|
-
}
|
114
|
-
return suggestions;
|
115
|
-
}
|
116
|
-
}
|
117
|
-
exports.DocAnalyzer = DocAnalyzer;
|
118
|
-
//# sourceMappingURL=docAnalyzer.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"docAnalyzer.js","sourceRoot":"","sources":["../../src/core/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;QAEjC,0DAA0D;QAC1D,IACE,QAAQ,CAAC,mBAAmB;YAC5B,QAAQ,CAAC,mBAAmB,CAAC,MAAM,GAAG,CAAC,EACvC;YACA,WAAW,CAAC,IAAI,CACd,uBAAuB,QAAQ,CAAC,mBAAmB,CAAC,MAAM,mCAAmC,CAC9F,CAAC;SACH;QAED,4DAA4D;QAC5D,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAChC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBAC/C,WAAW,CAAC,IAAI,CACd,iCAAiC,GAAG,6BAA6B,KAAK,cAAc,CACrF,CAAC;aACH;SACF;QAED,4CAA4C;QAC5C,IAAI,WAAW,GAAG,EAAE,EAAE;YACpB,WAAW,CAAC,IAAI,CACd,wFAAwF,CACzF,CAAC;SACH;QAED,4CAA4C;QAC5C,IACE,QAAQ,CAAC,QAAQ;YACjB,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC;YAC9B,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,EAClC;YACA,WAAW,CAAC,IAAI,CACd,+CAA+C,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,aAAa,CAC3F,CAAC;SACH;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AApJD,kCAoJC"}
|
@@ -1,48 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Document Manager for handling file operations
|
3
|
-
*/
|
4
|
-
import { DocContent, DocCreateParams, DocSummary, DocUpdateParams, SearchOptions } from "../types/index.js";
|
5
|
-
export declare class DocManager {
|
6
|
-
private baseDir;
|
7
|
-
private options;
|
8
|
-
constructor(baseDir?: string, options?: {
|
9
|
-
createIfNotExists?: boolean;
|
10
|
-
fileExtensions?: string[];
|
11
|
-
});
|
12
|
-
/**
|
13
|
-
* Initialize the docs directory
|
14
|
-
*/
|
15
|
-
private initializeDirectory;
|
16
|
-
/**
|
17
|
-
* List all markdown files in a directory recursively
|
18
|
-
*/
|
19
|
-
listMarkdownFiles(dir?: string): Promise<string[]>;
|
20
|
-
/**
|
21
|
-
* Get document content and metadata
|
22
|
-
*/
|
23
|
-
getDocument(filePath: string): Promise<DocContent | null>;
|
24
|
-
/**
|
25
|
-
* List directories in the docs folder
|
26
|
-
*/
|
27
|
-
listDirectories(dir?: string): Promise<string[]>;
|
28
|
-
/**
|
29
|
-
* Create a new document
|
30
|
-
*/
|
31
|
-
createDocument(params: DocCreateParams): Promise<boolean>;
|
32
|
-
/**
|
33
|
-
* Update an existing document
|
34
|
-
*/
|
35
|
-
updateDocument(params: DocUpdateParams): Promise<boolean>;
|
36
|
-
/**
|
37
|
-
* Delete a document
|
38
|
-
*/
|
39
|
-
deleteDocument(filePath: string): Promise<boolean>;
|
40
|
-
/**
|
41
|
-
* Basic search for documents matching query
|
42
|
-
*/
|
43
|
-
searchDocuments(options: SearchOptions): Promise<DocSummary[]>;
|
44
|
-
/**
|
45
|
-
* Get all documents as summaries
|
46
|
-
*/
|
47
|
-
getAllDocumentSummaries(directory?: string): Promise<DocSummary[]>;
|
48
|
-
}
|
package/dist/core/docManager.js
DELETED
@@ -1,257 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
/**
|
3
|
-
* Document Manager for handling file operations
|
4
|
-
*/
|
5
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
6
|
-
if (k2 === undefined) k2 = k;
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
8
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
9
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
10
|
-
}
|
11
|
-
Object.defineProperty(o, k2, desc);
|
12
|
-
}) : (function(o, m, k, k2) {
|
13
|
-
if (k2 === undefined) k2 = k;
|
14
|
-
o[k2] = m[k];
|
15
|
-
}));
|
16
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
17
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
18
|
-
}) : function(o, v) {
|
19
|
-
o["default"] = v;
|
20
|
-
});
|
21
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
22
|
-
if (mod && mod.__esModule) return mod;
|
23
|
-
var result = {};
|
24
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
25
|
-
__setModuleDefault(result, mod);
|
26
|
-
return result;
|
27
|
-
};
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
exports.DocManager = void 0;
|
30
|
-
const fs = __importStar(require("fs"));
|
31
|
-
const fsPromises = __importStar(require("fs/promises"));
|
32
|
-
const path = __importStar(require("path"));
|
33
|
-
const docProcessor_js_1 = require("./docProcessor.js");
|
34
|
-
class DocManager {
|
35
|
-
constructor(baseDir = "./docs", options = {}) {
|
36
|
-
this.baseDir = baseDir;
|
37
|
-
this.options = {
|
38
|
-
createIfNotExists: options.createIfNotExists ?? false,
|
39
|
-
fileExtensions: options.fileExtensions ?? [".md", ".mdx"],
|
40
|
-
};
|
41
|
-
// Initialize directory if needed
|
42
|
-
this.initializeDirectory();
|
43
|
-
}
|
44
|
-
/**
|
45
|
-
* Initialize the docs directory
|
46
|
-
*/
|
47
|
-
initializeDirectory() {
|
48
|
-
try {
|
49
|
-
// Check if directory exists
|
50
|
-
fs.accessSync(this.baseDir);
|
51
|
-
console.error(`Using existing docs directory: ${this.baseDir}`);
|
52
|
-
}
|
53
|
-
catch (error) {
|
54
|
-
// Directory doesn't exist
|
55
|
-
if (this.options.createIfNotExists) {
|
56
|
-
try {
|
57
|
-
fs.mkdirSync(this.baseDir, { recursive: true });
|
58
|
-
console.error(`Created docs directory: ${this.baseDir}`);
|
59
|
-
// Create a sample README.md file in the new directory
|
60
|
-
const readmePath = path.join(this.baseDir, "README.md");
|
61
|
-
const readmeContent = `# Documentation\n\nThis directory was created by the MCP Documentation Service.\n`;
|
62
|
-
fs.writeFileSync(readmePath, readmeContent, "utf-8");
|
63
|
-
console.error(`Created sample README.md in ${this.baseDir}`);
|
64
|
-
}
|
65
|
-
catch (createError) {
|
66
|
-
console.error(`Failed to create docs directory: ${createError}`);
|
67
|
-
}
|
68
|
-
}
|
69
|
-
else {
|
70
|
-
console.error(`Docs directory doesn't exist: ${this.baseDir}`);
|
71
|
-
console.error("Use --create-dir option to create it automatically");
|
72
|
-
}
|
73
|
-
}
|
74
|
-
}
|
75
|
-
/**
|
76
|
-
* List all markdown files in a directory recursively
|
77
|
-
*/
|
78
|
-
async listMarkdownFiles(dir = "") {
|
79
|
-
const fullDir = path.join(this.baseDir, dir);
|
80
|
-
const files = [];
|
81
|
-
try {
|
82
|
-
const entries = await fsPromises.readdir(fullDir, {
|
83
|
-
withFileTypes: true,
|
84
|
-
});
|
85
|
-
for (const entry of entries) {
|
86
|
-
const entryPath = path.join(dir, entry.name).replace(/^\//, "");
|
87
|
-
if (entry.isDirectory()) {
|
88
|
-
const subDirFiles = await this.listMarkdownFiles(entryPath);
|
89
|
-
files.push(...subDirFiles);
|
90
|
-
}
|
91
|
-
else if (entry.isFile() && entry.name.endsWith(".md")) {
|
92
|
-
files.push(entryPath);
|
93
|
-
}
|
94
|
-
}
|
95
|
-
}
|
96
|
-
catch (error) {
|
97
|
-
console.error(`Error listing files in ${fullDir}:`, error);
|
98
|
-
}
|
99
|
-
return files;
|
100
|
-
}
|
101
|
-
/**
|
102
|
-
* Get document content and metadata
|
103
|
-
*/
|
104
|
-
async getDocument(filePath) {
|
105
|
-
try {
|
106
|
-
const fullPath = path.join(this.baseDir, filePath);
|
107
|
-
const content = await fsPromises.readFile(fullPath, "utf-8");
|
108
|
-
return (0, docProcessor_js_1.parseMarkdownWithFrontMatter)(filePath, content);
|
109
|
-
}
|
110
|
-
catch (error) {
|
111
|
-
console.error(`Error reading document ${filePath}:`, error);
|
112
|
-
return null;
|
113
|
-
}
|
114
|
-
}
|
115
|
-
/**
|
116
|
-
* List directories in the docs folder
|
117
|
-
*/
|
118
|
-
async listDirectories(dir = "") {
|
119
|
-
const fullDir = path.join(this.baseDir, dir);
|
120
|
-
const directories = [];
|
121
|
-
try {
|
122
|
-
const entries = await fsPromises.readdir(fullDir, {
|
123
|
-
withFileTypes: true,
|
124
|
-
});
|
125
|
-
for (const entry of entries) {
|
126
|
-
if (entry.isDirectory()) {
|
127
|
-
const dirPath = path.join(dir, entry.name).replace(/^\//, "");
|
128
|
-
directories.push(dirPath);
|
129
|
-
}
|
130
|
-
}
|
131
|
-
}
|
132
|
-
catch (error) {
|
133
|
-
console.error(`Error listing directories in ${fullDir}:`, error);
|
134
|
-
}
|
135
|
-
return directories;
|
136
|
-
}
|
137
|
-
/**
|
138
|
-
* Create a new document
|
139
|
-
*/
|
140
|
-
async createDocument(params) {
|
141
|
-
try {
|
142
|
-
// Ensure the path is valid
|
143
|
-
if (!params.path.endsWith(".md")) {
|
144
|
-
params.path = `${params.path}.md`;
|
145
|
-
}
|
146
|
-
// Build the full file content with front matter
|
147
|
-
const fileContent = (0, docProcessor_js_1.combineMetadataAndContent)(params.metadata, params.content);
|
148
|
-
// Ensure directory exists
|
149
|
-
const fullPath = path.join(this.baseDir, params.path);
|
150
|
-
const dirPath = path.dirname(fullPath);
|
151
|
-
await fsPromises.mkdir(dirPath, { recursive: true });
|
152
|
-
// Write the file
|
153
|
-
await fsPromises.writeFile(fullPath, fileContent, "utf-8");
|
154
|
-
return true;
|
155
|
-
}
|
156
|
-
catch (error) {
|
157
|
-
console.error(`Error creating document ${params.path}:`, error);
|
158
|
-
return false;
|
159
|
-
}
|
160
|
-
}
|
161
|
-
/**
|
162
|
-
* Update an existing document
|
163
|
-
*/
|
164
|
-
async updateDocument(params) {
|
165
|
-
try {
|
166
|
-
// Get the existing document
|
167
|
-
const doc = await this.getDocument(params.path);
|
168
|
-
if (!doc) {
|
169
|
-
return false;
|
170
|
-
}
|
171
|
-
// Update metadata and content as needed
|
172
|
-
const updatedMetadata = { ...doc.metadata, ...(params.metadata || {}) };
|
173
|
-
const updatedContent = params.content !== undefined ? params.content : doc.content;
|
174
|
-
// Build the full file content with front matter
|
175
|
-
const fileContent = (0, docProcessor_js_1.combineMetadataAndContent)(updatedMetadata, updatedContent);
|
176
|
-
// Write the file
|
177
|
-
const fullPath = path.join(this.baseDir, params.path);
|
178
|
-
await fsPromises.writeFile(fullPath, fileContent, "utf-8");
|
179
|
-
return true;
|
180
|
-
}
|
181
|
-
catch (error) {
|
182
|
-
console.error(`Error updating document ${params.path}:`, error);
|
183
|
-
return false;
|
184
|
-
}
|
185
|
-
}
|
186
|
-
/**
|
187
|
-
* Delete a document
|
188
|
-
*/
|
189
|
-
async deleteDocument(filePath) {
|
190
|
-
try {
|
191
|
-
const fullPath = path.join(this.baseDir, filePath);
|
192
|
-
await fsPromises.unlink(fullPath);
|
193
|
-
return true;
|
194
|
-
}
|
195
|
-
catch (error) {
|
196
|
-
console.error(`Error deleting document ${filePath}:`, error);
|
197
|
-
return false;
|
198
|
-
}
|
199
|
-
}
|
200
|
-
/**
|
201
|
-
* Basic search for documents matching query
|
202
|
-
*/
|
203
|
-
async searchDocuments(options) {
|
204
|
-
const { query, tags, status, directory } = options;
|
205
|
-
const results = [];
|
206
|
-
// Get all markdown files in the specified directory or all if not specified
|
207
|
-
const files = await this.listMarkdownFiles(directory || "");
|
208
|
-
// Filter and search through files
|
209
|
-
for (const filePath of files) {
|
210
|
-
const doc = await this.getDocument(filePath);
|
211
|
-
if (!doc)
|
212
|
-
continue;
|
213
|
-
// Check if document matches search criteria
|
214
|
-
const searchableText = `${doc.metadata.title} ${doc.metadata.description || ""} ${doc.content}`.toLowerCase();
|
215
|
-
const matchesQuery = !query || searchableText.includes(query.toLowerCase());
|
216
|
-
const matchesTags = !tags ||
|
217
|
-
!tags.length ||
|
218
|
-
(doc.metadata.tags &&
|
219
|
-
tags.some((tag) => doc.metadata.tags?.includes(tag)));
|
220
|
-
const matchesStatus = !status || doc.metadata.status === status;
|
221
|
-
if (matchesQuery && matchesTags && matchesStatus) {
|
222
|
-
results.push({
|
223
|
-
title: doc.metadata.title,
|
224
|
-
description: doc.metadata.description,
|
225
|
-
path: doc.path,
|
226
|
-
lastUpdated: doc.metadata.lastUpdated,
|
227
|
-
tags: doc.metadata.tags,
|
228
|
-
status: doc.metadata.status,
|
229
|
-
});
|
230
|
-
}
|
231
|
-
}
|
232
|
-
return results;
|
233
|
-
}
|
234
|
-
/**
|
235
|
-
* Get all documents as summaries
|
236
|
-
*/
|
237
|
-
async getAllDocumentSummaries(directory) {
|
238
|
-
const files = await this.listMarkdownFiles(directory || "");
|
239
|
-
const summaries = [];
|
240
|
-
for (const filePath of files) {
|
241
|
-
const doc = await this.getDocument(filePath);
|
242
|
-
if (!doc)
|
243
|
-
continue;
|
244
|
-
summaries.push({
|
245
|
-
title: doc.metadata.title,
|
246
|
-
description: doc.metadata.description,
|
247
|
-
path: doc.path,
|
248
|
-
lastUpdated: doc.metadata.lastUpdated,
|
249
|
-
tags: doc.metadata.tags,
|
250
|
-
status: doc.metadata.status,
|
251
|
-
});
|
252
|
-
}
|
253
|
-
return summaries;
|
254
|
-
}
|
255
|
-
}
|
256
|
-
exports.DocManager = DocManager;
|
257
|
-
//# sourceMappingURL=docManager.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"docManager.js","sourceRoot":"","sources":["../../src/core/docManager.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,wDAA0C;AAC1C,2CAA6B;AAU7B,uDAG2B;AAE3B,MAAa,UAAU;IAOrB,YACE,UAAkB,QAAQ,EAC1B,UAGI,EAAE;QAEN,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG;YACb,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,IAAI,KA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AAS;YAEnB,SAAS,CAAC,IAAI,CAAC;gBACb,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,KAAK;gBACzB,WAAW,EAAE,GAAG,CAAC,QAAQ,CAAC,WAAW;gBACrC,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,WAAW,EAAE,GAAG,CAAC,QAAQ,CAAC,WAAW;gBACrC,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI;gBACvB,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,MAAM;aAC5B,CAAC,CAAC;SACJ;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA3QD,gCA2QC"}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Document processor for handling markdown files with front matter
|
3
|
-
*/
|
4
|
-
import { DocContent, DocMetadata } from "../types/index.js";
|
5
|
-
/**
|
6
|
-
* Parses front matter and content from a markdown file
|
7
|
-
* Front matter format is YAML between triple dashes:
|
8
|
-
* ---
|
9
|
-
* key: value
|
10
|
-
* ---
|
11
|
-
*/
|
12
|
-
export declare function parseMarkdownWithFrontMatter(filePath: string, content: string): DocContent;
|
13
|
-
/**
|
14
|
-
* Creates front matter text from metadata
|
15
|
-
*/
|
16
|
-
export declare function createFrontMatter(metadata: DocMetadata): string;
|
17
|
-
/**
|
18
|
-
* Combines metadata and content into a full document
|
19
|
-
*/
|
20
|
-
export declare function combineMetadataAndContent(metadata: DocMetadata, content: string): string;
|
@@ -1,127 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
/**
|
3
|
-
* Document processor for handling markdown files with front matter
|
4
|
-
*/
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.combineMetadataAndContent = exports.createFrontMatter = exports.parseMarkdownWithFrontMatter = void 0;
|
7
|
-
/**
|
8
|
-
* Parses front matter and content from a markdown file
|
9
|
-
* Front matter format is YAML between triple dashes:
|
10
|
-
* ---
|
11
|
-
* key: value
|
12
|
-
* ---
|
13
|
-
*/
|
14
|
-
function parseMarkdownWithFrontMatter(filePath, content) {
|
15
|
-
const metadata = {
|
16
|
-
title: extractTitleFromContent(content) || extractTitleFromPath(filePath),
|
17
|
-
};
|
18
|
-
// Check if the content has front matter
|
19
|
-
const frontMatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n/;
|
20
|
-
const match = content.match(frontMatterRegex);
|
21
|
-
if (match) {
|
22
|
-
const frontMatterText = match[1];
|
23
|
-
const frontMatterLines = frontMatterText.split("\n");
|
24
|
-
// Parse front matter lines
|
25
|
-
for (const line of frontMatterLines) {
|
26
|
-
const lineTrimmed = line.trim();
|
27
|
-
if (!lineTrimmed || lineTrimmed.startsWith("#"))
|
28
|
-
continue;
|
29
|
-
const colonIndex = lineTrimmed.indexOf(":");
|
30
|
-
if (colonIndex > 0) {
|
31
|
-
const key = lineTrimmed.slice(0, colonIndex).trim();
|
32
|
-
const value = lineTrimmed.slice(colonIndex + 1).trim();
|
33
|
-
// Handle special front matter keys safely
|
34
|
-
if (key === "globs" || key === "tags") {
|
35
|
-
try {
|
36
|
-
// If it's a YAML array, parse it
|
37
|
-
if (value.startsWith("[") && value.endsWith("]")) {
|
38
|
-
const arrayItems = value
|
39
|
-
.slice(1, -1)
|
40
|
-
.split(",")
|
41
|
-
.map((item) => item.trim().replace(/^['"]|['"]$/g, ""));
|
42
|
-
metadata[key] = arrayItems;
|
43
|
-
}
|
44
|
-
else {
|
45
|
-
metadata[key] = [value];
|
46
|
-
}
|
47
|
-
}
|
48
|
-
catch (e) {
|
49
|
-
console.error(`Error parsing ${key} in ${filePath}:`, e);
|
50
|
-
}
|
51
|
-
}
|
52
|
-
else if (key === "alwaysApply") {
|
53
|
-
metadata.alwaysApply = value.toLowerCase() === "true";
|
54
|
-
}
|
55
|
-
else {
|
56
|
-
metadata[key] = value;
|
57
|
-
}
|
58
|
-
}
|
59
|
-
}
|
60
|
-
// Remove front matter from content
|
61
|
-
content = content.replace(frontMatterRegex, "");
|
62
|
-
}
|
63
|
-
return {
|
64
|
-
metadata,
|
65
|
-
content,
|
66
|
-
path: filePath,
|
67
|
-
};
|
68
|
-
}
|
69
|
-
exports.parseMarkdownWithFrontMatter = parseMarkdownWithFrontMatter;
|
70
|
-
/**
|
71
|
-
* Creates front matter text from metadata
|
72
|
-
*/
|
73
|
-
function createFrontMatter(metadata) {
|
74
|
-
const lines = ["---"];
|
75
|
-
// Add each metadata field
|
76
|
-
for (const [key, value] of Object.entries(metadata)) {
|
77
|
-
if (value === undefined)
|
78
|
-
continue;
|
79
|
-
if (Array.isArray(value)) {
|
80
|
-
// Use simple format for compatibility
|
81
|
-
lines.push(`${key}:`);
|
82
|
-
for (const item of value) {
|
83
|
-
lines.push(` - ${item}`);
|
84
|
-
}
|
85
|
-
}
|
86
|
-
else if (typeof value === "boolean") {
|
87
|
-
lines.push(`${key}: ${value}`);
|
88
|
-
}
|
89
|
-
else {
|
90
|
-
lines.push(`${key}: ${value}`);
|
91
|
-
}
|
92
|
-
}
|
93
|
-
lines.push("---");
|
94
|
-
lines.push("");
|
95
|
-
return lines.join("\n");
|
96
|
-
}
|
97
|
-
exports.createFrontMatter = createFrontMatter;
|
98
|
-
/**
|
99
|
-
* Extracts title from content (first h1)
|
100
|
-
*/
|
101
|
-
function extractTitleFromContent(content) {
|
102
|
-
const h1Match = content.match(/^#\s+(.+)$/m);
|
103
|
-
if (h1Match) {
|
104
|
-
return h1Match[1].trim();
|
105
|
-
}
|
106
|
-
return null;
|
107
|
-
}
|
108
|
-
/**
|
109
|
-
* Extracts title from file path
|
110
|
-
*/
|
111
|
-
function extractTitleFromPath(filePath) {
|
112
|
-
const baseName = filePath.split("/").pop() || "";
|
113
|
-
const withoutExtension = baseName.replace(/\.md$/, "");
|
114
|
-
return withoutExtension
|
115
|
-
.split("-")
|
116
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
117
|
-
.join(" ");
|
118
|
-
}
|
119
|
-
/**
|
120
|
-
* Combines metadata and content into a full document
|
121
|
-
*/
|
122
|
-
function combineMetadataAndContent(metadata, content) {
|
123
|
-
const frontMatter = createFrontMatter(metadata);
|
124
|
-
return `${frontMatter}${content}`;
|
125
|
-
}
|
126
|
-
exports.combineMetadataAndContent = combineMetadataAndContent;
|
127
|
-
//# sourceMappingURL=docProcessor.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"docProcessor.js","sourceRoot":"","sources":["../../src/core/docProcessor.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAIH;;;;;;GAMG;AACH,SAAgB,4BAA4B,CAC1C,QAAgB,EAChB,OAAe;IAEf,MAAM,QAAQ,GAAgB;QAC5B,KAAK,EAAE,uBAAuB,CAAC,OAAO,CAAC,IAAI,oBAAoB,CAAC,QAAQ,CAAC;KAC1E,CAAC;IAEF,wCAAwC;IACxC,MAAM,gBAAgB,GAAG,+BAA+B,CAAC;IACzD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAE9C,IAAI,KAAK,EAAE;QACT,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,gBAAgB,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAErD,2BAA2B;QAC3B,KAAK,MAAM,IAAI,IAAI,gBAAgB,EAAE;YACnC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAChC,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC;gBAAE,SAAS;YAE1D,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC5C,IAAI,UAAU,GAAG,CAAC,EAAE;gBAClB,MAAM,GAAG,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;gBACpD,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC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OAAO,gBAAgB;SACpB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SAC3D,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED;;GAEG;AACH,SAAgB,yBAAyB,CACvC,QAAqB,EACrB,OAAe;IAEf,MAAM,WAAW,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAChD,OAAO,GAAG,WAAW,GAAG,OAAO,EAAE,CAAC;AACpC,CAAC;AAND,8DAMC"}
|
@@ -1,61 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* MCP Documentation Management Server
|
3
|
-
* This server implements the Model Context Protocol for managing documentation
|
4
|
-
*/
|
5
|
-
import { MCPQueryResult } from "../types/index.js";
|
6
|
-
export declare class MCPDocsServer {
|
7
|
-
private docManager;
|
8
|
-
private docAnalyzer;
|
9
|
-
constructor(docsDir?: string, options?: {
|
10
|
-
createIfNotExists?: boolean;
|
11
|
-
fileExtensions?: string[];
|
12
|
-
});
|
13
|
-
/**
|
14
|
-
* Execute a query using the MCP protocol
|
15
|
-
*/
|
16
|
-
executeQuery(sql: string): Promise<MCPQueryResult>;
|
17
|
-
/**
|
18
|
-
* Parse a query string into command and parameters
|
19
|
-
*/
|
20
|
-
private parseQuery;
|
21
|
-
/**
|
22
|
-
* List all markdown files
|
23
|
-
*/
|
24
|
-
private listFiles;
|
25
|
-
/**
|
26
|
-
* List all directories
|
27
|
-
*/
|
28
|
-
private listDirectories;
|
29
|
-
/**
|
30
|
-
* Get a document by path
|
31
|
-
*/
|
32
|
-
private getDocument;
|
33
|
-
/**
|
34
|
-
* Search for documents
|
35
|
-
*/
|
36
|
-
private searchDocuments;
|
37
|
-
/**
|
38
|
-
* Create a new document
|
39
|
-
*/
|
40
|
-
private createDocument;
|
41
|
-
/**
|
42
|
-
* Update an existing document
|
43
|
-
*/
|
44
|
-
private updateDocument;
|
45
|
-
/**
|
46
|
-
* Delete a document
|
47
|
-
*/
|
48
|
-
private deleteDocument;
|
49
|
-
/**
|
50
|
-
* Analyze documentation
|
51
|
-
*/
|
52
|
-
private analyzeDocumentation;
|
53
|
-
/**
|
54
|
-
* Get documentation health score
|
55
|
-
*/
|
56
|
-
private getHealthScore;
|
57
|
-
/**
|
58
|
-
* Get suggestions for improving documentation
|
59
|
-
*/
|
60
|
-
private getSuggestions;
|
61
|
-
}
|