mcp-docs-service 0.2.0 → 0.2.1
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 +43 -0
- package/LICENSE +1 -1
- package/README.md +29 -57
- package/dist/handlers/docs.d.ts +17 -0
- package/dist/handlers/docs.js +280 -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 +431 -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 +141 -0
- package/dist/schemas/tools.js +46 -0
- package/dist/schemas/tools.js.map +1 -0
- package/dist/types/docs.d.ts +49 -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 +39 -0
- package/dist/utils/path.js.map +1 -0
- package/package.json +20 -8
- package/dist/cli/bin.d.ts +0 -6
- package/dist/cli/bin.js +0 -49
- package/dist/cli/bin.js.map +0 -1
- 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
@@ -0,0 +1,39 @@
|
|
1
|
+
import path from "path";
|
2
|
+
import os from "os";
|
3
|
+
/**
|
4
|
+
* Normalizes a path consistently
|
5
|
+
*/
|
6
|
+
export function normalizePath(p) {
|
7
|
+
return path.normalize(p);
|
8
|
+
}
|
9
|
+
/**
|
10
|
+
* Expands the home directory tilde (~) in a path
|
11
|
+
*/
|
12
|
+
export function expandHome(filepath) {
|
13
|
+
if (filepath.startsWith("~/") || filepath === "~") {
|
14
|
+
return path.join(os.homedir(), filepath.slice(1));
|
15
|
+
}
|
16
|
+
return filepath;
|
17
|
+
}
|
18
|
+
/**
|
19
|
+
* Validates that a path is within allowed directories
|
20
|
+
* @param p The path to validate
|
21
|
+
* @param allowedDirectories Array of allowed directory paths
|
22
|
+
* @returns The normalized path if valid
|
23
|
+
* @throws Error if path is not within allowed directories
|
24
|
+
*/
|
25
|
+
export async function validatePath(p, allowedDirectories) {
|
26
|
+
const normalizedPath = normalizePath(path.resolve(expandHome(p)));
|
27
|
+
// Check if the path is within any of the allowed directories
|
28
|
+
const isAllowed = allowedDirectories.some((dir) => {
|
29
|
+
const relativePath = path.relative(dir, normalizedPath);
|
30
|
+
return (relativePath !== "" &&
|
31
|
+
!relativePath.startsWith("..") &&
|
32
|
+
!path.isAbsolute(relativePath));
|
33
|
+
});
|
34
|
+
if (!isAllowed) {
|
35
|
+
throw new Error(`Access denied: ${p} is not within allowed directories`);
|
36
|
+
}
|
37
|
+
return normalizedPath;
|
38
|
+
}
|
39
|
+
//# sourceMappingURL=path.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../src/utils/path.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AAGpB;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,CAAS;IACrC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,QAAQ,KAAK,GAAG,EAAE,CAAC;QAClD,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,CAAS,EACT,kBAA4B;IAE5B,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAElE,6DAA6D;IAC7D,MAAM,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;QAChD,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QACxD,OAAO,CACL,YAAY,KAAK,EAAE;YACnB,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC;YAC9B,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,CAC/B,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,oCAAoC,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
package/package.json
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
{
|
2
2
|
"name": "mcp-docs-service",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.1",
|
4
4
|
"description": "MCP Documentation Management Service - A Model Context Protocol implementation for documentation management",
|
5
|
+
"type": "module",
|
5
6
|
"main": "dist/index.js",
|
6
7
|
"types": "dist/index.d.ts",
|
7
8
|
"bin": {
|
@@ -9,9 +10,11 @@
|
|
9
10
|
},
|
10
11
|
"scripts": {
|
11
12
|
"build": "tsc",
|
12
|
-
"
|
13
|
+
"prepare": "npm run build",
|
14
|
+
"watch": "tsc --watch",
|
13
15
|
"test": "echo \"No tests yet\" && exit 0",
|
14
|
-
"start": "node dist/cli/bin.js"
|
16
|
+
"start": "node dist/cli/bin.js",
|
17
|
+
"prepare-publish": "node scripts/prepare-publish.js"
|
15
18
|
},
|
16
19
|
"keywords": [
|
17
20
|
"mcp",
|
@@ -19,23 +22,32 @@
|
|
19
22
|
"cursor",
|
20
23
|
"claude",
|
21
24
|
"markdown",
|
22
|
-
"model-context-protocol"
|
25
|
+
"model-context-protocol",
|
26
|
+
"knowledge-base",
|
27
|
+
"documentation-management",
|
28
|
+
"llm-context"
|
23
29
|
],
|
24
30
|
"author": "Aleks Petrov",
|
25
31
|
"license": "MIT",
|
26
32
|
"dependencies": {
|
27
|
-
"@modelcontextprotocol/sdk": "^
|
28
|
-
"
|
29
|
-
"
|
33
|
+
"@modelcontextprotocol/sdk": "^0.5.0",
|
34
|
+
"diff": "^7.0.0",
|
35
|
+
"glob": "^11.0.1",
|
36
|
+
"js-yaml": "^4.1.0",
|
37
|
+
"minimatch": "^10.0.1",
|
38
|
+
"zod-to-json-schema": "^3.23.5"
|
30
39
|
},
|
31
40
|
"devDependencies": {
|
41
|
+
"@types/diff": "^7.0.1",
|
32
42
|
"@types/js-yaml": "^4.0.5",
|
33
43
|
"@types/node": "^18.0.0",
|
34
|
-
"
|
44
|
+
"shx": "^0.3.4",
|
45
|
+
"typescript": "^5.3.3"
|
35
46
|
},
|
36
47
|
"files": [
|
37
48
|
"dist",
|
38
49
|
"README.md",
|
50
|
+
"CHANGELOG.md",
|
39
51
|
"LICENSE"
|
40
52
|
],
|
41
53
|
"engines": {
|
package/dist/cli/bin.d.ts
DELETED
package/dist/cli/bin.js
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
"use strict";
|
3
|
-
/**
|
4
|
-
* MCP Documentation Management Service CLI
|
5
|
-
* This is the entry point for the CLI when run via npx
|
6
|
-
*/
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
8
|
-
const index_js_1 = require("./index.js");
|
9
|
-
// Parse command line arguments
|
10
|
-
const args = process.argv.slice(2);
|
11
|
-
const options = {
|
12
|
-
docsDir: "./docs",
|
13
|
-
createIfNotExists: false,
|
14
|
-
help: false,
|
15
|
-
};
|
16
|
-
// Process arguments
|
17
|
-
for (let i = 0; i < args.length; i++) {
|
18
|
-
const arg = args[i];
|
19
|
-
if (arg === "--docs-dir" && i + 1 < args.length) {
|
20
|
-
options.docsDir = args[++i];
|
21
|
-
}
|
22
|
-
else if (arg === "--create-dir") {
|
23
|
-
options.createIfNotExists = true;
|
24
|
-
}
|
25
|
-
else if (arg === "--help" || arg === "-h") {
|
26
|
-
options.help = true;
|
27
|
-
}
|
28
|
-
}
|
29
|
-
// Show help if requested
|
30
|
-
if (options.help) {
|
31
|
-
console.log(`
|
32
|
-
MCP Documentation Service
|
33
|
-
|
34
|
-
Usage:
|
35
|
-
npx mcp-docs-service [options]
|
36
|
-
|
37
|
-
Options:
|
38
|
-
--docs-dir <path> Specify the docs directory (default: ./docs)
|
39
|
-
--create-dir Create the docs directory if it doesn't exist
|
40
|
-
--help, -h Show this help message
|
41
|
-
`);
|
42
|
-
process.exit(0);
|
43
|
-
}
|
44
|
-
// Start the main process
|
45
|
-
(0, index_js_1.main)(options).catch((error) => {
|
46
|
-
console.error("Fatal error:", error);
|
47
|
-
process.exit(1);
|
48
|
-
});
|
49
|
-
//# sourceMappingURL=bin.js.map
|
package/dist/cli/bin.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/cli/bin.ts"],"names":[],"mappings":";;AAEA;;;GAGG;;AAEH,yCAAkC;AAElC,+BAA+B;AAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,QAAQ;IACjB,iBAAiB,EAAE,KAAK;IACxB,IAAI,EAAE,KAAK;CACZ,CAAC;AAEF,oBAAoB;AACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;IACpC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAEpB,IAAI,GAAG,KAAK,YAAY,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE;QAC/C,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;KAC7B;SAAM,IAAI,GAAG,KAAK,cAAc,EAAE;QACjC,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;KAClC;SAAM,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE;QAC3C,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;KACrB;CACF;AAED,yBAAyB;AACzB,IAAI,OAAO,CAAC,IAAI,EAAE;IAChB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;GAUX,CAAC,CAAC;IACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CACjB;AAED,yBAAyB;AACzB,IAAA,eAAI,EAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC5B,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/cli/index.d.ts
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* CLI interface for the MCP Documentation Management Service
|
3
|
-
*
|
4
|
-
* This script is meant to be run from the command line to start the MCP server.
|
5
|
-
* It reads queries from stdin, processes them, and writes results to stdout.
|
6
|
-
*
|
7
|
-
* Usage:
|
8
|
-
* npx mcp-docs-service [options]
|
9
|
-
*/
|
10
|
-
/**
|
11
|
-
* Main function to process stdin commands
|
12
|
-
*/
|
13
|
-
export declare function main(options?: {
|
14
|
-
docsDir: string;
|
15
|
-
createIfNotExists: boolean;
|
16
|
-
}): Promise<void>;
|
package/dist/cli/index.js
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
/**
|
3
|
-
* CLI interface for the MCP Documentation Management Service
|
4
|
-
*
|
5
|
-
* This script is meant to be run from the command line to start the MCP server.
|
6
|
-
* It reads queries from stdin, processes them, and writes results to stdout.
|
7
|
-
*
|
8
|
-
* Usage:
|
9
|
-
* npx mcp-docs-service [options]
|
10
|
-
*/
|
11
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
12
|
-
if (k2 === undefined) k2 = k;
|
13
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
14
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
15
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
16
|
-
}
|
17
|
-
Object.defineProperty(o, k2, desc);
|
18
|
-
}) : (function(o, m, k, k2) {
|
19
|
-
if (k2 === undefined) k2 = k;
|
20
|
-
o[k2] = m[k];
|
21
|
-
}));
|
22
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
23
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
24
|
-
}) : function(o, v) {
|
25
|
-
o["default"] = v;
|
26
|
-
});
|
27
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
28
|
-
if (mod && mod.__esModule) return mod;
|
29
|
-
var result = {};
|
30
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
31
|
-
__setModuleDefault(result, mod);
|
32
|
-
return result;
|
33
|
-
};
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
35
|
-
exports.main = void 0;
|
36
|
-
const index_js_1 = require("../index.js");
|
37
|
-
const readline = __importStar(require("readline"));
|
38
|
-
const jsonrpc_js_1 = require("./jsonrpc.js");
|
39
|
-
/**
|
40
|
-
* Main function to process stdin commands
|
41
|
-
*/
|
42
|
-
async function main(options = {
|
43
|
-
docsDir: "./docs",
|
44
|
-
createIfNotExists: false,
|
45
|
-
}) {
|
46
|
-
console.error("MCP Documentation Management Service started.");
|
47
|
-
console.error(`Using docs directory: ${options.docsDir}`);
|
48
|
-
if (options.createIfNotExists) {
|
49
|
-
console.error("Will create directory if it doesn't exist");
|
50
|
-
}
|
51
|
-
console.error("Reading from stdin, writing results to stdout...");
|
52
|
-
// Create a custom query function that uses the specified docs directory
|
53
|
-
const query = (sql) => (0, index_js_1.query)(sql, {
|
54
|
-
docsDir: options.docsDir,
|
55
|
-
createIfNotExists: options.createIfNotExists,
|
56
|
-
});
|
57
|
-
// Create readline interface
|
58
|
-
const rl = readline.createInterface({
|
59
|
-
input: process.stdin,
|
60
|
-
output: process.stdout,
|
61
|
-
terminal: false,
|
62
|
-
});
|
63
|
-
// Handle process termination
|
64
|
-
process.on("SIGINT", () => {
|
65
|
-
console.error("\nMCP Documentation Management Service terminated.");
|
66
|
-
process.exit(0);
|
67
|
-
});
|
68
|
-
// Process lines from stdin
|
69
|
-
rl.on("line", async (line) => {
|
70
|
-
if (line.trim()) {
|
71
|
-
try {
|
72
|
-
// Check if the input is a JSON-RPC 2.0 request
|
73
|
-
if (line.trim().startsWith("{") && line.includes('"jsonrpc"')) {
|
74
|
-
// Process as JSON-RPC 2.0 request
|
75
|
-
const response = await (0, jsonrpc_js_1.processJsonRpcRequest)(line.trim(), {
|
76
|
-
docsDir: options.docsDir,
|
77
|
-
createIfNotExists: options.createIfNotExists,
|
78
|
-
});
|
79
|
-
console.log(JSON.stringify(response));
|
80
|
-
}
|
81
|
-
else {
|
82
|
-
// Process as SQL-like query (legacy mode)
|
83
|
-
const result = await query(line.trim());
|
84
|
-
console.log(JSON.stringify(result));
|
85
|
-
}
|
86
|
-
}
|
87
|
-
catch (error) {
|
88
|
-
// Log errors to stderr and write error result to stdout
|
89
|
-
console.error(`Error processing command: ${error instanceof Error ? error.message : String(error)}`);
|
90
|
-
console.log(JSON.stringify({
|
91
|
-
success: false,
|
92
|
-
error: error instanceof Error ? error.message : String(error),
|
93
|
-
}));
|
94
|
-
}
|
95
|
-
}
|
96
|
-
});
|
97
|
-
// Handle end of input
|
98
|
-
rl.on("close", () => {
|
99
|
-
console.error("Input stream closed. Waiting for output to flush...");
|
100
|
-
// Add a delay before exiting to ensure all output is flushed
|
101
|
-
setTimeout(() => {
|
102
|
-
console.error("Exiting...");
|
103
|
-
process.exit(0);
|
104
|
-
}, 1000);
|
105
|
-
});
|
106
|
-
}
|
107
|
-
exports.main = main;
|
108
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cli/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,0CAAqD;AACrD,mDAAqC;AACrC,6CA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C;AACL,CAAC;AA/ED,oBA+EC"}
|
package/dist/cli/jsonrpc.d.ts
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* JSON-RPC 2.0 handler for MCP Documentation Service
|
3
|
-
*
|
4
|
-
* This module adds JSON-RPC 2.0 support to the MCP Documentation Service,
|
5
|
-
* allowing it to be used with Cursor and other MCP clients.
|
6
|
-
*/
|
7
|
-
interface JsonRpcSuccessResponse {
|
8
|
-
jsonrpc: string;
|
9
|
-
result: any;
|
10
|
-
id: number | string | null;
|
11
|
-
}
|
12
|
-
interface JsonRpcErrorResponse {
|
13
|
-
jsonrpc: string;
|
14
|
-
error: {
|
15
|
-
code: number;
|
16
|
-
message: string;
|
17
|
-
data?: any;
|
18
|
-
};
|
19
|
-
id: number | string | null;
|
20
|
-
}
|
21
|
-
type JsonRpcResponse = JsonRpcSuccessResponse | JsonRpcErrorResponse;
|
22
|
-
/**
|
23
|
-
* Process a JSON-RPC 2.0 request and return a response
|
24
|
-
*/
|
25
|
-
export declare function processJsonRpcRequest(requestStr: string, options: {
|
26
|
-
docsDir: string;
|
27
|
-
createIfNotExists: boolean;
|
28
|
-
}): Promise<JsonRpcResponse>;
|
29
|
-
export {};
|
package/dist/cli/jsonrpc.js
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
/**
|
3
|
-
* JSON-RPC 2.0 handler for MCP Documentation Service
|
4
|
-
*
|
5
|
-
* This module adds JSON-RPC 2.0 support to the MCP Documentation Service,
|
6
|
-
* allowing it to be used with Cursor and other MCP clients.
|
7
|
-
*/
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
9
|
-
exports.processJsonRpcRequest = void 0;
|
10
|
-
const index_js_1 = require("../index.js");
|
11
|
-
/**
|
12
|
-
* Process a JSON-RPC 2.0 request and return a response
|
13
|
-
*/
|
14
|
-
async function processJsonRpcRequest(requestStr, options) {
|
15
|
-
try {
|
16
|
-
// Parse the JSON-RPC request
|
17
|
-
const request = JSON.parse(requestStr);
|
18
|
-
// Validate the request
|
19
|
-
if (request.jsonrpc !== "2.0") {
|
20
|
-
return createErrorResponse(request.id, -32600, "Invalid Request: Not a valid JSON-RPC 2.0 request");
|
21
|
-
}
|
22
|
-
// Handle special MCP methods
|
23
|
-
if (request.method === "list_allowed_directories") {
|
24
|
-
return createSuccessResponse(request.id, [options.docsDir]);
|
25
|
-
}
|
26
|
-
// Translate JSON-RPC method and params to SQL-like query
|
27
|
-
const sqlQuery = translateToSqlQuery(request.method, request.params);
|
28
|
-
if (!sqlQuery) {
|
29
|
-
return createErrorResponse(request.id, -32601, `Method not found: ${request.method}`);
|
30
|
-
}
|
31
|
-
// Execute the query
|
32
|
-
const result = await (0, index_js_1.query)(sqlQuery, options);
|
33
|
-
// Translate the result to JSON-RPC response
|
34
|
-
if (result.success) {
|
35
|
-
return createSuccessResponse(request.id, result.data);
|
36
|
-
}
|
37
|
-
else {
|
38
|
-
return createErrorResponse(request.id, -32000, result.error || "Unknown error");
|
39
|
-
}
|
40
|
-
}
|
41
|
-
catch (error) {
|
42
|
-
console.error("Error processing JSON-RPC request:", error);
|
43
|
-
return createErrorResponse(null, -32700, error instanceof Error ? error.message : String(error));
|
44
|
-
}
|
45
|
-
}
|
46
|
-
exports.processJsonRpcRequest = processJsonRpcRequest;
|
47
|
-
/**
|
48
|
-
* Translate a JSON-RPC method and params to a SQL-like query
|
49
|
-
*/
|
50
|
-
function translateToSqlQuery(method, params) {
|
51
|
-
switch (method) {
|
52
|
-
case "list_files":
|
53
|
-
return "list_files()";
|
54
|
-
case "list_directories":
|
55
|
-
return "list_directories()";
|
56
|
-
case "get_document":
|
57
|
-
if (!params || !params.path) {
|
58
|
-
throw new Error("Invalid params: path is required");
|
59
|
-
}
|
60
|
-
return `get_document(path="${params.path}")`;
|
61
|
-
case "search_documents":
|
62
|
-
if (!params || !params.query) {
|
63
|
-
throw new Error("Invalid params: query is required");
|
64
|
-
}
|
65
|
-
return `search_documents(query="${params.query}")`;
|
66
|
-
case "create_document":
|
67
|
-
if (!params || !params.path || !params.content) {
|
68
|
-
throw new Error("Invalid params: path and content are required");
|
69
|
-
}
|
70
|
-
return `create_document(path="${params.path}", content="${escapeString(params.content)}")`;
|
71
|
-
case "update_document":
|
72
|
-
if (!params || !params.path || !params.content) {
|
73
|
-
throw new Error("Invalid params: path and content are required");
|
74
|
-
}
|
75
|
-
return `update_document(path="${params.path}", content="${escapeString(params.content)}")`;
|
76
|
-
case "delete_document":
|
77
|
-
if (!params || !params.path) {
|
78
|
-
throw new Error("Invalid params: path is required");
|
79
|
-
}
|
80
|
-
return `delete_document(path="${params.path}")`;
|
81
|
-
case "analyze_docs":
|
82
|
-
return "analyze_docs()";
|
83
|
-
case "get_health_score":
|
84
|
-
return "get_health_score()";
|
85
|
-
case "get_suggestions":
|
86
|
-
return "get_suggestions()";
|
87
|
-
default:
|
88
|
-
return null;
|
89
|
-
}
|
90
|
-
}
|
91
|
-
/**
|
92
|
-
* Create a JSON-RPC 2.0 success response
|
93
|
-
*/
|
94
|
-
function createSuccessResponse(id, result) {
|
95
|
-
return {
|
96
|
-
jsonrpc: "2.0",
|
97
|
-
result,
|
98
|
-
id,
|
99
|
-
};
|
100
|
-
}
|
101
|
-
/**
|
102
|
-
* Create a JSON-RPC 2.0 error response
|
103
|
-
*/
|
104
|
-
function createErrorResponse(id, code, message, data) {
|
105
|
-
return {
|
106
|
-
jsonrpc: "2.0",
|
107
|
-
error: {
|
108
|
-
code,
|
109
|
-
message,
|
110
|
-
data,
|
111
|
-
},
|
112
|
-
id,
|
113
|
-
};
|
114
|
-
}
|
115
|
-
/**
|
116
|
-
* Escape special characters in a string
|
117
|
-
*/
|
118
|
-
function escapeString(str) {
|
119
|
-
return str.replace(/"/g, '\\"').replace(/\n/g, "\\n");
|
120
|
-
}
|
121
|
-
//# sourceMappingURL=jsonrpc.js.map
|
package/dist/cli/jsonrpc.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"j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AAC,IAAI,eAAe,YAAY,CACpE,MAAM,CAAC,OAAO,CACf,IAAI,CAAC;QAER,KAAK,iBAAiB;YACpB,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;gBAC3B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;aACrD;YACD,OAAO,yBAAyB,MAAM,CAAC,IAAI,IAAI,CAAC;QAElD,KAAK,cAAc;YACjB,OAAO,gBAAgB,CAAC;QAE1B,KAAK,kBAAkB;YACrB,OAAO,oBAAoB,CAAC;QAE9B,KAAK,iBAAiB;YACpB,OAAO,mBAAmB,CAAC;QAE7B;YACE,OAAO,IAAI,CAAC;KACf;AACH,CAAC;AAED;;GAEG;AACH,SAAS,qBAAqB,CAC5B,EAA0B,EAC1B,MAAW;IAEX,OAAO;QACL,OAAO,EAAE,KAAK;QACd,MAAM;QACN,EAAE;KACH,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAC1B,EAA0B,EAC1B,IAAY,EACZ,OAAe,EACf,IAAU;IAEV,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK,EAAE;YACL,IAAI;YACJ,OAAO;YACP,IAAI;SACL;QACD,EAAE;KACH,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC"}
|
@@ -1,25 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Document Analyzer for generating insights about documentation
|
3
|
-
*/
|
4
|
-
import { DocAnalysisResult } from "../types/index.js";
|
5
|
-
import { DocManager } from "./docManager.js";
|
6
|
-
export declare class DocAnalyzer {
|
7
|
-
private docManager;
|
8
|
-
constructor(docManager: DocManager);
|
9
|
-
/**
|
10
|
-
* Analyze the documentation and generate insights
|
11
|
-
*/
|
12
|
-
analyzeDocumentation(directory?: string): Promise<DocAnalysisResult>;
|
13
|
-
/**
|
14
|
-
* Find documentation gaps (directories with few or no documents)
|
15
|
-
*/
|
16
|
-
findDocumentationGaps(): Promise<Record<string, number>>;
|
17
|
-
/**
|
18
|
-
* Calculate overall documentation health score (0-100)
|
19
|
-
*/
|
20
|
-
calculateHealthScore(): Promise<number>;
|
21
|
-
/**
|
22
|
-
* Generate suggestions for improving documentation
|
23
|
-
*/
|
24
|
-
generateSuggestions(): Promise<string[]>;
|
25
|
-
}
|
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/docAnalyzer.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAKH,MAAa,WAAW;IAGtB,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;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C,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
|
-
}
|