@utaba/ucm-mcp-server 6.5.0 → 6.6.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/dist/clients/UcmLocalApiClient.d.ts +175 -2
- package/dist/clients/UcmLocalApiClient.js +203 -3
- package/dist/index.js +1 -1
- package/dist/mcp-server/clients/UcmLocalApiClient.d.ts +399 -0
- package/dist/mcp-server/clients/UcmLocalApiClient.js +719 -0
- package/dist/mcp-server/index.d.ts +3 -0
- package/dist/mcp-server/index.js +68 -0
- package/dist/mcp-server/interfaces/ILogger.d.ts +8 -0
- package/dist/mcp-server/interfaces/ILogger.js +4 -0
- package/dist/mcp-server/interfaces/IMcpTool.d.ts +7 -0
- package/dist/mcp-server/interfaces/IMcpTool.js +3 -0
- package/dist/mcp-server/logging/ConsoleLogger.d.ts +16 -0
- package/dist/mcp-server/logging/ConsoleLogger.js +45 -0
- package/dist/mcp-server/logging/LoggerFactory.d.ts +9 -0
- package/dist/mcp-server/logging/LoggerFactory.js +12 -0
- package/dist/mcp-server/server/McpConfig.d.ts +26 -0
- package/dist/mcp-server/server/McpConfig.js +90 -0
- package/dist/mcp-server/server/McpHandler.d.ts +12 -0
- package/dist/mcp-server/server/McpHandler.js +84 -0
- package/dist/mcp-server/server/McpServer.d.ts +15 -0
- package/dist/mcp-server/server/McpServer.js +49 -0
- package/dist/mcp-server/server/ToolRegistry.d.ts +23 -0
- package/dist/mcp-server/server/ToolRegistry.js +169 -0
- package/dist/mcp-server/tools/authorization/ListAuthorizationsTool.d.ts +21 -0
- package/dist/mcp-server/tools/authorization/ListAuthorizationsTool.js +146 -0
- package/dist/mcp-server/tools/authorization/SignOutTool.d.ts +23 -0
- package/dist/mcp-server/tools/authorization/SignOutTool.js +128 -0
- package/dist/mcp-server/tools/base/BaseToolController.d.ts +19 -0
- package/dist/mcp-server/tools/base/BaseToolController.js +58 -0
- package/dist/mcp-server/tools/connections/AccessConnectionTool.d.ts +21 -0
- package/dist/mcp-server/tools/connections/AccessConnectionTool.js +107 -0
- package/dist/mcp-server/tools/connections/CallRemoteToolTool.d.ts +22 -0
- package/dist/mcp-server/tools/connections/CallRemoteToolTool.js +124 -0
- package/dist/mcp-server/tools/core/DeleteArtifactTool.d.ts +11 -0
- package/dist/mcp-server/tools/core/DeleteArtifactTool.js +83 -0
- package/dist/mcp-server/tools/core/EditArtifactMetadataTool.d.ts +12 -0
- package/dist/mcp-server/tools/core/EditArtifactMetadataTool.js +173 -0
- package/dist/mcp-server/tools/core/GetArtifactTool.d.ts +13 -0
- package/dist/mcp-server/tools/core/GetArtifactTool.js +124 -0
- package/dist/mcp-server/tools/core/GetArtifactVersionsTool.d.ts +11 -0
- package/dist/mcp-server/tools/core/GetArtifactVersionsTool.js +63 -0
- package/dist/mcp-server/tools/core/GetChunkTool.d.ts +11 -0
- package/dist/mcp-server/tools/core/GetChunkTool.js +56 -0
- package/dist/mcp-server/tools/core/ListArtifactsTool.d.ts +11 -0
- package/dist/mcp-server/tools/core/ListArtifactsTool.js +84 -0
- package/dist/mcp-server/tools/core/MoveArtifactTool.d.ts +12 -0
- package/dist/mcp-server/tools/core/MoveArtifactTool.js +104 -0
- package/dist/mcp-server/tools/core/PublishArtifactFromFileTool.d.ts +15 -0
- package/dist/mcp-server/tools/core/PublishArtifactFromFileTool.js +277 -0
- package/dist/mcp-server/tools/core/PublishArtifactTool.d.ts +13 -0
- package/dist/mcp-server/tools/core/PublishArtifactTool.js +218 -0
- package/dist/mcp-server/tools/core/SearchArtifactsTool.d.ts +11 -0
- package/dist/mcp-server/tools/core/SearchArtifactsTool.js +137 -0
- package/dist/mcp-server/tools/list/ListNamespaceController.d.ts +1 -0
- package/dist/mcp-server/tools/list/ListNamespaceController.js +8 -0
- package/dist/mcp-server/tools/memory-graph/GraphCreateEntitiesTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/GraphCreateEntitiesTool.js +58 -0
- package/dist/mcp-server/tools/memory-graph/GraphCreateRelationshipsTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/GraphCreateRelationshipsTool.js +57 -0
- package/dist/mcp-server/tools/memory-graph/GraphCreateTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/GraphCreateTool.js +64 -0
- package/dist/mcp-server/tools/memory-graph/GraphDeleteEntitiesTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/GraphDeleteEntitiesTool.js +45 -0
- package/dist/mcp-server/tools/memory-graph/GraphDeleteRelationshipsTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/GraphDeleteRelationshipsTool.js +45 -0
- package/dist/mcp-server/tools/memory-graph/GraphExploreTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/GraphExploreTool.js +73 -0
- package/dist/mcp-server/tools/memory-graph/GraphFindEntitiesTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/GraphFindEntitiesTool.js +68 -0
- package/dist/mcp-server/tools/memory-graph/GraphFindPathsTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/GraphFindPathsTool.js +62 -0
- package/dist/mcp-server/tools/memory-graph/GraphGetEntityTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/GraphGetEntityTool.js +49 -0
- package/dist/mcp-server/tools/memory-graph/GraphGetRelationshipsTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/GraphGetRelationshipsTool.js +62 -0
- package/dist/mcp-server/tools/memory-graph/GraphListTemplatesTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/GraphListTemplatesTool.js +34 -0
- package/dist/mcp-server/tools/memory-graph/GraphListTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/GraphListTool.js +45 -0
- package/dist/mcp-server/tools/memory-graph/GraphOpenTool.d.ts +15 -0
- package/dist/mcp-server/tools/memory-graph/GraphOpenTool.js +50 -0
- package/dist/mcp-server/tools/memory-graph/GraphProposeVocabularyTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/GraphProposeVocabularyTool.js +108 -0
- package/dist/mcp-server/tools/memory-graph/GraphSearchTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/GraphSearchTool.js +94 -0
- package/dist/mcp-server/tools/memory-graph/GraphTraverseTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/GraphTraverseTool.js +114 -0
- package/dist/mcp-server/tools/memory-graph/GraphUpdateEntitiesTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/GraphUpdateEntitiesTool.js +58 -0
- package/dist/mcp-server/tools/memory-graph/KnowledgeSetListTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/KnowledgeSetListTool.js +25 -0
- package/dist/mcp-server/tools/memory-graph/KnowledgeSetOpenTool.d.ts +14 -0
- package/dist/mcp-server/tools/memory-graph/KnowledgeSetOpenTool.js +31 -0
- package/dist/mcp-server/tools/repository/CreateRepositoryTool.d.ts +12 -0
- package/dist/mcp-server/tools/repository/CreateRepositoryTool.js +116 -0
- package/dist/mcp-server/tools/repository/GetRepositoryTool.d.ts +12 -0
- package/dist/mcp-server/tools/repository/GetRepositoryTool.js +85 -0
- package/dist/mcp-server/tools/repository/UpdateRepositoryTool.d.ts +12 -0
- package/dist/mcp-server/tools/repository/UpdateRepositoryTool.js +115 -0
- package/dist/mcp-server/tools/sharepoint/SharePointListConnectionsTool.d.ts +19 -0
- package/dist/mcp-server/tools/sharepoint/SharePointListConnectionsTool.js +90 -0
- package/dist/mcp-server/tools/sharepoint/SharePointListFoldersTool.d.ts +21 -0
- package/dist/mcp-server/tools/sharepoint/SharePointListFoldersTool.js +133 -0
- package/dist/mcp-server/tools/sharepoint/SharePointReadFileTool.d.ts +22 -0
- package/dist/mcp-server/tools/sharepoint/SharePointReadFileTool.js +146 -0
- package/dist/mcp-server/tools/sharepoint/SharePointReadRelatedFileTool.d.ts +18 -0
- package/dist/mcp-server/tools/sharepoint/SharePointReadRelatedFileTool.js +108 -0
- package/dist/mcp-server/tools/sharepoint/SharePointSearchTool.d.ts +22 -0
- package/dist/mcp-server/tools/sharepoint/SharePointSearchTool.js +125 -0
- package/dist/mcp-server/tools/utility/AuthorIndexTool.d.ts +11 -0
- package/dist/mcp-server/tools/utility/AuthorIndexTool.js +49 -0
- package/dist/mcp-server/tools/utility/AuthorRecentsTool.d.ts +11 -0
- package/dist/mcp-server/tools/utility/AuthorRecentsTool.js +49 -0
- package/dist/mcp-server/tools/utility/ListRepositoriesTool.d.ts +11 -0
- package/dist/mcp-server/tools/utility/ListRepositoriesTool.js +68 -0
- package/dist/mcp-server/tools/utility/QuickstartTool.d.ts +11 -0
- package/dist/mcp-server/tools/utility/QuickstartTool.js +36 -0
- package/dist/mcp-server/types/UcmApiTypes.d.ts +40 -0
- package/dist/mcp-server/types/UcmApiTypes.js +4 -0
- package/dist/mcp-server/utils/McpErrorHandler.d.ts +25 -0
- package/dist/mcp-server/utils/McpErrorHandler.js +67 -0
- package/dist/mcp-server/utils/PathUtils.d.ts +61 -0
- package/dist/mcp-server/utils/PathUtils.js +178 -0
- package/dist/mcp-server/utils/ResponseChunker.d.ts +25 -0
- package/dist/mcp-server/utils/ResponseChunker.js +79 -0
- package/dist/mcp-server/utils/SharePointErrorHandler.d.ts +34 -0
- package/dist/mcp-server/utils/SharePointErrorHandler.js +55 -0
- package/dist/schemas/memory-graph-tool-schemas.d.ts +789 -0
- package/dist/schemas/memory-graph-tool-schemas.js +181 -0
- package/dist/server/ToolRegistry.js +42 -8
- package/dist/tools/authorization/ListAuthorizationsTool.js +2 -2
- package/dist/tools/authorization/SignOutTool.js +2 -2
- package/dist/tools/connections/AccessConnectionTool.js +8 -6
- package/dist/tools/connections/CallRemoteToolTool.js +4 -4
- package/dist/tools/core/DeleteArtifactTool.js +5 -4
- package/dist/tools/core/EditArtifactMetadataTool.js +1 -1
- package/dist/tools/core/GetArtifactTool.js +1 -1
- package/dist/tools/core/GetArtifactVersionsTool.js +1 -1
- package/dist/tools/core/GetChunkTool.js +1 -1
- package/dist/tools/core/ListArtifactsTool.js +1 -1
- package/dist/tools/core/MoveArtifactTool.js +1 -1
- package/dist/tools/core/PublishArtifactFromFileTool.js +1 -1
- package/dist/tools/core/PublishArtifactTool.js +2 -2
- package/dist/tools/core/SearchArtifactsTool.js +7 -6
- package/dist/tools/memory-graph/GraphCreateEntitiesTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphCreateEntitiesTool.js +56 -0
- package/dist/tools/memory-graph/GraphCreateRelationshipsTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphCreateRelationshipsTool.js +55 -0
- package/dist/tools/memory-graph/GraphCreateTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphCreateTool.js +62 -0
- package/dist/tools/memory-graph/GraphDeleteEntitiesTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphDeleteEntitiesTool.js +43 -0
- package/dist/tools/memory-graph/GraphDeleteRelationshipsTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphDeleteRelationshipsTool.js +43 -0
- package/dist/tools/memory-graph/GraphExploreTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphExploreTool.js +71 -0
- package/dist/tools/memory-graph/GraphFindEntitiesTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphFindEntitiesTool.js +66 -0
- package/dist/tools/memory-graph/GraphFindPathsTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphFindPathsTool.js +60 -0
- package/dist/tools/memory-graph/GraphGetEntityTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphGetEntityTool.js +47 -0
- package/dist/tools/memory-graph/GraphGetRelationshipsTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphGetRelationshipsTool.js +60 -0
- package/dist/tools/memory-graph/GraphGetStatsTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphGetStatsTool.js +42 -0
- package/dist/tools/memory-graph/GraphListTemplatesTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphListTemplatesTool.js +32 -0
- package/dist/tools/memory-graph/GraphListTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphListTool.js +43 -0
- package/dist/tools/memory-graph/GraphOpenTool.d.ts +12 -0
- package/dist/tools/memory-graph/GraphOpenTool.js +48 -0
- package/dist/tools/memory-graph/GraphProposeVocabularyTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphProposeVocabularyTool.js +104 -0
- package/dist/tools/memory-graph/GraphRemoveRelationshipsTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphRemoveRelationshipsTool.js +47 -0
- package/dist/tools/memory-graph/GraphSearchTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphSearchTool.js +92 -0
- package/dist/tools/memory-graph/GraphTraverseTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphTraverseTool.js +112 -0
- package/dist/tools/memory-graph/GraphUpdateEntitiesTool.d.ts +11 -0
- package/dist/tools/memory-graph/GraphUpdateEntitiesTool.js +56 -0
- package/dist/tools/memory-graph/KnowledgeSetListTool.d.ts +11 -0
- package/dist/tools/memory-graph/KnowledgeSetListTool.js +23 -0
- package/dist/tools/memory-graph/KnowledgeSetOpenTool.d.ts +11 -0
- package/dist/tools/memory-graph/KnowledgeSetOpenTool.js +29 -0
- package/dist/tools/repository/CreateRepositoryTool.js +10 -9
- package/dist/tools/repository/GetRepositoryTool.js +15 -15
- package/dist/tools/repository/UpdateRepositoryTool.js +10 -9
- package/dist/tools/sharepoint/SharePointListConnectionsTool.js +1 -1
- package/dist/tools/sharepoint/SharePointListFoldersTool.js +1 -1
- package/dist/tools/utility/AuthorIndexTool.js +6 -5
- package/dist/tools/utility/AuthorRecentsTool.js +6 -5
- package/dist/tools/utility/HealthCheckController.js +1 -1
- package/dist/tools/utility/ListRepositoriesTool.js +5 -4
- package/dist/utils/McpErrorHandler.js +1 -1
- package/package.json +1 -1
- package/package.json.backup +1 -1
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for parsing UCM paths into component parts
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Parse a UCM path into its component parts
|
|
6
|
+
* Supports formats like:
|
|
7
|
+
* - "utaba/main/commands/user" (namespace only)
|
|
8
|
+
* - "utaba/main/commands/user/CreateUserCommand.ts" (with filename)
|
|
9
|
+
* - "utaba/main/commands/user/CreateUserCommand.ts@1.0.0" (with version)
|
|
10
|
+
*/
|
|
11
|
+
export function parsePath(path) {
|
|
12
|
+
if (!path)
|
|
13
|
+
path = "";
|
|
14
|
+
// Remove leading/trailing slashes
|
|
15
|
+
const cleanPath = path.replace(/^\/+|\/+$/g, '');
|
|
16
|
+
// Split into parts
|
|
17
|
+
const parts = cleanPath.split('/');
|
|
18
|
+
const result = {
|
|
19
|
+
author: parts.length > 0 ? parts[0] : undefined,
|
|
20
|
+
repository: parts.length > 1 ? parts[1] : undefined,
|
|
21
|
+
category: parts.length > 2 ? parts[2] : undefined,
|
|
22
|
+
subcategory: parts.length > 3 ? parts[3] : undefined,
|
|
23
|
+
};
|
|
24
|
+
if (parts.length > 4) {
|
|
25
|
+
let filenameParts = parts[4].split('@');
|
|
26
|
+
//filename
|
|
27
|
+
result.filename = filenameParts[0];
|
|
28
|
+
if (filenameParts.length > 1) {
|
|
29
|
+
result.version = filenameParts[1];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Build a namespace path from components (author/repository/category/subcategory)
|
|
36
|
+
*/
|
|
37
|
+
export function buildNamespacePath(author, repository, category, subcategory) {
|
|
38
|
+
return `${author}/${repository}/${category}/${subcategory}`;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Build a full path with filename and optional version
|
|
42
|
+
*/
|
|
43
|
+
export function buildFullPath(author, repository, category, subcategory, filename, version) {
|
|
44
|
+
let path = buildNamespacePath(author, repository, category, subcategory);
|
|
45
|
+
if (filename) {
|
|
46
|
+
path += `/${filename}`;
|
|
47
|
+
if (version) {
|
|
48
|
+
path += `@${version}`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return path;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Extract namespace from a full path
|
|
55
|
+
*/
|
|
56
|
+
export function extractNamespace(path) {
|
|
57
|
+
const parsed = parsePath(path);
|
|
58
|
+
return buildNamespacePath(parsed.author || '', parsed.repository || '', parsed.category || '', parsed.subcategory || '');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Validate if a path follows UCM naming conventions
|
|
62
|
+
*/
|
|
63
|
+
export function validatePath(path) {
|
|
64
|
+
const errors = [];
|
|
65
|
+
try {
|
|
66
|
+
const parsed = parsePath(path);
|
|
67
|
+
// Validate author (lowercase alphanumeric and hyphens)
|
|
68
|
+
if (!/^[a-z0-9-]+$/.test(parsed.author || '')) {
|
|
69
|
+
errors.push('Author must contain only lowercase letters, numbers, and hyphens');
|
|
70
|
+
}
|
|
71
|
+
// Validate repository (lowercase alphanumeric and hyphens)
|
|
72
|
+
if (!/^[a-z0-9-]+$/.test(parsed.repository || '')) {
|
|
73
|
+
errors.push('Repository must contain only lowercase letters, numbers, and hyphens');
|
|
74
|
+
}
|
|
75
|
+
// Validate category (must be valid UCM category)
|
|
76
|
+
const validCategories = ['commands', 'services', 'patterns', 'implementations', 'contracts', 'guidance', 'project'];
|
|
77
|
+
if (!validCategories.includes(parsed.category || '')) {
|
|
78
|
+
errors.push(`Category must be one of: ${validCategories.join(', ')}`);
|
|
79
|
+
}
|
|
80
|
+
// Validate subcategory (lowercase alphanumeric and hyphens)
|
|
81
|
+
if (!/^[a-z0-9-]+$/.test(parsed.subcategory || '')) {
|
|
82
|
+
errors.push('Subcategory must contain only lowercase letters, numbers, and hyphens');
|
|
83
|
+
}
|
|
84
|
+
// Validate filename if present
|
|
85
|
+
if (parsed.filename) {
|
|
86
|
+
if (!/^[a-zA-Z0-9._-]+\.[a-z]+$/.test(parsed.filename)) {
|
|
87
|
+
errors.push('Filename must be valid with an extension');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Validate version if present
|
|
91
|
+
if (parsed.version) {
|
|
92
|
+
if (!/^v?\d+\.\d+\.\d+(-[a-z0-9-]+)?(\+[a-z0-9-]+)?$/.test(parsed.version)) {
|
|
93
|
+
errors.push('Version must follow semantic versioning (e.g., 1.0.0, v2.1.0)');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
errors.push(error instanceof Error ? error.message : 'Invalid path format');
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
isValid: errors.length === 0,
|
|
102
|
+
errors
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Compare two semantic versions
|
|
107
|
+
* Returns: -1 if version1 < version2, 0 if equal, 1 if version1 > version2
|
|
108
|
+
*/
|
|
109
|
+
export function compareVersions(version1, version2) {
|
|
110
|
+
// Normalize versions by removing 'v' prefix if present
|
|
111
|
+
const v1 = version1.replace(/^v/, '');
|
|
112
|
+
const v2 = version2.replace(/^v/, '');
|
|
113
|
+
// Split versions into parts
|
|
114
|
+
const parts1 = v1.split(/[.-]/);
|
|
115
|
+
const parts2 = v2.split(/[.-]/);
|
|
116
|
+
// Compare major, minor, patch
|
|
117
|
+
for (let i = 0; i < 3; i++) {
|
|
118
|
+
const num1 = parseInt(parts1[i] || '0', 10);
|
|
119
|
+
const num2 = parseInt(parts2[i] || '0', 10);
|
|
120
|
+
if (num1 > num2)
|
|
121
|
+
return 1;
|
|
122
|
+
if (num1 < num2)
|
|
123
|
+
return -1;
|
|
124
|
+
}
|
|
125
|
+
// If major.minor.patch are equal, compare pre-release versions
|
|
126
|
+
const preRelease1 = parts1.slice(3).join('.');
|
|
127
|
+
const preRelease2 = parts2.slice(3).join('.');
|
|
128
|
+
// No pre-release is greater than pre-release
|
|
129
|
+
if (!preRelease1 && preRelease2)
|
|
130
|
+
return 1;
|
|
131
|
+
if (preRelease1 && !preRelease2)
|
|
132
|
+
return -1;
|
|
133
|
+
if (!preRelease1 && !preRelease2)
|
|
134
|
+
return 0;
|
|
135
|
+
// Compare pre-release versions lexically
|
|
136
|
+
return preRelease1.localeCompare(preRelease2);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Check if a version is greater than another version
|
|
140
|
+
*/
|
|
141
|
+
export function isVersionGreater(version1, version2) {
|
|
142
|
+
return compareVersions(version1, version2) > 0;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Check if a version is less than another version
|
|
146
|
+
*/
|
|
147
|
+
export function isVersionLess(version1, version2) {
|
|
148
|
+
return compareVersions(version1, version2) < 0;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Check if two versions are equal
|
|
152
|
+
*/
|
|
153
|
+
export function isVersionEqual(version1, version2) {
|
|
154
|
+
return compareVersions(version1, version2) === 0;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Increment the patch version of a semantic version
|
|
158
|
+
* Examples: 1.0.0 -> 1.0.1, 2.1.5 -> 2.1.6
|
|
159
|
+
*/
|
|
160
|
+
export function incrementPatchVersion(version) {
|
|
161
|
+
// Normalize version by removing 'v' prefix if present
|
|
162
|
+
const normalized = version.replace(/^v/, '');
|
|
163
|
+
// Split version into parts
|
|
164
|
+
const parts = normalized.split('.');
|
|
165
|
+
if (parts.length < 3) {
|
|
166
|
+
throw new Error(`Invalid semantic version format: ${version}`);
|
|
167
|
+
}
|
|
168
|
+
// Parse major, minor, patch
|
|
169
|
+
const major = parseInt(parts[0], 10);
|
|
170
|
+
const minor = parseInt(parts[1], 10);
|
|
171
|
+
const patch = parseInt(parts[2].split('-')[0], 10); // Handle pre-release versions
|
|
172
|
+
if (isNaN(major) || isNaN(minor) || isNaN(patch)) {
|
|
173
|
+
throw new Error(`Invalid semantic version format: ${version}`);
|
|
174
|
+
}
|
|
175
|
+
// Increment patch version
|
|
176
|
+
return `${major}.${minor}.${patch + 1}`;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=PathUtils.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ChunkedResponse {
|
|
2
|
+
chunk: {
|
|
3
|
+
id: string;
|
|
4
|
+
sequence: number;
|
|
5
|
+
total: number;
|
|
6
|
+
data: string;
|
|
7
|
+
};
|
|
8
|
+
hasMore: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class ResponseChunker {
|
|
11
|
+
private static readonly MAX_CHUNK_SIZE;
|
|
12
|
+
private static chunks;
|
|
13
|
+
private static readonly CHUNK_TTL;
|
|
14
|
+
private static chunkTimestamps;
|
|
15
|
+
static chunk(data: any, chunkId?: string): ChunkedResponse | any;
|
|
16
|
+
static getNextChunk(chunkId: string, sequence: number): ChunkedResponse | null;
|
|
17
|
+
static cleanup(chunkId: string): void;
|
|
18
|
+
static cleanupExpired(): void;
|
|
19
|
+
static getChunkInfo(chunkId: string): {
|
|
20
|
+
exists: boolean;
|
|
21
|
+
total?: number;
|
|
22
|
+
expires?: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=ResponseChunker.d.ts.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export class ResponseChunker {
|
|
2
|
+
static MAX_CHUNK_SIZE = 20000; // ~20k characters to stay under token limit
|
|
3
|
+
static chunks = new Map();
|
|
4
|
+
static CHUNK_TTL = 5 * 60 * 1000; // 5 minutes
|
|
5
|
+
static chunkTimestamps = new Map();
|
|
6
|
+
static chunk(data, chunkId) {
|
|
7
|
+
const serialized = typeof data === 'string' ? data : JSON.stringify(data, null, 2);
|
|
8
|
+
// If small enough, return as-is
|
|
9
|
+
if (serialized.length < this.MAX_CHUNK_SIZE) {
|
|
10
|
+
return data;
|
|
11
|
+
}
|
|
12
|
+
// Generate chunk ID if not provided
|
|
13
|
+
const id = chunkId || `ucm_chunk_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
|
|
14
|
+
// Split into chunks
|
|
15
|
+
const chunks = [];
|
|
16
|
+
for (let i = 0; i < serialized.length; i += this.MAX_CHUNK_SIZE) {
|
|
17
|
+
chunks.push(serialized.slice(i, i + this.MAX_CHUNK_SIZE));
|
|
18
|
+
}
|
|
19
|
+
// Store chunks for retrieval with timestamp
|
|
20
|
+
this.chunks.set(id, chunks);
|
|
21
|
+
this.chunkTimestamps.set(id, Date.now());
|
|
22
|
+
// Schedule cleanup after TTL
|
|
23
|
+
setTimeout(() => {
|
|
24
|
+
this.cleanup(id);
|
|
25
|
+
}, this.CHUNK_TTL);
|
|
26
|
+
// Return first chunk with metadata
|
|
27
|
+
return {
|
|
28
|
+
chunk: {
|
|
29
|
+
id,
|
|
30
|
+
sequence: 0,
|
|
31
|
+
total: chunks.length,
|
|
32
|
+
data: chunks[0]
|
|
33
|
+
},
|
|
34
|
+
hasMore: chunks.length > 1
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
static getNextChunk(chunkId, sequence) {
|
|
38
|
+
const chunks = this.chunks.get(chunkId);
|
|
39
|
+
if (!chunks || sequence >= chunks.length || sequence < 0) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
// Update timestamp to extend TTL
|
|
43
|
+
this.chunkTimestamps.set(chunkId, Date.now());
|
|
44
|
+
return {
|
|
45
|
+
chunk: {
|
|
46
|
+
id: chunkId,
|
|
47
|
+
sequence,
|
|
48
|
+
total: chunks.length,
|
|
49
|
+
data: chunks[sequence]
|
|
50
|
+
},
|
|
51
|
+
hasMore: sequence < chunks.length - 1
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
static cleanup(chunkId) {
|
|
55
|
+
this.chunks.delete(chunkId);
|
|
56
|
+
this.chunkTimestamps.delete(chunkId);
|
|
57
|
+
}
|
|
58
|
+
static cleanupExpired() {
|
|
59
|
+
const now = Date.now();
|
|
60
|
+
for (const [id, timestamp] of this.chunkTimestamps.entries()) {
|
|
61
|
+
if (now - timestamp > this.CHUNK_TTL) {
|
|
62
|
+
this.cleanup(id);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
static getChunkInfo(chunkId) {
|
|
67
|
+
const chunks = this.chunks.get(chunkId);
|
|
68
|
+
const timestamp = this.chunkTimestamps.get(chunkId);
|
|
69
|
+
if (!chunks || !timestamp) {
|
|
70
|
+
return { exists: false };
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
exists: true,
|
|
74
|
+
total: chunks.length,
|
|
75
|
+
expires: timestamp + this.CHUNK_TTL
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=ResponseChunker.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SharePointErrorHandler
|
|
3
|
+
* Centralized error handling for SharePoint MCP tools
|
|
4
|
+
*/
|
|
5
|
+
import { ILogger } from '../interfaces/ILogger.js';
|
|
6
|
+
/**
|
|
7
|
+
* Standard MCP tool result with content array
|
|
8
|
+
*/
|
|
9
|
+
interface ToolResult {
|
|
10
|
+
content: Array<{
|
|
11
|
+
type: string;
|
|
12
|
+
text?: string;
|
|
13
|
+
uri?: string;
|
|
14
|
+
mimeType?: string;
|
|
15
|
+
resource?: {
|
|
16
|
+
uri: string;
|
|
17
|
+
text?: string;
|
|
18
|
+
blob?: string;
|
|
19
|
+
mimeType?: string;
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
export declare class SharePointErrorHandler {
|
|
24
|
+
/**
|
|
25
|
+
* Handle SharePoint API errors and return appropriate MCP responses
|
|
26
|
+
* @param error - The error from axios/API call
|
|
27
|
+
* @param logger - Logger instance for error tracking
|
|
28
|
+
* @param toolName - Name of the tool for logging context
|
|
29
|
+
* @returns ToolResult for authentication errors, throws McpError for others
|
|
30
|
+
*/
|
|
31
|
+
static handle(error: any, logger: ILogger, toolName: string): ToolResult | never;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=SharePointErrorHandler.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SharePointErrorHandler
|
|
3
|
+
* Centralized error handling for SharePoint MCP tools
|
|
4
|
+
*/
|
|
5
|
+
import { McpError, McpErrorCode } from './McpErrorHandler.js';
|
|
6
|
+
export class SharePointErrorHandler {
|
|
7
|
+
/**
|
|
8
|
+
* Handle SharePoint API errors and return appropriate MCP responses
|
|
9
|
+
* @param error - The error from axios/API call
|
|
10
|
+
* @param logger - Logger instance for error tracking
|
|
11
|
+
* @param toolName - Name of the tool for logging context
|
|
12
|
+
* @returns ToolResult for authentication errors, throws McpError for others
|
|
13
|
+
*/
|
|
14
|
+
static handle(error, logger, toolName) {
|
|
15
|
+
// Extract only serializable error details for logging to avoid circular reference issues
|
|
16
|
+
const sanitizedError = {
|
|
17
|
+
message: error?.message,
|
|
18
|
+
status: error?.response?.status,
|
|
19
|
+
statusText: error?.response?.statusText,
|
|
20
|
+
data: error?.response?.data,
|
|
21
|
+
url: error?.config?.url
|
|
22
|
+
};
|
|
23
|
+
logger.error(toolName, 'SharePoint operation failed', '', sanitizedError);
|
|
24
|
+
const serverError = error?.response?.data;
|
|
25
|
+
// Handle OAuth authentication required (user-delegated flow)
|
|
26
|
+
if (error?.response?.status === 401 && serverError?.error === 'AUTH_REQUIRED') {
|
|
27
|
+
const userMessage = serverError.message || 'To access SharePoint, please login then continue your conversation.';
|
|
28
|
+
// loginUrl can be in serverError directly or in details (check both)
|
|
29
|
+
const loginUrl = serverError.loginUrl || serverError.details?.loginUrl;
|
|
30
|
+
return {
|
|
31
|
+
content: [
|
|
32
|
+
{
|
|
33
|
+
type: 'text',
|
|
34
|
+
text: userMessage
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'text',
|
|
38
|
+
text: loginUrl
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// Handle not found errors
|
|
44
|
+
if (error?.response?.status === 404) {
|
|
45
|
+
throw new McpError(McpErrorCode.InvalidParams, 'SharePoint resource not found');
|
|
46
|
+
}
|
|
47
|
+
// Handle authorization errors (403 or other 401s)
|
|
48
|
+
if (error?.response?.status === 401 || error?.response?.status === 403) {
|
|
49
|
+
throw new McpError(McpErrorCode.InvalidParams, 'Not authorized to access this SharePoint resource');
|
|
50
|
+
}
|
|
51
|
+
// Handle all other errors
|
|
52
|
+
throw new McpError(McpErrorCode.InternalError, `SharePoint operation failed: ${error?.message || 'Unknown error'}`, { originalError: error?.message });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=SharePointErrorHandler.js.map
|