mcp-docs-service 0.4.0 → 0.5.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/README.md +228 -54
- package/dist/handlers/documents.js +469 -0
- package/dist/handlers/health.js +189 -118
- package/dist/index.js +116 -32
- package/dist/schemas/tools.js +33 -0
- package/package.json +3 -1
- package/dist/cli/bin.d.ts +0 -8
- package/dist/cli/bin.js +0 -133
- package/dist/cli/bin.js.map +0 -1
- package/dist/handlers/docs.d.ts +0 -26
- package/dist/handlers/docs.js +0 -513
- package/dist/handlers/docs.js.map +0 -1
- package/dist/handlers/file.d.ts +0 -32
- package/dist/handlers/file.js +0 -222
- package/dist/handlers/file.js.map +0 -1
- package/dist/handlers/index.d.ts +0 -1
- package/dist/handlers/index.js.map +0 -1
- package/dist/schemas/index.d.ts +0 -1
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/tools.d.ts +0 -164
- package/dist/schemas/tools.js.map +0 -1
- package/dist/types/docs.d.ts +0 -74
- package/dist/types/docs.js.map +0 -1
- package/dist/types/file.d.ts +0 -21
- package/dist/types/file.js +0 -2
- package/dist/types/file.js.map +0 -1
- package/dist/types/index.d.ts +0 -44
- package/dist/types/index.js.map +0 -1
- package/dist/types/tools.d.ts +0 -11
- package/dist/types/tools.js.map +0 -1
- package/dist/utils/file.d.ts +0 -24
- package/dist/utils/file.js +0 -94
- package/dist/utils/file.js.map +0 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/path.d.ts +0 -16
- package/dist/utils/path.js.map +0 -1
package/dist/schemas/tools.js
CHANGED
@@ -45,3 +45,36 @@ export const SearchDocumentsSchema = ToolInputSchema.extend({
|
|
45
45
|
export const CheckDocumentationHealthSchema = ToolInputSchema.extend({
|
46
46
|
basePath: z.string().optional().default(""),
|
47
47
|
});
|
48
|
+
// New schemas for Phase 2 features
|
49
|
+
export const CreateFolderSchema = ToolInputSchema.extend({
|
50
|
+
path: z.string(),
|
51
|
+
createReadme: z.boolean().default(true),
|
52
|
+
});
|
53
|
+
export const MoveDocumentSchema = ToolInputSchema.extend({
|
54
|
+
sourcePath: z.string(),
|
55
|
+
destinationPath: z.string(),
|
56
|
+
updateReferences: z.boolean().default(true),
|
57
|
+
});
|
58
|
+
export const RenameDocumentSchema = ToolInputSchema.extend({
|
59
|
+
path: z.string(),
|
60
|
+
newName: z.string(),
|
61
|
+
updateReferences: z.boolean().default(true),
|
62
|
+
});
|
63
|
+
export const UpdateNavigationOrderSchema = ToolInputSchema.extend({
|
64
|
+
path: z.string(),
|
65
|
+
order: z.number(),
|
66
|
+
});
|
67
|
+
export const CreateSectionSchema = ToolInputSchema.extend({
|
68
|
+
title: z.string(),
|
69
|
+
path: z.string(),
|
70
|
+
order: z.number().optional(),
|
71
|
+
});
|
72
|
+
// New schemas for Phase 3 features
|
73
|
+
export const ValidateLinksSchema = ToolInputSchema.extend({
|
74
|
+
basePath: z.string().optional().default(""),
|
75
|
+
recursive: z.boolean().default(true),
|
76
|
+
});
|
77
|
+
export const ValidateMetadataSchema = ToolInputSchema.extend({
|
78
|
+
basePath: z.string().optional().default(""),
|
79
|
+
requiredFields: z.array(z.string()).optional(),
|
80
|
+
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mcp-docs-service",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.5.1",
|
4
4
|
"description": "MCP Documentation Service - A Model Context Protocol implementation for documentation management",
|
5
5
|
"type": "module",
|
6
6
|
"main": "dist/index.js",
|
@@ -19,6 +19,7 @@
|
|
19
19
|
"lint": "eslint src --ext .ts",
|
20
20
|
"test": "vitest run",
|
21
21
|
"test:watch": "vitest",
|
22
|
+
"test:coverage": "vitest run --coverage",
|
22
23
|
"prepublishOnly": "npm run build",
|
23
24
|
"prepare-publish": "node scripts/prepare-publish.js"
|
24
25
|
},
|
@@ -44,6 +45,7 @@
|
|
44
45
|
"@types/node": "^20.10.5",
|
45
46
|
"@typescript-eslint/eslint-plugin": "^6.15.0",
|
46
47
|
"@typescript-eslint/parser": "^6.15.0",
|
48
|
+
"@vitest/coverage-v8": "^3.0.8",
|
47
49
|
"eslint": "^8.56.0",
|
48
50
|
"ts-node": "^10.9.2",
|
49
51
|
"typescript": "^5.3.3",
|
package/dist/cli/bin.d.ts
DELETED
package/dist/cli/bin.js
DELETED
@@ -1,133 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
/**
|
3
|
-
* MCP Docs Service CLI
|
4
|
-
*
|
5
|
-
* This is the entry point for the CLI version of the MCP Docs Service.
|
6
|
-
* It simply imports and runs the main service.
|
7
|
-
*/
|
8
|
-
import path from "path";
|
9
|
-
import fs from "fs";
|
10
|
-
import { fileURLToPath } from "url";
|
11
|
-
// Get the current directory
|
12
|
-
const __filename = fileURLToPath(import.meta.url);
|
13
|
-
const __dirname = path.dirname(__filename);
|
14
|
-
// Check if we're running under MCP Inspector
|
15
|
-
const isMCPInspector = process.env.MCP_INSPECTOR === "true" ||
|
16
|
-
process.argv.some((arg) => arg.includes("modelcontextprotocol/inspector"));
|
17
|
-
// Create a logging function that respects MCP Inspector mode
|
18
|
-
const log = (...args) => {
|
19
|
-
if (!isMCPInspector) {
|
20
|
-
console.log(...args);
|
21
|
-
}
|
22
|
-
};
|
23
|
-
const errorLog = (...args) => {
|
24
|
-
console.error(...args);
|
25
|
-
};
|
26
|
-
// Parse command line arguments
|
27
|
-
const args = process.argv.slice(2);
|
28
|
-
log("CLI Arguments:", JSON.stringify(args));
|
29
|
-
let docsDir = path.join(process.cwd(), "docs");
|
30
|
-
let createDir = false;
|
31
|
-
let healthCheck = false;
|
32
|
-
let showHelp = false;
|
33
|
-
// MCP Inspector specific handling
|
34
|
-
// When run through MCP Inspector, it might pass arguments in a different format
|
35
|
-
if (isMCPInspector) {
|
36
|
-
log("Detected MCP Inspector environment");
|
37
|
-
// Try to find a valid docs directory in all arguments
|
38
|
-
// This is a more aggressive approach but should work with various argument formats
|
39
|
-
for (const arg of process.argv) {
|
40
|
-
if (arg.endsWith("/docs") || arg.includes("/docs ")) {
|
41
|
-
const potentialPath = arg.split(" ")[0];
|
42
|
-
log("Found potential docs path in MCP Inspector args:", potentialPath);
|
43
|
-
if (fs.existsSync(potentialPath)) {
|
44
|
-
docsDir = path.resolve(potentialPath);
|
45
|
-
log("Using docs directory from MCP Inspector:", docsDir);
|
46
|
-
break;
|
47
|
-
}
|
48
|
-
}
|
49
|
-
}
|
50
|
-
// If we couldn't find a valid docs directory, use the default
|
51
|
-
log("Using docs directory:", docsDir);
|
52
|
-
}
|
53
|
-
else {
|
54
|
-
// Standard argument parsing
|
55
|
-
for (let i = 0; i < args.length; i++) {
|
56
|
-
log(`Processing arg[${i}]:`, args[i]);
|
57
|
-
if (args[i] === "--docs-dir" && i + 1 < args.length) {
|
58
|
-
docsDir = path.resolve(args[i + 1]);
|
59
|
-
log("Setting docs dir from --docs-dir flag:", docsDir);
|
60
|
-
i++; // Skip the next argument
|
61
|
-
}
|
62
|
-
else if (args[i] === "--create-dir") {
|
63
|
-
createDir = true;
|
64
|
-
}
|
65
|
-
else if (args[i] === "--health-check") {
|
66
|
-
healthCheck = true;
|
67
|
-
}
|
68
|
-
else if (args[i] === "--help" || args[i] === "-h") {
|
69
|
-
showHelp = true;
|
70
|
-
}
|
71
|
-
else if (!args[i].startsWith("--")) {
|
72
|
-
// Handle positional argument as docs directory
|
73
|
-
const potentialPath = path.resolve(args[i]);
|
74
|
-
log("Potential positional path:", potentialPath);
|
75
|
-
log("Path exists?", fs.existsSync(potentialPath));
|
76
|
-
if (fs.existsSync(potentialPath)) {
|
77
|
-
docsDir = potentialPath;
|
78
|
-
log("Setting docs dir from positional argument:", docsDir);
|
79
|
-
}
|
80
|
-
else {
|
81
|
-
log("Path doesn't exist, not using as docs dir:", potentialPath);
|
82
|
-
}
|
83
|
-
}
|
84
|
-
}
|
85
|
-
}
|
86
|
-
log("Final docs dir:", docsDir);
|
87
|
-
// Show help if requested
|
88
|
-
if (showHelp) {
|
89
|
-
console.log(`
|
90
|
-
MCP Docs Service - Documentation Management Service
|
91
|
-
|
92
|
-
Usage:
|
93
|
-
mcp-docs-service [options]
|
94
|
-
mcp-docs-service <docs-directory> [options]
|
95
|
-
|
96
|
-
Options:
|
97
|
-
--docs-dir <path> Specify the docs directory (default: ./docs)
|
98
|
-
--create-dir Create the docs directory if it doesn't exist
|
99
|
-
--health-check Run a health check on the documentation
|
100
|
-
--help, -h Show this help message
|
101
|
-
`);
|
102
|
-
process.exit(0);
|
103
|
-
}
|
104
|
-
// Create docs directory if it doesn't exist and --create-dir is specified
|
105
|
-
if (createDir) {
|
106
|
-
try {
|
107
|
-
if (!fs.existsSync(docsDir)) {
|
108
|
-
fs.mkdirSync(docsDir, { recursive: true });
|
109
|
-
log(`Created docs directory: ${docsDir}`);
|
110
|
-
}
|
111
|
-
}
|
112
|
-
catch (error) {
|
113
|
-
errorLog(`Error creating docs directory: ${error}`);
|
114
|
-
process.exit(1);
|
115
|
-
}
|
116
|
-
}
|
117
|
-
// Ensure the docs directory exists
|
118
|
-
if (!fs.existsSync(docsDir)) {
|
119
|
-
errorLog(`Error: Docs directory does not exist: ${docsDir}`);
|
120
|
-
errorLog(`Use --create-dir to create it automatically`);
|
121
|
-
process.exit(1);
|
122
|
-
}
|
123
|
-
// Add the docs directory to process.argv so it's available to the main service
|
124
|
-
process.argv.push(docsDir);
|
125
|
-
// Add health check flag to process.argv if specified
|
126
|
-
if (healthCheck) {
|
127
|
-
process.argv.push("--health-check");
|
128
|
-
}
|
129
|
-
// Import the main service
|
130
|
-
import "../index.js";
|
131
|
-
// The main service will handle the CLI arguments and execution
|
132
|
-
// No additional code needed here as the main index.ts already has CLI functionality
|
133
|
-
//# 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":[],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C,OAAO,CAAC,EAAE,CAAC;YAC5B,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3C,GAAG,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,QAAQ,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,mCAAmC;AACnC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;IAC5B,QAAQ,CAAC,yCAAyC,OAAO,EAAE,CAAC,CAAC;IAC7D,QAAQ,CAAC,6CAA6C,CAAC,CAAC;IACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,+EAA+E;AAC/E,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAE3B,qDAAqD;AACrD,IAAI,WAAW,EAAE,CAAC;IAChB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;AACtC,CAAC;AAED,0BAA0B;AAC1B,OAAO,aAAa,CAAC;AAErB,+DAA+D;AAC/D,oFAAoF"}
|
package/dist/handlers/docs.d.ts
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
import { ToolResponse } from "../types/tools.js";
|
2
|
-
/**
|
3
|
-
* Reads a markdown document and extracts its content and metadata
|
4
|
-
*/
|
5
|
-
export declare function readDocument(docPath: string, allowedDirectories: string[]): Promise<ToolResponse>;
|
6
|
-
/**
|
7
|
-
* Lists all markdown documents in a directory
|
8
|
-
*/
|
9
|
-
export declare function listDocuments(basePath: string, allowedDirectories: string[]): Promise<ToolResponse>;
|
10
|
-
/**
|
11
|
-
* Gets the structure of the documentation directory
|
12
|
-
*/
|
13
|
-
export declare function getStructure(basePath: string, allowedDirectories: string[]): Promise<ToolResponse>;
|
14
|
-
/**
|
15
|
-
* Gets the navigation structure for the documentation
|
16
|
-
*/
|
17
|
-
export declare function getNavigation(basePath: string, allowedDirectories: string[]): Promise<ToolResponse>;
|
18
|
-
/**
|
19
|
-
* Checks the health of documentation
|
20
|
-
*/
|
21
|
-
export declare function checkDocumentationHealth(basePath: string, options: {
|
22
|
-
checkLinks?: boolean;
|
23
|
-
checkMetadata?: boolean;
|
24
|
-
checkOrphans?: boolean;
|
25
|
-
requiredMetadataFields?: string[];
|
26
|
-
}, allowedDirectories: string[]): Promise<ToolResponse>;
|