@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.
Files changed (198) hide show
  1. package/dist/clients/UcmLocalApiClient.d.ts +175 -2
  2. package/dist/clients/UcmLocalApiClient.js +203 -3
  3. package/dist/index.js +1 -1
  4. package/dist/mcp-server/clients/UcmLocalApiClient.d.ts +399 -0
  5. package/dist/mcp-server/clients/UcmLocalApiClient.js +719 -0
  6. package/dist/mcp-server/index.d.ts +3 -0
  7. package/dist/mcp-server/index.js +68 -0
  8. package/dist/mcp-server/interfaces/ILogger.d.ts +8 -0
  9. package/dist/mcp-server/interfaces/ILogger.js +4 -0
  10. package/dist/mcp-server/interfaces/IMcpTool.d.ts +7 -0
  11. package/dist/mcp-server/interfaces/IMcpTool.js +3 -0
  12. package/dist/mcp-server/logging/ConsoleLogger.d.ts +16 -0
  13. package/dist/mcp-server/logging/ConsoleLogger.js +45 -0
  14. package/dist/mcp-server/logging/LoggerFactory.d.ts +9 -0
  15. package/dist/mcp-server/logging/LoggerFactory.js +12 -0
  16. package/dist/mcp-server/server/McpConfig.d.ts +26 -0
  17. package/dist/mcp-server/server/McpConfig.js +90 -0
  18. package/dist/mcp-server/server/McpHandler.d.ts +12 -0
  19. package/dist/mcp-server/server/McpHandler.js +84 -0
  20. package/dist/mcp-server/server/McpServer.d.ts +15 -0
  21. package/dist/mcp-server/server/McpServer.js +49 -0
  22. package/dist/mcp-server/server/ToolRegistry.d.ts +23 -0
  23. package/dist/mcp-server/server/ToolRegistry.js +169 -0
  24. package/dist/mcp-server/tools/authorization/ListAuthorizationsTool.d.ts +21 -0
  25. package/dist/mcp-server/tools/authorization/ListAuthorizationsTool.js +146 -0
  26. package/dist/mcp-server/tools/authorization/SignOutTool.d.ts +23 -0
  27. package/dist/mcp-server/tools/authorization/SignOutTool.js +128 -0
  28. package/dist/mcp-server/tools/base/BaseToolController.d.ts +19 -0
  29. package/dist/mcp-server/tools/base/BaseToolController.js +58 -0
  30. package/dist/mcp-server/tools/connections/AccessConnectionTool.d.ts +21 -0
  31. package/dist/mcp-server/tools/connections/AccessConnectionTool.js +107 -0
  32. package/dist/mcp-server/tools/connections/CallRemoteToolTool.d.ts +22 -0
  33. package/dist/mcp-server/tools/connections/CallRemoteToolTool.js +124 -0
  34. package/dist/mcp-server/tools/core/DeleteArtifactTool.d.ts +11 -0
  35. package/dist/mcp-server/tools/core/DeleteArtifactTool.js +83 -0
  36. package/dist/mcp-server/tools/core/EditArtifactMetadataTool.d.ts +12 -0
  37. package/dist/mcp-server/tools/core/EditArtifactMetadataTool.js +173 -0
  38. package/dist/mcp-server/tools/core/GetArtifactTool.d.ts +13 -0
  39. package/dist/mcp-server/tools/core/GetArtifactTool.js +124 -0
  40. package/dist/mcp-server/tools/core/GetArtifactVersionsTool.d.ts +11 -0
  41. package/dist/mcp-server/tools/core/GetArtifactVersionsTool.js +63 -0
  42. package/dist/mcp-server/tools/core/GetChunkTool.d.ts +11 -0
  43. package/dist/mcp-server/tools/core/GetChunkTool.js +56 -0
  44. package/dist/mcp-server/tools/core/ListArtifactsTool.d.ts +11 -0
  45. package/dist/mcp-server/tools/core/ListArtifactsTool.js +84 -0
  46. package/dist/mcp-server/tools/core/MoveArtifactTool.d.ts +12 -0
  47. package/dist/mcp-server/tools/core/MoveArtifactTool.js +104 -0
  48. package/dist/mcp-server/tools/core/PublishArtifactFromFileTool.d.ts +15 -0
  49. package/dist/mcp-server/tools/core/PublishArtifactFromFileTool.js +277 -0
  50. package/dist/mcp-server/tools/core/PublishArtifactTool.d.ts +13 -0
  51. package/dist/mcp-server/tools/core/PublishArtifactTool.js +218 -0
  52. package/dist/mcp-server/tools/core/SearchArtifactsTool.d.ts +11 -0
  53. package/dist/mcp-server/tools/core/SearchArtifactsTool.js +137 -0
  54. package/dist/mcp-server/tools/list/ListNamespaceController.d.ts +1 -0
  55. package/dist/mcp-server/tools/list/ListNamespaceController.js +8 -0
  56. package/dist/mcp-server/tools/memory-graph/GraphCreateEntitiesTool.d.ts +14 -0
  57. package/dist/mcp-server/tools/memory-graph/GraphCreateEntitiesTool.js +58 -0
  58. package/dist/mcp-server/tools/memory-graph/GraphCreateRelationshipsTool.d.ts +14 -0
  59. package/dist/mcp-server/tools/memory-graph/GraphCreateRelationshipsTool.js +57 -0
  60. package/dist/mcp-server/tools/memory-graph/GraphCreateTool.d.ts +14 -0
  61. package/dist/mcp-server/tools/memory-graph/GraphCreateTool.js +64 -0
  62. package/dist/mcp-server/tools/memory-graph/GraphDeleteEntitiesTool.d.ts +14 -0
  63. package/dist/mcp-server/tools/memory-graph/GraphDeleteEntitiesTool.js +45 -0
  64. package/dist/mcp-server/tools/memory-graph/GraphDeleteRelationshipsTool.d.ts +14 -0
  65. package/dist/mcp-server/tools/memory-graph/GraphDeleteRelationshipsTool.js +45 -0
  66. package/dist/mcp-server/tools/memory-graph/GraphExploreTool.d.ts +14 -0
  67. package/dist/mcp-server/tools/memory-graph/GraphExploreTool.js +73 -0
  68. package/dist/mcp-server/tools/memory-graph/GraphFindEntitiesTool.d.ts +14 -0
  69. package/dist/mcp-server/tools/memory-graph/GraphFindEntitiesTool.js +68 -0
  70. package/dist/mcp-server/tools/memory-graph/GraphFindPathsTool.d.ts +14 -0
  71. package/dist/mcp-server/tools/memory-graph/GraphFindPathsTool.js +62 -0
  72. package/dist/mcp-server/tools/memory-graph/GraphGetEntityTool.d.ts +14 -0
  73. package/dist/mcp-server/tools/memory-graph/GraphGetEntityTool.js +49 -0
  74. package/dist/mcp-server/tools/memory-graph/GraphGetRelationshipsTool.d.ts +14 -0
  75. package/dist/mcp-server/tools/memory-graph/GraphGetRelationshipsTool.js +62 -0
  76. package/dist/mcp-server/tools/memory-graph/GraphListTemplatesTool.d.ts +14 -0
  77. package/dist/mcp-server/tools/memory-graph/GraphListTemplatesTool.js +34 -0
  78. package/dist/mcp-server/tools/memory-graph/GraphListTool.d.ts +14 -0
  79. package/dist/mcp-server/tools/memory-graph/GraphListTool.js +45 -0
  80. package/dist/mcp-server/tools/memory-graph/GraphOpenTool.d.ts +15 -0
  81. package/dist/mcp-server/tools/memory-graph/GraphOpenTool.js +50 -0
  82. package/dist/mcp-server/tools/memory-graph/GraphProposeVocabularyTool.d.ts +14 -0
  83. package/dist/mcp-server/tools/memory-graph/GraphProposeVocabularyTool.js +108 -0
  84. package/dist/mcp-server/tools/memory-graph/GraphSearchTool.d.ts +14 -0
  85. package/dist/mcp-server/tools/memory-graph/GraphSearchTool.js +94 -0
  86. package/dist/mcp-server/tools/memory-graph/GraphTraverseTool.d.ts +14 -0
  87. package/dist/mcp-server/tools/memory-graph/GraphTraverseTool.js +114 -0
  88. package/dist/mcp-server/tools/memory-graph/GraphUpdateEntitiesTool.d.ts +14 -0
  89. package/dist/mcp-server/tools/memory-graph/GraphUpdateEntitiesTool.js +58 -0
  90. package/dist/mcp-server/tools/memory-graph/KnowledgeSetListTool.d.ts +14 -0
  91. package/dist/mcp-server/tools/memory-graph/KnowledgeSetListTool.js +25 -0
  92. package/dist/mcp-server/tools/memory-graph/KnowledgeSetOpenTool.d.ts +14 -0
  93. package/dist/mcp-server/tools/memory-graph/KnowledgeSetOpenTool.js +31 -0
  94. package/dist/mcp-server/tools/repository/CreateRepositoryTool.d.ts +12 -0
  95. package/dist/mcp-server/tools/repository/CreateRepositoryTool.js +116 -0
  96. package/dist/mcp-server/tools/repository/GetRepositoryTool.d.ts +12 -0
  97. package/dist/mcp-server/tools/repository/GetRepositoryTool.js +85 -0
  98. package/dist/mcp-server/tools/repository/UpdateRepositoryTool.d.ts +12 -0
  99. package/dist/mcp-server/tools/repository/UpdateRepositoryTool.js +115 -0
  100. package/dist/mcp-server/tools/sharepoint/SharePointListConnectionsTool.d.ts +19 -0
  101. package/dist/mcp-server/tools/sharepoint/SharePointListConnectionsTool.js +90 -0
  102. package/dist/mcp-server/tools/sharepoint/SharePointListFoldersTool.d.ts +21 -0
  103. package/dist/mcp-server/tools/sharepoint/SharePointListFoldersTool.js +133 -0
  104. package/dist/mcp-server/tools/sharepoint/SharePointReadFileTool.d.ts +22 -0
  105. package/dist/mcp-server/tools/sharepoint/SharePointReadFileTool.js +146 -0
  106. package/dist/mcp-server/tools/sharepoint/SharePointReadRelatedFileTool.d.ts +18 -0
  107. package/dist/mcp-server/tools/sharepoint/SharePointReadRelatedFileTool.js +108 -0
  108. package/dist/mcp-server/tools/sharepoint/SharePointSearchTool.d.ts +22 -0
  109. package/dist/mcp-server/tools/sharepoint/SharePointSearchTool.js +125 -0
  110. package/dist/mcp-server/tools/utility/AuthorIndexTool.d.ts +11 -0
  111. package/dist/mcp-server/tools/utility/AuthorIndexTool.js +49 -0
  112. package/dist/mcp-server/tools/utility/AuthorRecentsTool.d.ts +11 -0
  113. package/dist/mcp-server/tools/utility/AuthorRecentsTool.js +49 -0
  114. package/dist/mcp-server/tools/utility/ListRepositoriesTool.d.ts +11 -0
  115. package/dist/mcp-server/tools/utility/ListRepositoriesTool.js +68 -0
  116. package/dist/mcp-server/tools/utility/QuickstartTool.d.ts +11 -0
  117. package/dist/mcp-server/tools/utility/QuickstartTool.js +36 -0
  118. package/dist/mcp-server/types/UcmApiTypes.d.ts +40 -0
  119. package/dist/mcp-server/types/UcmApiTypes.js +4 -0
  120. package/dist/mcp-server/utils/McpErrorHandler.d.ts +25 -0
  121. package/dist/mcp-server/utils/McpErrorHandler.js +67 -0
  122. package/dist/mcp-server/utils/PathUtils.d.ts +61 -0
  123. package/dist/mcp-server/utils/PathUtils.js +178 -0
  124. package/dist/mcp-server/utils/ResponseChunker.d.ts +25 -0
  125. package/dist/mcp-server/utils/ResponseChunker.js +79 -0
  126. package/dist/mcp-server/utils/SharePointErrorHandler.d.ts +34 -0
  127. package/dist/mcp-server/utils/SharePointErrorHandler.js +55 -0
  128. package/dist/schemas/memory-graph-tool-schemas.d.ts +789 -0
  129. package/dist/schemas/memory-graph-tool-schemas.js +181 -0
  130. package/dist/server/ToolRegistry.js +42 -8
  131. package/dist/tools/authorization/ListAuthorizationsTool.js +2 -2
  132. package/dist/tools/authorization/SignOutTool.js +2 -2
  133. package/dist/tools/connections/AccessConnectionTool.js +8 -6
  134. package/dist/tools/connections/CallRemoteToolTool.js +4 -4
  135. package/dist/tools/core/DeleteArtifactTool.js +5 -4
  136. package/dist/tools/core/EditArtifactMetadataTool.js +1 -1
  137. package/dist/tools/core/GetArtifactTool.js +1 -1
  138. package/dist/tools/core/GetArtifactVersionsTool.js +1 -1
  139. package/dist/tools/core/GetChunkTool.js +1 -1
  140. package/dist/tools/core/ListArtifactsTool.js +1 -1
  141. package/dist/tools/core/MoveArtifactTool.js +1 -1
  142. package/dist/tools/core/PublishArtifactFromFileTool.js +1 -1
  143. package/dist/tools/core/PublishArtifactTool.js +2 -2
  144. package/dist/tools/core/SearchArtifactsTool.js +7 -6
  145. package/dist/tools/memory-graph/GraphCreateEntitiesTool.d.ts +11 -0
  146. package/dist/tools/memory-graph/GraphCreateEntitiesTool.js +56 -0
  147. package/dist/tools/memory-graph/GraphCreateRelationshipsTool.d.ts +11 -0
  148. package/dist/tools/memory-graph/GraphCreateRelationshipsTool.js +55 -0
  149. package/dist/tools/memory-graph/GraphCreateTool.d.ts +11 -0
  150. package/dist/tools/memory-graph/GraphCreateTool.js +62 -0
  151. package/dist/tools/memory-graph/GraphDeleteEntitiesTool.d.ts +11 -0
  152. package/dist/tools/memory-graph/GraphDeleteEntitiesTool.js +43 -0
  153. package/dist/tools/memory-graph/GraphDeleteRelationshipsTool.d.ts +11 -0
  154. package/dist/tools/memory-graph/GraphDeleteRelationshipsTool.js +43 -0
  155. package/dist/tools/memory-graph/GraphExploreTool.d.ts +11 -0
  156. package/dist/tools/memory-graph/GraphExploreTool.js +71 -0
  157. package/dist/tools/memory-graph/GraphFindEntitiesTool.d.ts +11 -0
  158. package/dist/tools/memory-graph/GraphFindEntitiesTool.js +66 -0
  159. package/dist/tools/memory-graph/GraphFindPathsTool.d.ts +11 -0
  160. package/dist/tools/memory-graph/GraphFindPathsTool.js +60 -0
  161. package/dist/tools/memory-graph/GraphGetEntityTool.d.ts +11 -0
  162. package/dist/tools/memory-graph/GraphGetEntityTool.js +47 -0
  163. package/dist/tools/memory-graph/GraphGetRelationshipsTool.d.ts +11 -0
  164. package/dist/tools/memory-graph/GraphGetRelationshipsTool.js +60 -0
  165. package/dist/tools/memory-graph/GraphGetStatsTool.d.ts +11 -0
  166. package/dist/tools/memory-graph/GraphGetStatsTool.js +42 -0
  167. package/dist/tools/memory-graph/GraphListTemplatesTool.d.ts +11 -0
  168. package/dist/tools/memory-graph/GraphListTemplatesTool.js +32 -0
  169. package/dist/tools/memory-graph/GraphListTool.d.ts +11 -0
  170. package/dist/tools/memory-graph/GraphListTool.js +43 -0
  171. package/dist/tools/memory-graph/GraphOpenTool.d.ts +12 -0
  172. package/dist/tools/memory-graph/GraphOpenTool.js +48 -0
  173. package/dist/tools/memory-graph/GraphProposeVocabularyTool.d.ts +11 -0
  174. package/dist/tools/memory-graph/GraphProposeVocabularyTool.js +104 -0
  175. package/dist/tools/memory-graph/GraphRemoveRelationshipsTool.d.ts +11 -0
  176. package/dist/tools/memory-graph/GraphRemoveRelationshipsTool.js +47 -0
  177. package/dist/tools/memory-graph/GraphSearchTool.d.ts +11 -0
  178. package/dist/tools/memory-graph/GraphSearchTool.js +92 -0
  179. package/dist/tools/memory-graph/GraphTraverseTool.d.ts +11 -0
  180. package/dist/tools/memory-graph/GraphTraverseTool.js +112 -0
  181. package/dist/tools/memory-graph/GraphUpdateEntitiesTool.d.ts +11 -0
  182. package/dist/tools/memory-graph/GraphUpdateEntitiesTool.js +56 -0
  183. package/dist/tools/memory-graph/KnowledgeSetListTool.d.ts +11 -0
  184. package/dist/tools/memory-graph/KnowledgeSetListTool.js +23 -0
  185. package/dist/tools/memory-graph/KnowledgeSetOpenTool.d.ts +11 -0
  186. package/dist/tools/memory-graph/KnowledgeSetOpenTool.js +29 -0
  187. package/dist/tools/repository/CreateRepositoryTool.js +10 -9
  188. package/dist/tools/repository/GetRepositoryTool.js +15 -15
  189. package/dist/tools/repository/UpdateRepositoryTool.js +10 -9
  190. package/dist/tools/sharepoint/SharePointListConnectionsTool.js +1 -1
  191. package/dist/tools/sharepoint/SharePointListFoldersTool.js +1 -1
  192. package/dist/tools/utility/AuthorIndexTool.js +6 -5
  193. package/dist/tools/utility/AuthorRecentsTool.js +6 -5
  194. package/dist/tools/utility/HealthCheckController.js +1 -1
  195. package/dist/tools/utility/ListRepositoriesTool.js +5 -4
  196. package/dist/utils/McpErrorHandler.js +1 -1
  197. package/package.json +1 -1
  198. package/package.json.backup +1 -1
