@elliotding/ai-agent-mcp 0.1.24 → 0.1.26

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 (233) hide show
  1. package/README.md +27 -0
  2. package/package.json +4 -1
  3. package/.prompt-cache/cmd-cmd-client-sdk-ai-hub-generate-testcase.md +0 -101
  4. package/.prompt-cache/cmd-cmd-client-sdk-ai-hub-submit_zct_job.md +0 -158
  5. package/.prompt-cache/skill-skill-client-sdk-ai-hub-analyze-conf-status.md +0 -311
  6. package/.prompt-cache/skill-skill-client-sdk-ai-hub-analyze-sdk-log.md +0 -64
  7. package/.prompt-cache/skill-skill-client-sdk-ai-hub-analyze-zmb-log-errors.md +0 -84
  8. package/ai-resource-telemetry.json +0 -40
  9. package/dist/api/cached-client.d.ts +0 -48
  10. package/dist/api/cached-client.d.ts.map +0 -1
  11. package/dist/api/cached-client.js +0 -126
  12. package/dist/api/cached-client.js.map +0 -1
  13. package/dist/api/client.d.ts +0 -281
  14. package/dist/api/client.d.ts.map +0 -1
  15. package/dist/api/client.js +0 -371
  16. package/dist/api/client.js.map +0 -1
  17. package/dist/auth/index.d.ts +0 -8
  18. package/dist/auth/index.d.ts.map +0 -1
  19. package/dist/auth/index.js +0 -26
  20. package/dist/auth/index.js.map +0 -1
  21. package/dist/auth/middleware.d.ts +0 -36
  22. package/dist/auth/middleware.d.ts.map +0 -1
  23. package/dist/auth/middleware.js +0 -194
  24. package/dist/auth/middleware.js.map +0 -1
  25. package/dist/auth/permissions.d.ts +0 -60
  26. package/dist/auth/permissions.d.ts.map +0 -1
  27. package/dist/auth/permissions.js +0 -262
  28. package/dist/auth/permissions.js.map +0 -1
  29. package/dist/auth/token-validator.d.ts +0 -52
  30. package/dist/auth/token-validator.d.ts.map +0 -1
  31. package/dist/auth/token-validator.js +0 -215
  32. package/dist/auth/token-validator.js.map +0 -1
  33. package/dist/cache/cache-manager.d.ts +0 -49
  34. package/dist/cache/cache-manager.d.ts.map +0 -1
  35. package/dist/cache/cache-manager.js +0 -191
  36. package/dist/cache/cache-manager.js.map +0 -1
  37. package/dist/cache/index.d.ts +0 -6
  38. package/dist/cache/index.d.ts.map +0 -1
  39. package/dist/cache/index.js +0 -12
  40. package/dist/cache/index.js.map +0 -1
  41. package/dist/cache/redis-client.d.ts +0 -45
  42. package/dist/cache/redis-client.d.ts.map +0 -1
  43. package/dist/cache/redis-client.js +0 -210
  44. package/dist/cache/redis-client.js.map +0 -1
  45. package/dist/config/constants.d.ts +0 -28
  46. package/dist/config/constants.d.ts.map +0 -1
  47. package/dist/config/constants.js +0 -31
  48. package/dist/config/constants.js.map +0 -1
  49. package/dist/config/index.d.ts +0 -71
  50. package/dist/config/index.d.ts.map +0 -1
  51. package/dist/config/index.js +0 -190
  52. package/dist/config/index.js.map +0 -1
  53. package/dist/filesystem/manager.d.ts +0 -45
  54. package/dist/filesystem/manager.d.ts.map +0 -1
  55. package/dist/filesystem/manager.js +0 -246
  56. package/dist/filesystem/manager.js.map +0 -1
  57. package/dist/git/multi-source-manager.d.ts +0 -78
  58. package/dist/git/multi-source-manager.d.ts.map +0 -1
  59. package/dist/git/multi-source-manager.js +0 -577
  60. package/dist/git/multi-source-manager.js.map +0 -1
  61. package/dist/git/operations.d.ts +0 -27
  62. package/dist/git/operations.d.ts.map +0 -1
  63. package/dist/git/operations.js +0 -83
  64. package/dist/git/operations.js.map +0 -1
  65. package/dist/index.d.ts +0 -6
  66. package/dist/index.d.ts.map +0 -1
  67. package/dist/index.js +0 -122
  68. package/dist/index.js.map +0 -1
  69. package/dist/monitoring/health.d.ts +0 -35
  70. package/dist/monitoring/health.d.ts.map +0 -1
  71. package/dist/monitoring/health.js +0 -105
  72. package/dist/monitoring/health.js.map +0 -1
  73. package/dist/prompts/cache.d.ts +0 -69
  74. package/dist/prompts/cache.d.ts.map +0 -1
  75. package/dist/prompts/cache.js +0 -163
  76. package/dist/prompts/cache.js.map +0 -1
  77. package/dist/prompts/generator.d.ts +0 -49
  78. package/dist/prompts/generator.d.ts.map +0 -1
  79. package/dist/prompts/generator.js +0 -160
  80. package/dist/prompts/generator.js.map +0 -1
  81. package/dist/prompts/index.d.ts +0 -13
  82. package/dist/prompts/index.d.ts.map +0 -1
  83. package/dist/prompts/index.js +0 -24
  84. package/dist/prompts/index.js.map +0 -1
  85. package/dist/prompts/manager.d.ts +0 -169
  86. package/dist/prompts/manager.d.ts.map +0 -1
  87. package/dist/prompts/manager.js +0 -488
  88. package/dist/prompts/manager.js.map +0 -1
  89. package/dist/resources/index.d.ts +0 -6
  90. package/dist/resources/index.d.ts.map +0 -1
  91. package/dist/resources/index.js +0 -10
  92. package/dist/resources/index.js.map +0 -1
  93. package/dist/resources/loader.d.ts +0 -88
  94. package/dist/resources/loader.d.ts.map +0 -1
  95. package/dist/resources/loader.js +0 -492
  96. package/dist/resources/loader.js.map +0 -1
  97. package/dist/server/http.d.ts +0 -57
  98. package/dist/server/http.d.ts.map +0 -1
  99. package/dist/server/http.js +0 -435
  100. package/dist/server/http.js.map +0 -1
  101. package/dist/server.d.ts +0 -13
  102. package/dist/server.d.ts.map +0 -1
  103. package/dist/server.js +0 -200
  104. package/dist/server.js.map +0 -1
  105. package/dist/session/manager.d.ts +0 -91
  106. package/dist/session/manager.d.ts.map +0 -1
  107. package/dist/session/manager.js +0 -251
  108. package/dist/session/manager.js.map +0 -1
  109. package/dist/telemetry/index.d.ts +0 -3
  110. package/dist/telemetry/index.d.ts.map +0 -1
  111. package/dist/telemetry/index.js +0 -7
  112. package/dist/telemetry/index.js.map +0 -1
  113. package/dist/telemetry/manager.d.ts +0 -151
  114. package/dist/telemetry/manager.d.ts.map +0 -1
  115. package/dist/telemetry/manager.js +0 -367
  116. package/dist/telemetry/manager.js.map +0 -1
  117. package/dist/tools/index.d.ts +0 -12
  118. package/dist/tools/index.d.ts.map +0 -1
  119. package/dist/tools/index.js +0 -28
  120. package/dist/tools/index.js.map +0 -1
  121. package/dist/tools/manage-subscription.d.ts +0 -47
  122. package/dist/tools/manage-subscription.d.ts.map +0 -1
  123. package/dist/tools/manage-subscription.js +0 -314
  124. package/dist/tools/manage-subscription.js.map +0 -1
  125. package/dist/tools/registry.d.ts +0 -40
  126. package/dist/tools/registry.d.ts.map +0 -1
  127. package/dist/tools/registry.js +0 -85
  128. package/dist/tools/registry.js.map +0 -1
  129. package/dist/tools/search-resources.d.ts +0 -35
  130. package/dist/tools/search-resources.d.ts.map +0 -1
  131. package/dist/tools/search-resources.js +0 -159
  132. package/dist/tools/search-resources.js.map +0 -1
  133. package/dist/tools/sync-resources.d.ts +0 -54
  134. package/dist/tools/sync-resources.d.ts.map +0 -1
  135. package/dist/tools/sync-resources.js +0 -733
  136. package/dist/tools/sync-resources.js.map +0 -1
  137. package/dist/tools/track-usage.d.ts +0 -63
  138. package/dist/tools/track-usage.d.ts.map +0 -1
  139. package/dist/tools/track-usage.js +0 -90
  140. package/dist/tools/track-usage.js.map +0 -1
  141. package/dist/tools/uninstall-resource.d.ts +0 -30
  142. package/dist/tools/uninstall-resource.d.ts.map +0 -1
  143. package/dist/tools/uninstall-resource.js +0 -174
  144. package/dist/tools/uninstall-resource.js.map +0 -1
  145. package/dist/tools/upload-resource.d.ts +0 -81
  146. package/dist/tools/upload-resource.d.ts.map +0 -1
  147. package/dist/tools/upload-resource.js +0 -393
  148. package/dist/tools/upload-resource.js.map +0 -1
  149. package/dist/transport/sse.d.ts +0 -29
  150. package/dist/transport/sse.d.ts.map +0 -1
  151. package/dist/transport/sse.js +0 -271
  152. package/dist/transport/sse.js.map +0 -1
  153. package/dist/types/errors.d.ts +0 -60
  154. package/dist/types/errors.d.ts.map +0 -1
  155. package/dist/types/errors.js +0 -112
  156. package/dist/types/errors.js.map +0 -1
  157. package/dist/types/index.d.ts +0 -7
  158. package/dist/types/index.d.ts.map +0 -1
  159. package/dist/types/index.js +0 -23
  160. package/dist/types/index.js.map +0 -1
  161. package/dist/types/mcp.d.ts +0 -50
  162. package/dist/types/mcp.d.ts.map +0 -1
  163. package/dist/types/mcp.js +0 -6
  164. package/dist/types/mcp.js.map +0 -1
  165. package/dist/types/resources.d.ts +0 -109
  166. package/dist/types/resources.d.ts.map +0 -1
  167. package/dist/types/resources.js +0 -7
  168. package/dist/types/resources.js.map +0 -1
  169. package/dist/types/tools.d.ts +0 -235
  170. package/dist/types/tools.d.ts.map +0 -1
  171. package/dist/types/tools.js +0 -6
  172. package/dist/types/tools.js.map +0 -1
  173. package/dist/utils/cursor-paths.d.ts +0 -84
  174. package/dist/utils/cursor-paths.d.ts.map +0 -1
  175. package/dist/utils/cursor-paths.js +0 -166
  176. package/dist/utils/cursor-paths.js.map +0 -1
  177. package/dist/utils/log-cleaner.d.ts +0 -18
  178. package/dist/utils/log-cleaner.d.ts.map +0 -1
  179. package/dist/utils/log-cleaner.js +0 -112
  180. package/dist/utils/log-cleaner.js.map +0 -1
  181. package/dist/utils/logger.d.ts +0 -59
  182. package/dist/utils/logger.d.ts.map +0 -1
  183. package/dist/utils/logger.js +0 -292
  184. package/dist/utils/logger.js.map +0 -1
  185. package/dist/utils/validation.d.ts +0 -58
  186. package/dist/utils/validation.d.ts.map +0 -1
  187. package/dist/utils/validation.js +0 -214
  188. package/dist/utils/validation.js.map +0 -1
  189. package/src/api/cached-client.ts +0 -144
  190. package/src/api/client.ts +0 -697
  191. package/src/auth/index.ts +0 -11
  192. package/src/auth/middleware.ts +0 -244
  193. package/src/auth/permissions.ts +0 -323
  194. package/src/auth/token-validator.ts +0 -292
  195. package/src/cache/cache-manager.ts +0 -243
  196. package/src/cache/index.ts +0 -6
  197. package/src/cache/redis-client.ts +0 -249
  198. package/src/config/constants.ts +0 -33
  199. package/src/config/index.ts +0 -269
  200. package/src/filesystem/manager.ts +0 -235
  201. package/src/git/multi-source-manager.ts +0 -654
  202. package/src/git/operations.ts +0 -93
  203. package/src/index.ts +0 -157
  204. package/src/monitoring/health.ts +0 -132
  205. package/src/prompts/cache.ts +0 -140
  206. package/src/prompts/generator.ts +0 -143
  207. package/src/prompts/index.ts +0 -20
  208. package/src/prompts/manager.ts +0 -613
  209. package/src/resources/index.ts +0 -13
  210. package/src/resources/loader.ts +0 -563
  211. package/src/server/http.ts +0 -549
  212. package/src/server.ts +0 -204
  213. package/src/session/manager.ts +0 -296
  214. package/src/telemetry/index.ts +0 -10
  215. package/src/telemetry/manager.ts +0 -419
  216. package/src/tools/index.ts +0 -12
  217. package/src/tools/manage-subscription.ts +0 -385
  218. package/src/tools/registry.ts +0 -97
  219. package/src/tools/search-resources.ts +0 -185
  220. package/src/tools/sync-resources.ts +0 -827
  221. package/src/tools/track-usage.ts +0 -113
  222. package/src/tools/uninstall-resource.ts +0 -199
  223. package/src/tools/upload-resource.ts +0 -431
  224. package/src/transport/sse.ts +0 -308
  225. package/src/types/errors.ts +0 -146
  226. package/src/types/index.ts +0 -7
  227. package/src/types/mcp.ts +0 -61
  228. package/src/types/resources.ts +0 -141
  229. package/src/types/tools.ts +0 -284
  230. package/src/utils/cursor-paths.ts +0 -135
  231. package/src/utils/log-cleaner.ts +0 -92
  232. package/src/utils/logger.ts +0 -333
  233. package/src/utils/validation.ts +0 -262