@@ -0,0 +1,719 @@
1
+ import axios from 'axios';
2
+ export class UcmLocalApiClient {
3
+ baseUrl;
4
+ authToken;
5
+ authorId;
6
+ client;
7
+ constructor(baseUrl, authToken, timeout = 600000, authorId) {
8
+ this.baseUrl = baseUrl;
9
+ this.authToken = authToken;
10
+ this.authorId = authorId;
11
+ this.client = axios.create({
12
+ baseURL: this.baseUrl,
13
+ timeout,
14
+ headers: {
15
+ 'Content-Type': 'application/json',
16
+ ...(authToken && { 'Authorization': `Bearer ${authToken}` })
17
+ }
18
+ });
19
+ this.setupInterceptors();
20
+ }
21
+ setupInterceptors() {
22
+ this.client.interceptors.response.use((response) => response, (error) => {
23
+ // For 4xx and 5xx errors, preserve the full error object so calling code
24
+ // can access error.response.data.details (e.g., for loginUrl in auth errors)
25
+ if (error.response && error.response.status >= 400) {
26
+ // Pass through the full axios error - don't wrap it
27
+ return Promise.reject(error);
28
+ }
29
+ // For other errors (network, timeout, etc.), preserve original error
30
+ return Promise.reject(error);
31
+ });
32
+ }
33
+ ensureClient() {
34
+ if (!this.client) {
35
+ throw new Error('UcmApiClient has been cleaned up and is no longer available');
36
+ }
37
+ return this.client;
38
+ }
39
+ async getAuthors() {
40
+ const client = this.ensureClient();
41
+ const response = await client.get('/api/v1/authors');
42
+ return response.data;
43
+ }
44
+ async getAuthor(authorId) {
45
+ // No individual author endpoint - get from authors list
46
+ const authors = await this.getAuthors();
47
+ return authors.find(author => author.id === authorId) || null;
48
+ }
49
+ buildApiPath(api, author, repository, category, subcategory, filename, version) {
50
+ let path = `/api/v1/${api}`;
51
+ if (author) {
52
+ path += `/${author}`;
53
+ }
54
+ else {
55
+ return path;
56
+ }
57
+ if (repository) {
58
+ path += `/${repository}`;
59
+ }
60
+ else {
61
+ return path;
62
+ }
63
+ if (category) {
64
+ path += `/${category}`;
65
+ }
66
+ else {
67
+ return path;
68
+ }
69
+ if (subcategory) {
70
+ path += `/${subcategory}`;
71
+ }
72
+ else {
73
+ return path;
74
+ }
75
+ if (filename) {
76
+ path += `/${filename}`;
77
+ }
78
+ else {
79
+ return path;
80
+ }
81
+ if (version) {
82
+ path += `@${version}`;
83
+ }
84
+ else {
85
+ return path;
86
+ }
87
+ return path;
88
+ }
89
+ async getArtifact(author, repository, category, subcategory, filename, version) {
90
+ // Default repository to 'main' for MVP
91
+ const repo = repository || 'main';
92
+ let metadataApiPath = this.buildApiPath('authors', author, repo, category, subcategory, filename, version);
93
+ // First get metadata from authors endpoint
94
+ const client = this.ensureClient();
95
+ const metadataResponse = await client.get(metadataApiPath);
96
+ const metadata = metadataResponse.data;
97
+ if (filename) {
98
+ let fileApiPath = this.buildApiPath('files', author, repo, category, subcategory, filename, version);
99
+ // Then get actual file content from files endpoint
100
+ let contentResponse = await client.get(fileApiPath, {
101
+ headers: { 'accept': metadataResponse.data }
102
+ });
103
+ return {
104
+ ...metadata.data,
105
+ content: contentResponse.data
106
+ };
107
+ }
108
+ // Combine metadata and content
109
+ return {
110
+ ...metadata.data,
111
+ };
112
+ }
113
+ async getLatestArtifact(author, repository, category, subcategory, filename) {
114
+ // Default repository to 'main' for MVP
115
+ const repo = repository || 'main';
116
+ let metadataApiPath = this.buildApiPath('authors', author, repo, category, subcategory, filename);
117
+ const client = this.ensureClient();
118
+ const response = await client.get(metadataApiPath);
119
+ return response.data;
120
+ }
121
+ async listArtifacts(author, repository, category, subcategory, offset, limit) {
122
+ const params = new URLSearchParams();
123
+ if (offset !== undefined)
124
+ params.append('offset', offset.toString());
125
+ if (limit !== undefined)
126
+ params.append('limit', limit.toString());
127
+ const queryString = params.toString();
128
+ // Build URL based on provided parameters for exploratory browsing
129
+ // Default repository to 'main' for MVP
130
+ const repo = repository;
131
+ let metadataApiPath = this.buildApiPath('authors', author, repo, category, subcategory);
132
+ metadataApiPath += queryString ? `?${queryString}` : '';
133
+ const client = this.ensureClient();
134
+ const response = await client.get(metadataApiPath);
135
+ return response.data; // response.data contains the full structured response with pagination
136
+ }
137
+ async searchArtifacts(filters = {}) {
138
+ const params = new URLSearchParams();
139
+ // Default repository to 'main' for MVP if not specified
140
+ if (!filters.repository) {
141
+ filters.repository = 'main';
142
+ }
143
+ Object.entries(filters).forEach(([key, value]) => {
144
+ if (value !== undefined)
145
+ params.append(key, value.toString());
146
+ });
147
+ const client = this.ensureClient();
148
+ const response = await client.get(`/api/v1/artifacts?${params}`);
149
+ return response.data;
150
+ }
151
+ async searchArtifactsByText(searchParams) {
152
+ const params = new URLSearchParams();
153
+ // Add all parameters to URL
154
+ Object.entries(searchParams).forEach(([key, value]) => {
155
+ if (value !== undefined)
156
+ params.append(key, value.toString());
157
+ });
158
+ const client = this.ensureClient();
159
+ const response = await client.get(`/api/v1/search/artifacts?${params}`);
160
+ return response.data;
161
+ }
162
+ async publishArtifact(author, repository, category, subcategory, data) {
163
+ // Default repository to 'main' for MVP
164
+ const repo = repository || 'main';
165
+ // Build query parameters from the data object
166
+ const params = new URLSearchParams();
167
+ if (data.queryParams) {
168
+ // New API structure with query params
169
+ Object.entries(data.queryParams).forEach(([key, value]) => {
170
+ // Skip if value is undefined, null, empty string, or string "null"/"undefined"
171
+ if (value !== undefined && value !== null && value !== '' && value !== 'null' && value !== 'undefined') {
172
+ // Handle arrays (e.g., tags) by JSON stringifying them
173
+ if (Array.isArray(value)) {
174
+ params.append(key, JSON.stringify(value));
175
+ }
176
+ else {
177
+ params.append(key, String(value));
178
+ }
179
+ }
180
+ });
181
+ // Send raw content as text/plain body
182
+ const client = this.ensureClient();
183
+ const response = await client.post(`/api/v1/authors/${author}/${repo}/${category}/${subcategory}?${params.toString()}`, data.content, {
184
+ headers: {
185
+ 'Content-Type': 'text/plain'
186
+ }
187
+ });
188
+ return response.data;
189
+ }
190
+ else {
191
+ // Legacy API structure (for backward compatibility)
192
+ const client = this.ensureClient();
193
+ const response = await client.post(`/api/v1/authors/${author}/${repo}/${category}/${subcategory}`, data);
194
+ return response.data;
195
+ }
196
+ }
197
+ async updateArtifact(author, repository, category, subcategory, filename, version, data) {
198
+ // Default repository to 'main' for MVP
199
+ const repo = repository || 'main';
200
+ // Build query parameters from the data object
201
+ const params = new URLSearchParams();
202
+ if (data.queryParams) {
203
+ // New API structure with query params
204
+ Object.entries(data.queryParams).forEach(([key, value]) => {
205
+ // Skip if value is undefined, null, empty string, or string "null"/"undefined"
206
+ if (value !== undefined && value !== null && value !== '' && value !== 'null' && value !== 'undefined') {
207
+ // Handle arrays (e.g., tags) by JSON stringifying them
208
+ if (Array.isArray(value)) {
209
+ params.append(key, JSON.stringify(value));
210
+ }
211
+ else {
212
+ params.append(key, String(value));
213
+ }
214
+ }
215
+ });
216
+ // Send raw content as text/plain body
217
+ const client = this.ensureClient();
218
+ const response = await client.put(`/api/v1/authors/${author}/${repo}/${category}/${subcategory}/${filename}@${version}?${params.toString()}`, data.content, {
219
+ headers: {
220
+ 'Content-Type': 'text/plain'
221
+ }
222
+ });
223
+ return response.data;
224
+ }
225
+ else {
226
+ // Legacy API structure (for backward compatibility)
227
+ const client = this.ensureClient();
228
+ const response = await client.put(`/api/v1/authors/${author}/${repo}/${category}/${subcategory}/${filename}@${version}`, data);
229
+ return response.data;
230
+ }
231
+ }
232
+ async deleteArtifact(author, repository, category, subcategory, filename, version) {
233
+ // Default repository to 'main' for MVP
234
+ const repo = repository || 'main';
235
+ const url = version
236
+ ? `/api/v1/authors/${author}/${repo}/${category}/${subcategory}/${filename}@${version}`
237
+ : `/api/v1/authors/${author}/${repo}/${category}/${subcategory}/${filename}`;
238
+ const client = this.ensureClient();
239
+ const response = await client.delete(url);
240
+ return response.data;
241
+ }
242
+ async getArtifactVersions(author, repository, category, subcategory, filename) {
243
+ // Default repository to 'main' for MVP
244
+ const repo = repository || 'main';
245
+ const client = this.ensureClient();
246
+ const response = await client.get(`/api/v1/authors/${author}/${repo}/${category}/${subcategory}/${filename}/versions`);
247
+ return response.data;
248
+ }
249
+ async getCategories() {
250
+ // Categories are derived from artifacts since there's no dedicated endpoint
251
+ // Return the standard UCM categories
252
+ return ['commands', 'services', 'patterns', 'implementations', 'contracts', 'guidance', 'project'];
253
+ }
254
+ async healthCheck() {
255
+ const client = this.ensureClient();
256
+ const response = await client.get('/api/v1/health');
257
+ return response.data;
258
+ }
259
+ async getQuickstart() {
260
+ const client = this.ensureClient();
261
+ const response = await client.get('/api/v1/quickstart', {
262
+ headers: { 'accept': 'text/markdown' }
263
+ });
264
+ return response.data;
265
+ }
266
+ async getAuthorIndex(author, repository) {
267
+ const client = this.ensureClient();
268
+ let url;
269
+ if (repository) {
270
+ // Repository-specific index (future use)
271
+ url = `/api/v1/authors/${author}/${repository}/index`;
272
+ }
273
+ else {
274
+ // Author-level index
275
+ url = `/api/v1/authors/${author}/index`;
276
+ }
277
+ const response = await client.get(url, {
278
+ headers: { 'accept': 'text/markdown' }
279
+ });
280
+ return response.data;
281
+ }
282
+ async getAuthorRecents(author) {
283
+ const client = this.ensureClient();
284
+ // Author-level recent activity (using new resources API structure)
285
+ const url = `/api/v1/resources/author/${author}/recents`;
286
+ const response = await client.get(url, {
287
+ headers: { 'accept': 'text/markdown' }
288
+ });
289
+ return response.data;
290
+ }
291
+ /**
292
+ * Cleanup method to properly dispose of HTTP client resources
293
+ * This helps prevent memory leaks from accumulated AbortSignal listeners
294
+ */
295
+ cleanup() {
296
+ if (this.client) {
297
+ // Clear interceptors to remove event listeners
298
+ this.client.interceptors.request.clear();
299
+ this.client.interceptors.response.clear();
300
+ // Set client to null to let GC handle cleanup
301
+ this.client = null;
302
+ }
303
+ }
304
+ /**
305
+ * Check if the client is still available for use
306
+ */
307
+ isAvailable() {
308
+ return this.client !== null;
309
+ }
310
+ // Repository Management Methods
311
+ async createRepository(author, data) {
312
+ const client = this.ensureClient();
313
+ const response = await client.post(`/api/v1/authors/${author}`, data);
314
+ return response.data;
315
+ }
316
+ async getRepository(author, repository) {
317
+ const client = this.ensureClient();
318
+ const response = await client.get(`/api/v1/authors/${author}/${repository}`);
319
+ return response.data;
320
+ }
321
+ async updateRepository(author, repository, data) {
322
+ const client = this.ensureClient();
323
+ const response = await client.put(`/api/v1/authors/${author}/${repository}`, data);
324
+ return response.data;
325
+ }
326
+ async deleteRepository(author, repository) {
327
+ const client = this.ensureClient();
328
+ const response = await client.delete(`/api/v1/authors/${author}/${repository}`);
329
+ return response.data;
330
+ }
331
+ async listRepositories(author, offset, limit) {
332
+ const params = new URLSearchParams();
333
+ if (offset !== undefined)
334
+ params.append('offset', offset.toString());
335
+ if (limit !== undefined)
336
+ params.append('limit', limit.toString());
337
+ const queryString = params.toString();
338
+ const url = `/api/v1/authors/${author}${queryString ? `?${queryString}` : ''}`;
339
+ const client = this.ensureClient();
340
+ const response = await client.get(url);
341
+ return response.data;
342
+ }
343
+ async submitFeedback(data) {
344
+ const client = this.ensureClient();
345
+ const response = await client.post('/api/v1/feedback', data);
346
+ return response.data;
347
+ }
348
+ async editArtifactMetadata(author, repository, category, subcategory, filename, data) {
349
+ const client = this.ensureClient();
350
+ const url = this.buildApiPath('authors', author, repository, category, subcategory, filename) + '/edit';
351
+ // Transform updateTags from comma-separated string to array for API
352
+ const requestData = { ...data };
353
+ if (data.updateTags && typeof data.updateTags === 'string') {
354
+ // Parse comma-separated tags into array, trim whitespace, filter empty strings
355
+ requestData.updateTags = data.updateTags
356
+ .split(',')
357
+ .map(tag => tag.trim())
358
+ .filter(tag => tag.length > 0);
359
+ }
360
+ const response = await client.post(url, requestData);
361
+ return response.data;
362
+ }
363
+ // SharePoint API methods
364
+ /**
365
+ * List External Connections including SharePoint
366
+ * Returns markdown with a table of connections available
367
+ */
368
+ async listExternalConnections(params) {
369
+ const client = this.ensureClient();
370
+ const url = `/api/v1/connections`;
371
+ const response = await client.get(url, { params });
372
+ return response.data;
373
+ }
374
+ /**
375
+ * Access a specific external connection
376
+ * Returns connection details, auth status, and available tool schemas
377
+ * Connection type is auto-detected by the server from the connectionId
378
+ */
379
+ async accessConnection(connectionId, toolNames) {
380
+ const client = this.ensureClient();
381
+ const params = {};
382
+ if (toolNames && toolNames.length > 0) {
383
+ params.toolNames = toolNames.join(',');
384
+ }
385
+ const response = await client.get(`/api/v1/connections/${connectionId}`, { params });
386
+ return response.data;
387
+ }
388
+ /**
389
+ * Call a tool on an external connection
390
+ * Executes a tool on a SharePoint connection or Remote MCP Server
391
+ * Connection type is auto-detected by the server from the connectionId
392
+ */
393
+ async callRemoteTool(connectionId, toolName, args) {
394
+ const client = this.ensureClient();
395
+ const body = { toolName };
396
+ if (args !== undefined) {
397
+ body.args = args;
398
+ }
399
+ const response = await client.post(`/api/v1/connections/${connectionId}/tools`, body);
400
+ return response.data;
401
+ }
402
+ /**
403
+ * Search SharePoint documents using Microsoft Search API
404
+ * Uses V1 API - organizationId is auto-detected from auth token
405
+ */
406
+ async sharePointSearch(connectionId, params) {
407
+ const client = this.ensureClient();
408
+ const response = await client.post(`/api/v1/connections/sharepoint/search`, {
409
+ connectionId,
410
+ ...params
411
+ });
412
+ return response.data;
413
+ }
414
+ /**
415
+ * List folders and files in SharePoint with pagination
416
+ * Uses V1 API - organizationId is auto-detected from auth token
417
+ */
418
+ async sharePointListFolders(connectionId, params) {
419
+ const client = this.ensureClient();
420
+ const response = await client.post(`/api/v1/connections/sharepoint/folders`, {
421
+ connectionId,
422
+ ...params
423
+ });
424
+ return response.data;
425
+ }
426
+ /**
427
+ * Read SharePoint file content with support for both fileUrl and legacy fileId
428
+ * Uses V1 API - organizationId is auto-detected from auth token
429
+ */
430
+ async sharePointReadFile(connectionId, params) {
431
+ const client = this.ensureClient();
432
+ const response = await client.post(`/api/v1/connections/sharepoint/read`, {
433
+ connectionId,
434
+ ...params
435
+ });
436
+ return response.data;
437
+ }
438
+ /**
439
+ * Read SharePoint related file (image/embedded file extracted from document)
440
+ * Uses V1 API - organizationId is auto-detected from auth token
441
+ * Accepts full URI from markdown (with or without protocol prefix)
442
+ * Returns complete file content (no pagination support)
443
+ */
444
+ async sharePointReadRelatedFile(uri) {
445
+ const client = this.ensureClient();
446
+ const response = await client.post(`/api/v1/connections/sharepoint/related-file`, { uri }, // Pass URI in JSON body
447
+ {
448
+ responseType: 'arraybuffer' // Binary data
449
+ });
450
+ // Convert binary response to base64 for MCP transport
451
+ const base64Content = Buffer.from(response.data).toString('base64');
452
+ const contentType = response.headers['content-type'] || 'application/octet-stream';
453
+ const contentLength = parseInt(response.headers['content-length'] || '0', 10);
454
+ // Extract fileName from URI for response metadata
455
+ const fileName = this.extractFileNameFromUri(uri);
456
+ return {
457
+ fileName,
458
+ mimeType: contentType,
459
+ size: contentLength,
460
+ content: base64Content
461
+ };
462
+ }
463
+ /**
464
+ * Extract fileName from SharePoint related file URI
465
+ * Helper method for metadata purposes
466
+ */
467
+ extractFileNameFromUri(uri) {
468
+ // Strip protocol prefix if present
469
+ const cleaned = uri.replace(/^ucm_sharepoint_read_relatedfile:\/\//, '');
470
+ // Extract path portion before query string
471
+ const pathPart = cleaned.split('?')[0];
472
+ // URL-decode the fileName
473
+ return decodeURIComponent(pathPart);
474
+ }
475
+ /**
476
+ * Revoke SharePoint OnBehalfOf authorization for a connection
477
+ * Deletes user's access tokens from Key Vault and database
478
+ * Uses V1 API - organizationId is auto-detected from auth token
479
+ * @deprecated Use signOut with connectionType='sharepoint' instead
480
+ */
481
+ async sharePointSignOut(connectionId) {
482
+ const client = this.ensureClient();
483
+ const response = await client.post(`/api/v1/connections/sharepoint/signout`, { connectionId });
484
+ return response.data;
485
+ }
486
+ /**
487
+ * Unified OAuth sign out for any connection type
488
+ * Revokes user's OAuth authorization by deleting tokens from Key Vault and database
489
+ * @param connectionType - Type of connection: 'sharepoint' | 'remote-mcp'
490
+ * @param connectionId - Connection ID to revoke authorization for
491
+ */
492
+ async signOut(connectionType, connectionId) {
493
+ const client = this.ensureClient();
494
+ // Route to appropriate endpoint based on connection type
495
+ if (connectionType === 'sharepoint') {
496
+ const response = await client.post(`/api/v1/connections/sharepoint/signout`, { connectionId });
497
+ return response.data;
498
+ }
499
+ else if (connectionType === 'remote-mcp') {
500
+ // Remote MCP uses the oauth signout endpoint
501
+ const response = await client.post(`/api/v1/oauth/signout`, { connectionType, connectionId });
502
+ return response.data;
503
+ }
504
+ throw new Error(`Unsupported connection type: ${connectionType}`);
505
+ }
506
+ /**
507
+ * List all user's active OAuth authorizations
508
+ * @param connectionType - Optional filter: 'sharepoint' | 'remote-mcp' | 'all' (default: 'all')
509
+ */
510
+ async listAuthorizations(connectionType) {
511
+ const client = this.ensureClient();
512
+ const params = connectionType && connectionType !== 'all' ? { connectionType } : {};
513
+ const response = await client.get('/api/v1/oauth/authorizations', { params });
514
+ return response.data;
515
+ }
516
+ // ─── Memory Graph API Methods ───────────────────────────────────────
517
+ /**
518
+ * List memory graphs, optionally filtered by scope
519
+ * @param scope - 'organization' | 'personal' | 'all' (default: 'all')
520
+ */
521
+ async listMemoryGraphs(scope) {
522
+ const client = this.ensureClient();
523
+ const params = {};
524
+ if (scope && scope !== 'all') {
525
+ params.scope = scope;
526
+ }
527
+ const response = await client.get(`/api/v1/memory-graphs`, { params });
528
+ return response.data;
529
+ }
530
+ /**
531
+ * Create a new Memory Graph for the authenticated user
532
+ */
533
+ async createMemoryGraph(data) {
534
+ const client = this.ensureClient();
535
+ const response = await client.post(`/api/v1/memory-graphs`, data);
536
+ return response.data;
537
+ }
538
+ /**
539
+ * List available vocabulary templates for Memory Graph creation
540
+ */
541
+ async listMemoryGraphTemplates() {
542
+ const client = this.ensureClient();
543
+ const response = await client.get(`/api/v1/memory-graphs/templates`);
544
+ return response.data;
545
+ }
546
+ /**
547
+ * Semantic vector search across multiple Memory Graphs
548
+ */
549
+ async graphSearchMultiple(query, options) {
550
+ const client = this.ensureClient();
551
+ const response = await client.post(`/api/v1/memory-graphs/search`, {
552
+ query,
553
+ ...options
554
+ });
555
+ return response.data;
556
+ }
557
+ /**
558
+ * List knowledge sets for an organization
559
+ */
560
+ async listKnowledgeSets() {
561
+ const client = this.ensureClient();
562
+ const response = await client.get(`/api/v1/knowledge-sets`);
563
+ return response.data;
564
+ }
565
+ /**
566
+ * List knowledge set summary (markdown) for an organization
567
+ */
568
+ async listKnowledgeSetSummary() {
569
+ const client = this.ensureClient();
570
+ const response = await client.get(`/api/v1/knowledge-sets/summary`);
571
+ return response.data.markdown;
572
+ }
573
+ /**
574
+ * Open a knowledge set — returns markdown summary with contents and tool guidance
575
+ */
576
+ async openKnowledgeSet(knowledgeSetId) {
577
+ const client = this.ensureClient();
578
+ const response = await client.get(`/api/v1/knowledge-sets/${knowledgeSetId}/summary`);
579
+ return response.data.markdown;
580
+ }
581
+ /**
582
+ * Open a memory graph — returns vocabulary, stats, instructions, policies, and metadata
583
+ */
584
+ async graphOpen(graphId) {
585
+ const client = this.ensureClient();
586
+ const response = await client.post(`/api/v1/memory-graphs/${graphId}/open`);
587
+ return response.data;
588
+ }
589
+ /**
590
+ * Find entities with filters and pagination
591
+ */
592
+ async graphFindEntities(graphId, query) {
593
+ const client = this.ensureClient();
594
+ const response = await client.post(`/api/v1/memory-graphs/${graphId}/entities/find`, query);
595
+ return response.data;
596
+ }
597
+ /**
598
+ * Get a single entity by ID
599
+ */
600
+ async graphGetEntity(graphId, entityId, detailLevel) {
601
+ const client = this.ensureClient();
602
+ const params = {};
603
+ if (detailLevel)
604
+ params.detailLevel = detailLevel;
605
+ const response = await client.get(`/api/v1/memory-graphs/${graphId}/entities/${entityId}`, { params });
606
+ return response.data;
607
+ }
608
+ /**
609
+ * Get relationships for an entity
610
+ */
611
+ async graphGetRelationships(graphId, entityId, options) {
612
+ const client = this.ensureClient();
613
+ const params = {};
614
+ if (options?.direction)
615
+ params.direction = options.direction;
616
+ if (options?.relationshipTypes)
617
+ params.relationshipTypes = options.relationshipTypes.join(',');
618
+ if (options?.limit)
619
+ params.limit = String(options.limit);
620
+ const response = await client.get(`/api/v1/memory-graphs/${graphId}/entities/${entityId}/relationships`, { params });
621
+ return response.data;
622
+ }
623
+ /**
624
+ * Explore neighbourhood around an entity (BFS, 1-3 hops)
625
+ */
626
+ async graphExplore(graphId, options) {
627
+ const client = this.ensureClient();
628
+ const response = await client.post(`/api/v1/memory-graphs/${graphId}/explore`, options);
629
+ return response.data;
630
+ }
631
+ /**
632
+ * Find paths between two entities
633
+ */
634
+ async graphFindPaths(graphId, options) {
635
+ const client = this.ensureClient();
636
+ const response = await client.post(`/api/v1/memory-graphs/${graphId}/find-paths`, options);
637
+ return response.data;
638
+ }
639
+ /**
640
+ * Structured graph traversal with a JSON spec
641
+ */
642
+ async graphTraverse(graphId, spec) {
643
+ const client = this.ensureClient();
644
+ const response = await client.post(`/api/v1/memory-graphs/${graphId}/traverse`, spec);
645
+ return response.data;
646
+ }
647
+ /**
648
+ * Semantic vector search on entity embeddings
649
+ */
650
+ async graphSearch(graphId, query, options) {
651
+ const client = this.ensureClient();
652
+ const response = await client.post(`/api/v1/memory-graphs/${graphId}/search`, {
653
+ query,
654
+ ...options
655
+ });
656
+ return response.data;
657
+ }
658
+ /**
659
+ * Create one or more entities
660
+ */
661
+ async graphCreateEntities(graphId, entities) {
662
+ const client = this.ensureClient();
663
+ const response = await client.post(`/api/v1/memory-graphs/${graphId}/entities`, { entities });
664
+ return response.data;
665
+ }
666
+ /**
667
+ * Update one or more entities
668
+ */
669
+ async graphUpdateEntities(graphId, updates) {
670
+ const client = this.ensureClient();
671
+ const response = await client.put(`/api/v1/memory-graphs/${graphId}/entities`, { updates });
672
+ return response.data;
673
+ }
674
+ /**
675
+ * Delete one or more entities
676
+ */
677
+ async graphDeleteEntities(graphId, entityIds) {
678
+ const client = this.ensureClient();
679
+ const response = await client.delete(`/api/v1/memory-graphs/${graphId}/entities`, {
680
+ data: { entityIds }
681
+ });
682
+ return response.data;
683
+ }
684
+ /**
685
+ * Create one or more relationships
686
+ */
687
+ async graphCreateRelationships(graphId, relationships) {
688
+ const client = this.ensureClient();
689
+ const response = await client.post(`/api/v1/memory-graphs/${graphId}/relationships`, { relationships });
690
+ return response.data;
691
+ }
692
+ /**
693
+ * Delete one or more relationships
694
+ */
695
+ async graphDeleteRelationships(graphId, relationshipIds) {
696
+ const client = this.ensureClient();
697
+ const response = await client.delete(`/api/v1/memory-graphs/${graphId}/relationships`, {
698
+ data: { relationshipIds }
699
+ });
700
+ return response.data;
701
+ }
702
+ /**
703
+ * Delete an entire memory graph (SQL record + CosmosDB repository)
704
+ */
705
+ async graphDelete(graphId) {
706
+ const client = this.ensureClient();
707
+ const response = await client.delete(`/api/v1/memory-graphs/${graphId}`);
708
+ return response.data;
709
+ }
710
+ /**
711
+ * Propose vocabulary extensions (entity types / relationship types)
712
+ */
713
+ async graphProposeVocabulary(graphId, proposals) {
714
+ const client = this.ensureClient();
715
+ const response = await client.post(`/api/v1/memory-graphs/${graphId}/vocabulary/propose`, proposals);
716
+ return response.data;
717
+ }
718
+ }
719
+ //# sourceMappingURL=UcmLocalApiClient.js.map