@@ -1,314 +0,0 @@
1
- "use strict";
2
- /**
3
- * manage_subscription Tool
4
- * Manage resource subscriptions
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.manageSubscriptionTool = void 0;
8
- exports.manageSubscription = manageSubscription;
9
- const logger_1 = require("../utils/logger");
10
- const client_1 = require("../api/client");
11
- const errors_1 = require("../types/errors");
12
- const sync_resources_1 = require("./sync-resources");
13
- const uninstall_resource_1 = require("./uninstall-resource");
14
- const index_js_1 = require("../prompts/index.js");
15
- async function manageSubscription(params) {
16
- const startTime = Date.now();
17
- // Type assertion for params
18
- const typedParams = params;
19
- logger_1.logger.info({ tool: 'manage_subscription', params }, 'manage_subscription called');
20
- try {
21
- let result;
22
- switch (typedParams.action) {
23
- case 'subscribe': {
24
- // Validate resource_ids
25
- if (!typedParams.resource_ids || typedParams.resource_ids.length === 0) {
26
- throw (0, errors_1.createValidationError)('resource_ids', 'array', 'resource_ids is required for subscribe action');
27
- }
28
- logger_1.logger.debug({ resourceIds: typedParams.resource_ids, autoSync: typedParams.auto_sync }, 'Subscribing to resources...');
29
- // Subscribe to resources
30
- const subResult = await client_1.apiClient.subscribe(typedParams.resource_ids, typedParams.auto_sync, undefined, typedParams.user_token);
31
- logger_1.logger.info({ count: subResult.subscriptions.length }, 'Resources subscribed successfully');
32
- // Auto-sync newly subscribed resources immediately (default: true)
33
- const shouldAutoSync = typedParams.auto_sync !== false;
34
- let syncSummary;
35
- let syncDetails;
36
- let pendingSetup;
37
- if (shouldAutoSync && subResult.subscriptions.length > 0) {
38
- logger_1.logger.info({ resourceIds: typedParams.resource_ids }, 'Auto-syncing newly subscribed resources...');
39
- const syncResult = await (0, sync_resources_1.syncResources)({
40
- mode: 'incremental',
41
- scope: typedParams.scope || 'global',
42
- user_token: typedParams.user_token,
43
- });
44
- if (syncResult.success && syncResult.data) {
45
- const sd = syncResult.data;
46
- syncSummary = `Auto-sync: ${sd.summary.synced} synced, ${sd.summary.cached} cached, ${sd.summary.failed} failed`;
47
- syncDetails = sd.details.map(d => ({ id: d.id, name: d.name, action: d.action }));
48
- if (sd.pending_setup && sd.pending_setup.length > 0) {
49
- pendingSetup = sd.pending_setup;
50
- }
51
- logger_1.logger.info({ summary: sd.summary }, 'Auto-sync after subscribe completed');
52
- }
53
- else {
54
- logger_1.logger.warn({ error: syncResult.error }, 'Auto-sync after subscribe failed, subscription still recorded');
55
- syncSummary = 'Auto-sync failed — run sync_resources manually if needed';
56
- }
57
- }
58
- result = {
59
- action: 'subscribe',
60
- success: true,
61
- subscriptions: subResult.subscriptions.map(sub => ({
62
- id: sub.id,
63
- name: sub.name,
64
- type: sub.type,
65
- subscribed_at: sub.subscribed_at,
66
- })),
67
- message: [
68
- `Successfully subscribed to ${subResult.subscriptions.length} resource${subResult.subscriptions.length > 1 ? 's' : ''}.`,
69
- syncSummary,
70
- ].filter(Boolean).join(' '),
71
- ...(syncDetails ? { sync_details: syncDetails } : {}),
72
- ...(pendingSetup ? { pending_setup: pendingSetup } : {}),
73
- };
74
- break;
75
- }
76
- case 'unsubscribe': {
77
- // Validate resource_ids
78
- if (!typedParams.resource_ids || typedParams.resource_ids.length === 0) {
79
- throw (0, errors_1.createValidationError)('resource_ids', 'array', 'resource_ids is required for unsubscribe action');
80
- }
81
- logger_1.logger.debug({ resourceIds: typedParams.resource_ids }, 'Unsubscribing from resources...');
82
- // Build a resource_id → type map from the current subscription list so
83
- // uninstall actions can be scoped precisely to rule vs mcp resources.
84
- let idToType = new Map();
85
- try {
86
- const currentSubs = await client_1.apiClient.getSubscriptions({}, typedParams.user_token);
87
- for (const s of currentSubs.subscriptions) {
88
- idToType.set(s.id, s.type);
89
- }
90
- }
91
- catch (e) {
92
- logger_1.logger.warn({ error: e.message }, 'Could not fetch subscriptions for type resolution — uninstall will emit both rule+mcp actions as fallback');
93
- }
94
- // Cancel server-side subscription
95
- await client_1.apiClient.unsubscribe(typedParams.resource_ids, typedParams.user_token);
96
- logger_1.logger.info({ count: typedParams.resource_ids.length }, 'Server-side subscriptions removed');
97
- // Uninstall local files and MCP config for each resource.
98
- // For Command/Skill: unregister MCP Prompt instead of deleting local files.
99
- const uninstallResults = [];
100
- for (const resourceId of typedParams.resource_ids) {
101
- // Determine if this is a Command or Skill by checking the prompt registry.
102
- // API resource IDs are UUIDs (e.g. "0ccd800f..."), NOT prefixed with "cmd-"/"skill-".
103
- // Check whether any registered prompt for this user matches the resource_id.
104
- const matchedPromptName = index_js_1.promptManager.promptNames(typedParams.user_token ?? '').find((name) => {
105
- // Prompt names are "<type>/<resource_name>"; check by looking up the registered meta.
106
- const registered = index_js_1.promptManager.getByPromptName(name, typedParams.user_token ?? '');
107
- return registered?.meta?.resource_id === resourceId;
108
- });
109
- if (matchedPromptName) {
110
- const parts = matchedPromptName.split('/');
111
- const resourceType = (parts[0] ?? 'command');
112
- const resourceName = parts.slice(1).join('/') || matchedPromptName;
113
- index_js_1.promptManager.unregisterPrompt(resourceId, resourceType, resourceName, typedParams.user_token ?? '');
114
- uninstallResults.push({ id: resourceId, removed: true, detail: `Unregistered MCP Prompt for "${resourceName}"` });
115
- logger_1.logger.info({ resourceId, resourceType, matchedPromptName }, 'MCP Prompt unregistered on unsubscribe');
116
- continue;
117
- }
118
- // Use the last segment of the resource ID as the search pattern
119
- // e.g. "mcp-client-sdk-ai-hub-jenkins" → "jenkins"
120
- // "rule-csp-elliotTest" → "elliotTest"
121
- const namePart = resourceId.split('-').slice(-1)[0] ||
122
- resourceId.split('-').slice(-2).join('-') ||
123
- resourceId;
124
- // Try full name match first (e.g. "elliotTest"), fallback to last segment
125
- const patternsToTry = Array.from(new Set([
126
- resourceId, // full id
127
- resourceId.replace(/^(skill|cmd|rule|mcp)-[^-]+-/, ''), // strip prefix+source
128
- namePart,
129
- ]));
130
- const resolvedType = idToType.get(resourceId);
131
- let uninstalled = false;
132
- for (const pattern of patternsToTry) {
133
- const uninstallResult = await (0, uninstall_resource_1.uninstallResource)({
134
- resource_id_or_name: pattern,
135
- remove_from_account: false, // already unsubscribed above
136
- ...(resolvedType ? { resource_type: resolvedType } : {}),
137
- });
138
- if (uninstallResult.success && uninstallResult.data && uninstallResult.data.removed_resources.length > 0) {
139
- uninstallResults.push({ id: resourceId, removed: true, detail: `Removed local files for "${pattern}"` });
140
- uninstalled = true;
141
- break;
142
- }
143
- }
144
- if (!uninstalled) {
145
- uninstallResults.push({ id: resourceId, removed: false, detail: 'No local files found (may not have been installed)' });
146
- }
147
- }
148
- const removedCount = uninstallResults.filter(r => r.removed).length;
149
- const notFoundCount = uninstallResults.filter(r => !r.removed).length;
150
- result = {
151
- action: 'unsubscribe',
152
- success: true,
153
- message: [
154
- `Successfully unsubscribed from ${typedParams.resource_ids.length} resource${typedParams.resource_ids.length > 1 ? 's' : ''}.`,
155
- removedCount > 0 ? `Removed local files for ${removedCount} resource${removedCount > 1 ? 's' : ''}.` : null,
156
- notFoundCount > 0 ? `${notFoundCount} resource${notFoundCount > 1 ? 's were' : ' was'} not installed locally.` : null,
157
- ].filter(Boolean).join(' '),
158
- sync_details: uninstallResults.map(r => ({ id: r.id, name: r.id, action: r.removed ? 'uninstalled' : 'not_found_locally' })),
159
- };
160
- logger_1.logger.info({ count: typedParams.resource_ids.length, removedCount }, 'Resources unsubscribed and local files cleaned up');
161
- break;
162
- }
163
- case 'list': {
164
- logger_1.logger.debug({ scope: typedParams.scope || 'all' }, 'Listing subscriptions...');
165
- // Get subscriptions list
166
- const subs = await client_1.apiClient.getSubscriptions({}, typedParams.user_token);
167
- result = {
168
- action: 'list',
169
- success: true,
170
- subscriptions: subs.subscriptions.map(sub => ({
171
- id: sub.id,
172
- name: sub.name,
173
- type: sub.type,
174
- subscribed_at: sub.subscribed_at,
175
- })),
176
- message: `Found ${subs.total} subscription${subs.total !== 1 ? 's' : ''}`,
177
- };
178
- logger_1.logger.info({ total: subs.total }, 'Subscriptions listed successfully');
179
- break;
180
- }
181
- case 'batch_subscribe': {
182
- // Validate resource_ids
183
- if (!typedParams.resource_ids || typedParams.resource_ids.length === 0) {
184
- throw (0, errors_1.createValidationError)('resource_ids', 'array', 'resource_ids is required for batch_subscribe action');
185
- }
186
- logger_1.logger.debug({ count: typedParams.resource_ids.length, autoSync: typedParams.auto_sync }, 'Batch subscribing to resources...');
187
- const batchSubResult = await client_1.apiClient.subscribe(typedParams.resource_ids, typedParams.auto_sync, undefined, typedParams.user_token);
188
- logger_1.logger.info({ count: batchSubResult.subscriptions.length }, 'Batch subscription completed');
189
- // Auto-sync newly subscribed resources immediately (default: true)
190
- const shouldBatchAutoSync = typedParams.auto_sync !== false;
191
- let batchSyncSummary;
192
- let batchSyncDetails;
193
- let batchPendingSetup;
194
- if (shouldBatchAutoSync && batchSubResult.subscriptions.length > 0) {
195
- logger_1.logger.info({ count: batchSubResult.subscriptions.length }, 'Auto-syncing batch subscribed resources...');
196
- const batchSyncResult = await (0, sync_resources_1.syncResources)({
197
- mode: 'incremental',
198
- scope: typedParams.scope || 'global',
199
- user_token: typedParams.user_token,
200
- });
201
- if (batchSyncResult.success && batchSyncResult.data) {
202
- const sd = batchSyncResult.data;
203
- batchSyncSummary = `Auto-sync: ${sd.summary.synced} synced, ${sd.summary.cached} cached, ${sd.summary.failed} failed`;
204
- batchSyncDetails = sd.details.map(d => ({ id: d.id, name: d.name, action: d.action }));
205
- if (sd.pending_setup && sd.pending_setup.length > 0) {
206
- batchPendingSetup = sd.pending_setup;
207
- }
208
- }
209
- else {
210
- batchSyncSummary = 'Auto-sync failed — run sync_resources manually if needed';
211
- }
212
- }
213
- result = {
214
- action: 'batch_subscribe',
215
- success: true,
216
- subscriptions: batchSubResult.subscriptions.map(sub => ({
217
- id: sub.id,
218
- name: sub.name,
219
- type: sub.type,
220
- subscribed_at: sub.subscribed_at,
221
- })),
222
- message: [
223
- `Successfully batch subscribed to ${batchSubResult.subscriptions.length} resource${batchSubResult.subscriptions.length > 1 ? 's' : ''}.`,
224
- batchSyncSummary,
225
- ].filter(Boolean).join(' '),
226
- ...(batchSyncDetails ? { sync_details: batchSyncDetails } : {}),
227
- ...(batchPendingSetup ? { pending_setup: batchPendingSetup } : {}),
228
- };
229
- break;
230
- }
231
- case 'batch_unsubscribe': {
232
- // Validate resource_ids
233
- if (!typedParams.resource_ids || typedParams.resource_ids.length === 0) {
234
- throw (0, errors_1.createValidationError)('resource_ids', 'array', 'resource_ids is required for batch_unsubscribe action');
235
- }
236
- logger_1.logger.debug({ count: typedParams.resource_ids.length }, 'Batch unsubscribing from resources...');
237
- // Delegate entirely to the unsubscribe case for unified cleanup logic
238
- return manageSubscription({ ...typedParams, action: 'unsubscribe' });
239
- }
240
- default: {
241
- throw (0, errors_1.createValidationError)('action', 'string', `Unknown action. Must be one of: subscribe, unsubscribe, list, batch_subscribe, batch_unsubscribe`);
242
- }
243
- }
244
- const duration = Date.now() - startTime;
245
- (0, logger_1.logToolCall)('manage_subscription', 'user-id', params, duration);
246
- logger_1.logger.info({
247
- action: typedParams.action,
248
- duration,
249
- }, 'manage_subscription completed successfully');
250
- return {
251
- success: true,
252
- data: result,
253
- };
254
- }
255
- catch (error) {
256
- logger_1.logger.error({ error, action: typedParams.action }, 'manage_subscription failed');
257
- return {
258
- success: false,
259
- error: {
260
- code: error instanceof errors_1.MCPServerError ? error.code : 'UNKNOWN_ERROR',
261
- message: error instanceof Error ? error.message : String(error),
262
- },
263
- };
264
- }
265
- }
266
- // Tool definition for registry
267
- exports.manageSubscriptionTool = {
268
- name: 'manage_subscription',
269
- description: 'Manage resource subscriptions (subscribe, unsubscribe, list). ' +
270
- 'When action is "subscribe" or "batch_subscribe", the tool automatically syncs ' +
271
- 'the newly subscribed resources to the local machine immediately after subscribing ' +
272
- '(auto_sync defaults to true). Pass auto_sync: false only when the user explicitly ' +
273
- 'says they do NOT want the resource installed right now.',
274
- inputSchema: {
275
- type: 'object',
276
- properties: {
277
- action: {
278
- type: 'string',
279
- description: 'Action to perform',
280
- enum: ['subscribe', 'unsubscribe', 'list', 'batch_subscribe', 'batch_unsubscribe'],
281
- },
282
- resource_ids: {
283
- type: 'array',
284
- description: 'Resource IDs (required for subscribe/unsubscribe actions)',
285
- },
286
- auto_sync: {
287
- type: 'boolean',
288
- description: 'Whether to immediately sync (install) the subscribed resources to the local machine after subscribing. ' +
289
- 'Defaults to true — omit this field in normal usage. ' +
290
- 'Set to false only when the user explicitly says they want to subscribe but NOT install yet.',
291
- default: true,
292
- },
293
- scope: {
294
- type: 'string',
295
- description: 'Installation scope',
296
- enum: ['global', 'workspace'],
297
- default: 'global',
298
- },
299
- notify: {
300
- type: 'boolean',
301
- description: 'Enable update notifications',
302
- default: true,
303
- },
304
- user_token: {
305
- type: 'string',
306
- description: 'DO NOT set this field — it is automatically injected by the MCP server from ' +
307
- 'the authenticated SSE connection. The server always provides the correct token.',
308
- },
309
- },
310
- required: ['action'],
311
- },
312
- handler: manageSubscription,
313
- };
314
- //# sourceMappingURL=manage-subscription.js.map
@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D;IAC3D,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mBAAmB;gBAChC,IAAI,EAAE,CAAC,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,mBAAmB,CAAC;aACnF;YACD,YAAY,EAAE;gBACZ,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,2DAA2D;aACzE;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,SAAS;gBACf,WAAW,EACT,yGAAyG;oBACzG,sDAAsD;oBACtD,6FAA6F;gBAC/F,OAAO,EAAE,IAAI;aACd;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oBAAoB;gBACjC,IAAI,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC;gBAC7B,OAAO,EAAE,QAAQ;aAClB;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,6BAA6B;gBAC1C,OAAO,EAAE,IAAI;aACd;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,8EAA8E;oBAC9E,iFAAiF;aACpF;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;KACrB;IACD,OAAO,EAAE,kBAAkB;CAC5B,CAAC"}
@@ -1,40 +0,0 @@
1
- /**
2
- * Tool Registry
3
- * Central registry for MCP tools
4
- */
5
- import type { ToolDefinition } from '../types/tools';
6
- import type { MCPToolDefinition } from '../types/mcp';
7
- declare class ToolRegistry {
8
- private tools;
9
- /**
10
- * Register a tool
11
- */
12
- registerTool(tool: ToolDefinition): void;
13
- /**
14
- * Get a tool by name
15
- */
16
- getTool(name: string): ToolDefinition | undefined;
17
- /**
18
- * List all registered tools
19
- */
20
- listTools(): ToolDefinition[];
21
- /**
22
- * Get MCP tool definitions (for tools/list response)
23
- */
24
- getMCPToolDefinitions(): MCPToolDefinition[];
25
- /**
26
- * Check if a tool exists
27
- */
28
- hasTool(name: string): boolean;
29
- /**
30
- * Get tool count
31
- */
32
- getToolCount(): number;
33
- /**
34
- * Call a tool by name with arguments
35
- */
36
- callTool(name: string, args: Record<string, unknown>): Promise<unknown>;
37
- }
38
- export declare const toolRegistry: ToolRegistry;
39
- export {};
40
- //# sourceMappingURL=registry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,cAAM,YAAY;IAChB,OAAO,CAAC,KAAK,CAA0C;IAEvD;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IASxC;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAIjD;;OAEG;IACH,SAAS,IAAI,cAAc,EAAE;IAI7B;;OAEG;IACH,qBAAqB,IAAI,iBAAiB,EAAE;IAQ5C;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI9B;;OAEG;IACH,YAAY,IAAI,MAAM;IAItB;;OAEG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;CA2B9E;AAGD,eAAO,MAAM,YAAY,cAAqB,CAAC"}
@@ -1,85 +0,0 @@
1
- "use strict";
2
- /**
3
- * Tool Registry
4
- * Central registry for MCP tools
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.toolRegistry = void 0;
8
- const logger_1 = require("../utils/logger");
9
- class ToolRegistry {
10
- tools = new Map();
11
- /**
12
- * Register a tool
13
- */
14
- registerTool(tool) {
15
- if (this.tools.has(tool.name)) {
16
- throw new Error(`Tool '${tool.name}' is already registered`);
17
- }
18
- this.tools.set(tool.name, tool);
19
- logger_1.logger.info({ toolName: tool.name }, `Tool registered: ${tool.name}`);
20
- }
21
- /**
22
- * Get a tool by name
23
- */
24
- getTool(name) {
25
- return this.tools.get(name);
26
- }
27
- /**
28
- * List all registered tools
29
- */
30
- listTools() {
31
- return Array.from(this.tools.values());
32
- }
33
- /**
34
- * Get MCP tool definitions (for tools/list response)
35
- */
36
- getMCPToolDefinitions() {
37
- return this.listTools().map((tool) => ({
38
- name: tool.name,
39
- description: tool.description,
40
- inputSchema: tool.inputSchema,
41
- }));
42
- }
43
- /**
44
- * Check if a tool exists
45
- */
46
- hasTool(name) {
47
- return this.tools.has(name);
48
- }
49
- /**
50
- * Get tool count
51
- */
52
- getToolCount() {
53
- return this.tools.size;
54
- }
55
- /**
56
- * Call a tool by name with arguments
57
- */
58
- async callTool(name, args) {
59
- const tool = this.getTool(name);
60
- if (!tool) {
61
- throw new Error(`Tool '${name}' not found`);
62
- }
63
- logger_1.logger.debug({ toolName: name, args }, 'Calling tool');
64
- try {
65
- const result = await tool.handler(args);
66
- // Debug: Log the result structure
67
- logger_1.logger.debug({
68
- toolName: name,
69
- resultType: typeof result,
70
- resultKeys: result && typeof result === 'object' ? Object.keys(result) : undefined,
71
- hasSuccess: result && typeof result === 'object' && 'success' in result,
72
- hasData: result && typeof result === 'object' && 'data' in result,
73
- hasError: result && typeof result === 'object' && 'error' in result
74
- }, 'Tool execution result structure');
75
- return result;
76
- }
77
- catch (error) {
78
- logger_1.logger.error({ toolName: name, error, errorType: typeof error, errorMessage: error instanceof Error ? error.message : String(error) }, 'Tool execution threw error');
79
- throw error;
80
- }
81
- }
82
- }
83
- // Global singleton
84
- exports.toolRegistry = new ToolRegistry();
85
- //# sourceMappingURL=registry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tools/registry.ts"],"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AC;YACrK,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAED,mBAAmB;AACN,QAAA,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC"}
@@ -1,35 +0,0 @@
1
- /**
2
- * search_resources Tool
3
- * Search for available resources
4
- */
5
- import type { SearchResourcesResult, ToolResult } from '../types/tools';
6
- export declare function searchResources(params: unknown): Promise<ToolResult<SearchResourcesResult>>;
7
- export declare const searchResourcesTool: {
8
- name: string;
9
- description: string;
10
- inputSchema: {
11
- type: "object";
12
- properties: {
13
- team: {
14
- type: string;
15
- description: string;
16
- };
17
- type: {
18
- type: string;
19
- description: string;
20
- enum: string[];
21
- };
22
- keyword: {
23
- type: string;
24
- description: string;
25
- };
26
- user_token: {
27
- type: string;
28
- description: string;
29
- };
30
- };
31
- required: string[];
32
- };
33
- handler: typeof searchResources;
34
- };
35
- //# sourceMappingURL=search-resources.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"search-resources.d.ts","sourceRoot":"","sources":["../../src/tools/search-resources.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAyB,qBAAqB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AA8C/F,wBAAsB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC,CAgGjG;AAGD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6B/B,CAAC"}