@elliotding/ai-agent-mcp 0.1.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/api/cached-client.d.ts +48 -0
- package/dist/api/cached-client.d.ts.map +1 -0
- package/dist/api/cached-client.js +126 -0
- package/dist/api/cached-client.js.map +1 -0
- package/dist/api/client.d.ts +213 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +326 -0
- package/dist/api/client.js.map +1 -0
- package/dist/auth/index.d.ts +8 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +26 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/middleware.d.ts +36 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +194 -0
- package/dist/auth/middleware.js.map +1 -0
- package/dist/auth/permissions.d.ts +60 -0
- package/dist/auth/permissions.d.ts.map +1 -0
- package/dist/auth/permissions.js +256 -0
- package/dist/auth/permissions.js.map +1 -0
- package/dist/auth/token-validator.d.ts +52 -0
- package/dist/auth/token-validator.d.ts.map +1 -0
- package/dist/auth/token-validator.js +217 -0
- package/dist/auth/token-validator.js.map +1 -0
- package/dist/cache/cache-manager.d.ts +49 -0
- package/dist/cache/cache-manager.d.ts.map +1 -0
- package/dist/cache/cache-manager.js +191 -0
- package/dist/cache/cache-manager.js.map +1 -0
- package/dist/cache/index.d.ts +6 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +12 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/redis-client.d.ts +45 -0
- package/dist/cache/redis-client.d.ts.map +1 -0
- package/dist/cache/redis-client.js +210 -0
- package/dist/cache/redis-client.js.map +1 -0
- package/dist/config/constants.d.ts +28 -0
- package/dist/config/constants.d.ts.map +1 -0
- package/dist/config/constants.js +31 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/config/index.d.ts +54 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +168 -0
- package/dist/config/index.js.map +1 -0
- package/dist/filesystem/manager.d.ts +45 -0
- package/dist/filesystem/manager.d.ts.map +1 -0
- package/dist/filesystem/manager.js +246 -0
- package/dist/filesystem/manager.js.map +1 -0
- package/dist/git/multi-source-manager.d.ts +62 -0
- package/dist/git/multi-source-manager.d.ts.map +1 -0
- package/dist/git/multi-source-manager.js +293 -0
- package/dist/git/multi-source-manager.js.map +1 -0
- package/dist/git/operations.d.ts +27 -0
- package/dist/git/operations.d.ts.map +1 -0
- package/dist/git/operations.js +83 -0
- package/dist/git/operations.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +109 -0
- package/dist/index.js.map +1 -0
- package/dist/monitoring/health.d.ts +35 -0
- package/dist/monitoring/health.d.ts.map +1 -0
- package/dist/monitoring/health.js +105 -0
- package/dist/monitoring/health.js.map +1 -0
- package/dist/resources/index.d.ts +6 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +10 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/loader.d.ts +87 -0
- package/dist/resources/loader.d.ts.map +1 -0
- package/dist/resources/loader.js +452 -0
- package/dist/resources/loader.js.map +1 -0
- package/dist/server/http.d.ts +57 -0
- package/dist/server/http.d.ts.map +1 -0
- package/dist/server/http.js +336 -0
- package/dist/server/http.js.map +1 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +157 -0
- package/dist/server.js.map +1 -0
- package/dist/session/manager.d.ts +91 -0
- package/dist/session/manager.d.ts.map +1 -0
- package/dist/session/manager.js +251 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/tools/index.d.ts +11 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +27 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/manage-subscription.d.ts +43 -0
- package/dist/tools/manage-subscription.d.ts.map +1 -0
- package/dist/tools/manage-subscription.js +268 -0
- package/dist/tools/manage-subscription.js.map +1 -0
- package/dist/tools/registry.d.ts +40 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +85 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/search-resources.d.ts +31 -0
- package/dist/tools/search-resources.d.ts.map +1 -0
- package/dist/tools/search-resources.js +154 -0
- package/dist/tools/search-resources.js.map +1 -0
- package/dist/tools/sync-resources.d.ts +41 -0
- package/dist/tools/sync-resources.d.ts.map +1 -0
- package/dist/tools/sync-resources.js +606 -0
- package/dist/tools/sync-resources.js.map +1 -0
- package/dist/tools/uninstall-resource.d.ts +30 -0
- package/dist/tools/uninstall-resource.d.ts.map +1 -0
- package/dist/tools/uninstall-resource.js +259 -0
- package/dist/tools/uninstall-resource.js.map +1 -0
- package/dist/tools/upload-resource.d.ts +77 -0
- package/dist/tools/upload-resource.d.ts.map +1 -0
- package/dist/tools/upload-resource.js +252 -0
- package/dist/tools/upload-resource.js.map +1 -0
- package/dist/transport/sse.d.ts +29 -0
- package/dist/transport/sse.d.ts.map +1 -0
- package/dist/transport/sse.js +271 -0
- package/dist/transport/sse.js.map +1 -0
- package/dist/types/errors.d.ts +60 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +112 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +23 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/mcp.d.ts +50 -0
- package/dist/types/mcp.d.ts.map +1 -0
- package/dist/types/mcp.js +6 -0
- package/dist/types/mcp.js.map +1 -0
- package/dist/types/resources.d.ts +109 -0
- package/dist/types/resources.d.ts.map +1 -0
- package/dist/types/resources.js +7 -0
- package/dist/types/resources.js.map +1 -0
- package/dist/types/tools.d.ts +147 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +6 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/utils/cursor-paths.d.ts +49 -0
- package/dist/utils/cursor-paths.d.ts.map +1 -0
- package/dist/utils/cursor-paths.js +116 -0
- package/dist/utils/cursor-paths.js.map +1 -0
- package/dist/utils/log-cleaner.d.ts +18 -0
- package/dist/utils/log-cleaner.d.ts.map +1 -0
- package/dist/utils/log-cleaner.js +112 -0
- package/dist/utils/log-cleaner.js.map +1 -0
- package/dist/utils/logger.d.ts +59 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +292 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/validation.d.ts +58 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +214 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +58 -0
- package/src/api/cached-client.ts +144 -0
- package/src/api/client.ts +578 -0
- package/src/auth/index.ts +11 -0
- package/src/auth/middleware.ts +244 -0
- package/src/auth/permissions.ts +317 -0
- package/src/auth/token-validator.ts +294 -0
- package/src/cache/cache-manager.ts +243 -0
- package/src/cache/index.ts +6 -0
- package/src/cache/redis-client.ts +249 -0
- package/src/config/constants.ts +33 -0
- package/src/config/index.ts +228 -0
- package/src/filesystem/manager.ts +235 -0
- package/src/git/multi-source-manager.ts +333 -0
- package/src/git/operations.ts +93 -0
- package/src/index.ts +139 -0
- package/src/monitoring/health.ts +132 -0
- package/src/resources/index.ts +13 -0
- package/src/resources/loader.ts +530 -0
- package/src/server/http.ts +427 -0
- package/src/server.ts +191 -0
- package/src/session/manager.ts +296 -0
- package/src/tools/index.ts +11 -0
- package/src/tools/manage-subscription.ts +332 -0
- package/src/tools/registry.ts +97 -0
- package/src/tools/search-resources.ts +177 -0
- package/src/tools/sync-resources.ts +662 -0
- package/src/tools/uninstall-resource.ts +248 -0
- package/src/tools/upload-resource.ts +258 -0
- package/src/transport/sse.ts +308 -0
- package/src/types/errors.ts +146 -0
- package/src/types/index.ts +7 -0
- package/src/types/mcp.ts +61 -0
- package/src/types/resources.ts +141 -0
- package/src/types/tools.ts +175 -0
- package/src/utils/cursor-paths.ts +83 -0
- package/src/utils/log-cleaner.ts +92 -0
- package/src/utils/logger.ts +333 -0
- package/src/utils/validation.ts +262 -0
|
@@ -0,0 +1,268 @@
|
|
|
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
|
+
async function manageSubscription(params) {
|
|
15
|
+
const startTime = Date.now();
|
|
16
|
+
// Type assertion for params
|
|
17
|
+
const typedParams = params;
|
|
18
|
+
logger_1.logger.info({ tool: 'manage_subscription', params }, 'manage_subscription called');
|
|
19
|
+
try {
|
|
20
|
+
let result;
|
|
21
|
+
switch (typedParams.action) {
|
|
22
|
+
case 'subscribe': {
|
|
23
|
+
// Validate resource_ids
|
|
24
|
+
if (!typedParams.resource_ids || typedParams.resource_ids.length === 0) {
|
|
25
|
+
throw (0, errors_1.createValidationError)('resource_ids', 'array', 'resource_ids is required for subscribe action');
|
|
26
|
+
}
|
|
27
|
+
logger_1.logger.debug({ resourceIds: typedParams.resource_ids, autoSync: typedParams.auto_sync }, 'Subscribing to resources...');
|
|
28
|
+
// Subscribe to resources
|
|
29
|
+
const subResult = await client_1.apiClient.subscribe(typedParams.resource_ids, typedParams.auto_sync);
|
|
30
|
+
logger_1.logger.info({ count: subResult.subscriptions.length }, 'Resources subscribed successfully');
|
|
31
|
+
// Auto-sync newly subscribed resources immediately (default: true)
|
|
32
|
+
const shouldAutoSync = typedParams.auto_sync !== false;
|
|
33
|
+
let syncSummary;
|
|
34
|
+
let syncDetails;
|
|
35
|
+
let pendingSetup;
|
|
36
|
+
if (shouldAutoSync && subResult.subscriptions.length > 0) {
|
|
37
|
+
logger_1.logger.info({ resourceIds: typedParams.resource_ids }, 'Auto-syncing newly subscribed resources...');
|
|
38
|
+
const syncResult = await (0, sync_resources_1.syncResources)({ mode: 'incremental', scope: typedParams.scope || 'global' });
|
|
39
|
+
if (syncResult.success && syncResult.data) {
|
|
40
|
+
const sd = syncResult.data;
|
|
41
|
+
syncSummary = `Auto-sync: ${sd.summary.synced} synced, ${sd.summary.cached} cached, ${sd.summary.failed} failed`;
|
|
42
|
+
syncDetails = sd.details.map(d => ({ id: d.id, name: d.name, action: d.action }));
|
|
43
|
+
if (sd.pending_setup && sd.pending_setup.length > 0) {
|
|
44
|
+
pendingSetup = sd.pending_setup;
|
|
45
|
+
}
|
|
46
|
+
logger_1.logger.info({ summary: sd.summary }, 'Auto-sync after subscribe completed');
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
logger_1.logger.warn({ error: syncResult.error }, 'Auto-sync after subscribe failed, subscription still recorded');
|
|
50
|
+
syncSummary = 'Auto-sync failed — run sync_resources manually if needed';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
result = {
|
|
54
|
+
action: 'subscribe',
|
|
55
|
+
success: true,
|
|
56
|
+
subscriptions: subResult.subscriptions.map(sub => ({
|
|
57
|
+
id: sub.id,
|
|
58
|
+
name: sub.name,
|
|
59
|
+
type: sub.type,
|
|
60
|
+
subscribed_at: sub.subscribed_at,
|
|
61
|
+
})),
|
|
62
|
+
message: [
|
|
63
|
+
`Successfully subscribed to ${subResult.subscriptions.length} resource${subResult.subscriptions.length > 1 ? 's' : ''}.`,
|
|
64
|
+
syncSummary,
|
|
65
|
+
].filter(Boolean).join(' '),
|
|
66
|
+
...(syncDetails ? { sync_details: syncDetails } : {}),
|
|
67
|
+
...(pendingSetup ? { pending_setup: pendingSetup } : {}),
|
|
68
|
+
};
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
case 'unsubscribe': {
|
|
72
|
+
// Validate resource_ids
|
|
73
|
+
if (!typedParams.resource_ids || typedParams.resource_ids.length === 0) {
|
|
74
|
+
throw (0, errors_1.createValidationError)('resource_ids', 'array', 'resource_ids is required for unsubscribe action');
|
|
75
|
+
}
|
|
76
|
+
logger_1.logger.debug({ resourceIds: typedParams.resource_ids }, 'Unsubscribing from resources...');
|
|
77
|
+
// Cancel server-side subscription
|
|
78
|
+
await client_1.apiClient.unsubscribe(typedParams.resource_ids);
|
|
79
|
+
logger_1.logger.info({ count: typedParams.resource_ids.length }, 'Server-side subscriptions removed');
|
|
80
|
+
// Uninstall local files and MCP config for each resource
|
|
81
|
+
const uninstallResults = [];
|
|
82
|
+
for (const resourceId of typedParams.resource_ids) {
|
|
83
|
+
// Use the last segment of the resource ID as the search pattern
|
|
84
|
+
// e.g. "mcp-client-sdk-ai-hub-jenkins" → "jenkins"
|
|
85
|
+
// "rule-csp-elliotTest" → "elliotTest"
|
|
86
|
+
const namePart = resourceId.split('-').slice(-1)[0] ||
|
|
87
|
+
resourceId.split('-').slice(-2).join('-') ||
|
|
88
|
+
resourceId;
|
|
89
|
+
// Try full name match first (e.g. "elliotTest"), fallback to last segment
|
|
90
|
+
const patternsToTry = Array.from(new Set([
|
|
91
|
+
resourceId, // full id
|
|
92
|
+
resourceId.replace(/^(skill|cmd|rule|mcp)-[^-]+-/, ''), // strip prefix+source
|
|
93
|
+
namePart,
|
|
94
|
+
]));
|
|
95
|
+
let uninstalled = false;
|
|
96
|
+
for (const pattern of patternsToTry) {
|
|
97
|
+
const uninstallResult = await (0, uninstall_resource_1.uninstallResource)({
|
|
98
|
+
resource_id_or_name: pattern,
|
|
99
|
+
remove_from_account: false, // already unsubscribed above
|
|
100
|
+
});
|
|
101
|
+
if (uninstallResult.success && uninstallResult.data && uninstallResult.data.removed_resources.length > 0) {
|
|
102
|
+
uninstallResults.push({ id: resourceId, removed: true, detail: `Removed local files for "${pattern}"` });
|
|
103
|
+
uninstalled = true;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (!uninstalled) {
|
|
108
|
+
uninstallResults.push({ id: resourceId, removed: false, detail: 'No local files found (may not have been installed)' });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const removedCount = uninstallResults.filter(r => r.removed).length;
|
|
112
|
+
const notFoundCount = uninstallResults.filter(r => !r.removed).length;
|
|
113
|
+
result = {
|
|
114
|
+
action: 'unsubscribe',
|
|
115
|
+
success: true,
|
|
116
|
+
message: [
|
|
117
|
+
`Successfully unsubscribed from ${typedParams.resource_ids.length} resource${typedParams.resource_ids.length > 1 ? 's' : ''}.`,
|
|
118
|
+
removedCount > 0 ? `Removed local files for ${removedCount} resource${removedCount > 1 ? 's' : ''}.` : null,
|
|
119
|
+
notFoundCount > 0 ? `${notFoundCount} resource${notFoundCount > 1 ? 's were' : ' was'} not installed locally.` : null,
|
|
120
|
+
].filter(Boolean).join(' '),
|
|
121
|
+
sync_details: uninstallResults.map(r => ({ id: r.id, name: r.id, action: r.removed ? 'uninstalled' : 'not_found_locally' })),
|
|
122
|
+
};
|
|
123
|
+
logger_1.logger.info({ count: typedParams.resource_ids.length, removedCount }, 'Resources unsubscribed and local files cleaned up');
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
case 'list': {
|
|
127
|
+
logger_1.logger.debug({ scope: typedParams.scope || 'all' }, 'Listing subscriptions...');
|
|
128
|
+
// Get subscriptions list
|
|
129
|
+
const subs = await client_1.apiClient.getSubscriptions({});
|
|
130
|
+
result = {
|
|
131
|
+
action: 'list',
|
|
132
|
+
success: true,
|
|
133
|
+
subscriptions: subs.subscriptions.map(sub => ({
|
|
134
|
+
id: sub.id,
|
|
135
|
+
name: sub.name,
|
|
136
|
+
type: sub.type,
|
|
137
|
+
subscribed_at: sub.subscribed_at,
|
|
138
|
+
})),
|
|
139
|
+
message: `Found ${subs.total} subscription${subs.total !== 1 ? 's' : ''}`,
|
|
140
|
+
};
|
|
141
|
+
logger_1.logger.info({ total: subs.total }, 'Subscriptions listed successfully');
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
case 'batch_subscribe': {
|
|
145
|
+
// Validate resource_ids
|
|
146
|
+
if (!typedParams.resource_ids || typedParams.resource_ids.length === 0) {
|
|
147
|
+
throw (0, errors_1.createValidationError)('resource_ids', 'array', 'resource_ids is required for batch_subscribe action');
|
|
148
|
+
}
|
|
149
|
+
logger_1.logger.debug({ count: typedParams.resource_ids.length, autoSync: typedParams.auto_sync }, 'Batch subscribing to resources...');
|
|
150
|
+
const batchSubResult = await client_1.apiClient.subscribe(typedParams.resource_ids, typedParams.auto_sync);
|
|
151
|
+
logger_1.logger.info({ count: batchSubResult.subscriptions.length }, 'Batch subscription completed');
|
|
152
|
+
// Auto-sync newly subscribed resources immediately (default: true)
|
|
153
|
+
const shouldBatchAutoSync = typedParams.auto_sync !== false;
|
|
154
|
+
let batchSyncSummary;
|
|
155
|
+
let batchSyncDetails;
|
|
156
|
+
let batchPendingSetup;
|
|
157
|
+
if (shouldBatchAutoSync && batchSubResult.subscriptions.length > 0) {
|
|
158
|
+
logger_1.logger.info({ count: batchSubResult.subscriptions.length }, 'Auto-syncing batch subscribed resources...');
|
|
159
|
+
const batchSyncResult = await (0, sync_resources_1.syncResources)({ mode: 'incremental', scope: typedParams.scope || 'global' });
|
|
160
|
+
if (batchSyncResult.success && batchSyncResult.data) {
|
|
161
|
+
const sd = batchSyncResult.data;
|
|
162
|
+
batchSyncSummary = `Auto-sync: ${sd.summary.synced} synced, ${sd.summary.cached} cached, ${sd.summary.failed} failed`;
|
|
163
|
+
batchSyncDetails = sd.details.map(d => ({ id: d.id, name: d.name, action: d.action }));
|
|
164
|
+
if (sd.pending_setup && sd.pending_setup.length > 0) {
|
|
165
|
+
batchPendingSetup = sd.pending_setup;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
batchSyncSummary = 'Auto-sync failed — run sync_resources manually if needed';
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
result = {
|
|
173
|
+
action: 'batch_subscribe',
|
|
174
|
+
success: true,
|
|
175
|
+
subscriptions: batchSubResult.subscriptions.map(sub => ({
|
|
176
|
+
id: sub.id,
|
|
177
|
+
name: sub.name,
|
|
178
|
+
type: sub.type,
|
|
179
|
+
subscribed_at: sub.subscribed_at,
|
|
180
|
+
})),
|
|
181
|
+
message: [
|
|
182
|
+
`Successfully batch subscribed to ${batchSubResult.subscriptions.length} resource${batchSubResult.subscriptions.length > 1 ? 's' : ''}.`,
|
|
183
|
+
batchSyncSummary,
|
|
184
|
+
].filter(Boolean).join(' '),
|
|
185
|
+
...(batchSyncDetails ? { sync_details: batchSyncDetails } : {}),
|
|
186
|
+
...(batchPendingSetup ? { pending_setup: batchPendingSetup } : {}),
|
|
187
|
+
};
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
case 'batch_unsubscribe': {
|
|
191
|
+
// Validate resource_ids
|
|
192
|
+
if (!typedParams.resource_ids || typedParams.resource_ids.length === 0) {
|
|
193
|
+
throw (0, errors_1.createValidationError)('resource_ids', 'array', 'resource_ids is required for batch_unsubscribe action');
|
|
194
|
+
}
|
|
195
|
+
logger_1.logger.debug({ count: typedParams.resource_ids.length }, 'Batch unsubscribing from resources...');
|
|
196
|
+
// Delegate entirely to the unsubscribe case for unified cleanup logic
|
|
197
|
+
return manageSubscription({ ...typedParams, action: 'unsubscribe' });
|
|
198
|
+
}
|
|
199
|
+
default: {
|
|
200
|
+
throw (0, errors_1.createValidationError)('action', 'string', `Unknown action. Must be one of: subscribe, unsubscribe, list, batch_subscribe, batch_unsubscribe`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const duration = Date.now() - startTime;
|
|
204
|
+
(0, logger_1.logToolCall)('manage_subscription', 'user-id', params, duration);
|
|
205
|
+
logger_1.logger.info({
|
|
206
|
+
action: typedParams.action,
|
|
207
|
+
duration,
|
|
208
|
+
}, 'manage_subscription completed successfully');
|
|
209
|
+
return {
|
|
210
|
+
success: true,
|
|
211
|
+
data: result,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
logger_1.logger.error({ error, action: typedParams.action }, 'manage_subscription failed');
|
|
216
|
+
return {
|
|
217
|
+
success: false,
|
|
218
|
+
error: {
|
|
219
|
+
code: error instanceof errors_1.MCPServerError ? error.code : 'UNKNOWN_ERROR',
|
|
220
|
+
message: error instanceof Error ? error.message : String(error),
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// Tool definition for registry
|
|
226
|
+
exports.manageSubscriptionTool = {
|
|
227
|
+
name: 'manage_subscription',
|
|
228
|
+
description: 'Manage resource subscriptions (subscribe, unsubscribe, list). ' +
|
|
229
|
+
'When action is "subscribe" or "batch_subscribe", the tool automatically syncs ' +
|
|
230
|
+
'the newly subscribed resources to the local machine immediately after subscribing ' +
|
|
231
|
+
'(auto_sync defaults to true). Pass auto_sync: false only when the user explicitly ' +
|
|
232
|
+
'says they do NOT want the resource installed right now.',
|
|
233
|
+
inputSchema: {
|
|
234
|
+
type: 'object',
|
|
235
|
+
properties: {
|
|
236
|
+
action: {
|
|
237
|
+
type: 'string',
|
|
238
|
+
description: 'Action to perform',
|
|
239
|
+
enum: ['subscribe', 'unsubscribe', 'list', 'batch_subscribe', 'batch_unsubscribe'],
|
|
240
|
+
},
|
|
241
|
+
resource_ids: {
|
|
242
|
+
type: 'array',
|
|
243
|
+
description: 'Resource IDs (required for subscribe/unsubscribe actions)',
|
|
244
|
+
},
|
|
245
|
+
auto_sync: {
|
|
246
|
+
type: 'boolean',
|
|
247
|
+
description: 'Whether to immediately sync (install) the subscribed resources to the local machine after subscribing. ' +
|
|
248
|
+
'Defaults to true — omit this field in normal usage. ' +
|
|
249
|
+
'Set to false only when the user explicitly says they want to subscribe but NOT install yet.',
|
|
250
|
+
default: true,
|
|
251
|
+
},
|
|
252
|
+
scope: {
|
|
253
|
+
type: 'string',
|
|
254
|
+
description: 'Installation scope',
|
|
255
|
+
enum: ['global', 'workspace'],
|
|
256
|
+
default: 'global',
|
|
257
|
+
},
|
|
258
|
+
notify: {
|
|
259
|
+
type: 'boolean',
|
|
260
|
+
description: 'Enable update notifications',
|
|
261
|
+
default: true,
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
required: ['action'],
|
|
265
|
+
},
|
|
266
|
+
handler: manageSubscription,
|
|
267
|
+
};
|
|
268
|
+
//# sourceMappingURL=manage-subscription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manage-subscription.js","sourceRoot":"","sources":["../../src/tools/manage-subscription.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,gDAiRC;AAxRD,4CAAsD;AACtD,0CAA0C;AAC1C,4CAAwE;AAExE,qDAAiD;AACjD,6DAAyD;AAElD,KAAK,UAAU,kBAAkB,CAAC,MAAe;IACtD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,4BAA4B;IAC5B,MAAM,WAAW,GAAG,MAAkC,CAAC;IAEvD,eAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,EAAE,4BAA4B,CAAC,CAAC;IAEnF,IAAI,CAAC;QACH,IAAI,MAAgC,CAAC;QAErC,QAAQ,WAAW,CAAC,MAAM,EAAE,CAAC;YAC3B,KAAK,WAAW,CAAC,CAAC,CAAC;gBACjB,wBAAwB;gBACxB,IAAI,CAAC,WAAW,CAAC,YAAY,IAAI,WAAW,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBACvE,MAAM,IAAA,8BAAqB,EACzB,cAAc,EACd,OAAO,EACP,+CAA+C,CAChD,CAAC;gBACJ,CAAC;gBAED,eAAM,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,WAAW,CAAC,YAAY,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AAyG;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;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;KACrB;IACD,OAAO,EAAE,kBAAkB;CAC5B,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4CAAyC;AAIzC,MAAM,YAAY;IACR,KAAK,GAAgC,IAAI,GAAG,EAAE,CAAC;IAEvD;;OAEG;IACH,YAAY,CAAC,IAAoB;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,IAAI,yBAAyB,CAAC,CAAC;QAC/D,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAChC,eAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,oBAAoB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACxE,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,IA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Q,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;gBAClF,UAAU,EAAE,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,SAAS,IAAI,MAAM;gBACvE,OAAO,EAAE,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAI,MAAM;gBACjE,QAAQ,EAAE,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,IAAI,MAAM;aACpE,EAAE,iCAAiC,CAAC,CAAC;YAEtC,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,eAAM,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,4BAA4B,CAAC,CAAC;YACrK,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAED,mBAAmB;AACN,QAAA,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
};
|
|
27
|
+
required: string[];
|
|
28
|
+
};
|
|
29
|
+
handler: typeof searchResources;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=search-resources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AA+C/F,wBAAsB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC,CA6FjG;AAGD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;CAuB/B,CAAC"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* search_resources Tool
|
|
4
|
+
* Search for available resources
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.searchResourcesTool = void 0;
|
|
8
|
+
exports.searchResources = searchResources;
|
|
9
|
+
const logger_1 = require("../utils/logger");
|
|
10
|
+
const client_1 = require("../api/client");
|
|
11
|
+
const manager_1 = require("../filesystem/manager");
|
|
12
|
+
const cursor_paths_js_1 = require("../utils/cursor-paths.js");
|
|
13
|
+
const errors_1 = require("../types/errors");
|
|
14
|
+
// Simple in-memory cache
|
|
15
|
+
const searchCache = new Map();
|
|
16
|
+
const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
|
|
17
|
+
/**
|
|
18
|
+
* Generate cache key from search parameters
|
|
19
|
+
*/
|
|
20
|
+
function getCacheKey(params) {
|
|
21
|
+
return JSON.stringify({
|
|
22
|
+
team: params.team || '',
|
|
23
|
+
type: params.type || '',
|
|
24
|
+
keyword: params.keyword || '',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get cached search results if available and not expired
|
|
29
|
+
*/
|
|
30
|
+
function getCachedResults(cacheKey) {
|
|
31
|
+
const cached = searchCache.get(cacheKey);
|
|
32
|
+
if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
|
|
33
|
+
logger_1.logger.debug({ cacheKey }, 'Search cache hit');
|
|
34
|
+
return cached.results;
|
|
35
|
+
}
|
|
36
|
+
if (cached) {
|
|
37
|
+
// Remove expired cache entry
|
|
38
|
+
searchCache.delete(cacheKey);
|
|
39
|
+
logger_1.logger.debug({ cacheKey }, 'Search cache expired, removed');
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Cache search results
|
|
45
|
+
*/
|
|
46
|
+
function cacheResults(cacheKey, results) {
|
|
47
|
+
searchCache.set(cacheKey, {
|
|
48
|
+
results,
|
|
49
|
+
timestamp: Date.now(),
|
|
50
|
+
});
|
|
51
|
+
logger_1.logger.debug({ cacheKey, total: results.total }, 'Search results cached');
|
|
52
|
+
}
|
|
53
|
+
async function searchResources(params) {
|
|
54
|
+
const startTime = Date.now();
|
|
55
|
+
// Type assertion for params
|
|
56
|
+
const typedParams = params;
|
|
57
|
+
logger_1.logger.info({ tool: 'search_resources', params }, 'search_resources called');
|
|
58
|
+
try {
|
|
59
|
+
// Generate cache key
|
|
60
|
+
const cacheKey = getCacheKey(typedParams);
|
|
61
|
+
// Check cache first
|
|
62
|
+
const cachedResult = getCachedResults(cacheKey);
|
|
63
|
+
if (cachedResult) {
|
|
64
|
+
const duration = Date.now() - startTime;
|
|
65
|
+
(0, logger_1.logToolCall)('search_resources', 'user-id', params, duration);
|
|
66
|
+
logger_1.logger.info({ total: cachedResult.total, duration, cached: true }, 'search_resources completed (cache hit)');
|
|
67
|
+
return {
|
|
68
|
+
success: true,
|
|
69
|
+
data: cachedResult,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// Search via API
|
|
73
|
+
logger_1.logger.debug({ team: typedParams.team, type: typedParams.type, keyword: typedParams.keyword }, 'Searching resources...');
|
|
74
|
+
const searchResults = await client_1.apiClient.searchResources({
|
|
75
|
+
team: typedParams.team,
|
|
76
|
+
type: typedParams.type,
|
|
77
|
+
keyword: typedParams.keyword,
|
|
78
|
+
});
|
|
79
|
+
// Check subscription and installation status for each result
|
|
80
|
+
const enhancedResults = await Promise.all(searchResults.results.map(async (resource) => {
|
|
81
|
+
// Check if installed locally in the Cursor directory for this resource type
|
|
82
|
+
let isInstalled = false;
|
|
83
|
+
try {
|
|
84
|
+
const resourcePath = (0, cursor_paths_js_1.getCursorResourcePath)(resource.type, resource.name);
|
|
85
|
+
isInstalled = await manager_1.filesystemManager.fileExists(resourcePath);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// Unknown type or path check failed — treat as not installed
|
|
89
|
+
isInstalled = false;
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
...resource,
|
|
93
|
+
is_installed: isInstalled,
|
|
94
|
+
};
|
|
95
|
+
}));
|
|
96
|
+
// Build final result
|
|
97
|
+
const result = {
|
|
98
|
+
total: searchResults.total,
|
|
99
|
+
results: enhancedResults,
|
|
100
|
+
};
|
|
101
|
+
// Cache the results
|
|
102
|
+
cacheResults(cacheKey, result);
|
|
103
|
+
const duration = Date.now() - startTime;
|
|
104
|
+
(0, logger_1.logToolCall)('search_resources', 'user-id', params, duration);
|
|
105
|
+
logger_1.logger.info({
|
|
106
|
+
team: typedParams.team,
|
|
107
|
+
type: typedParams.type,
|
|
108
|
+
keyword: typedParams.keyword,
|
|
109
|
+
total: result.total,
|
|
110
|
+
duration,
|
|
111
|
+
cached: false,
|
|
112
|
+
}, 'search_resources completed successfully');
|
|
113
|
+
return {
|
|
114
|
+
success: true,
|
|
115
|
+
data: result,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
logger_1.logger.error({ error, tool: 'search_resources', errorStack: error instanceof Error ? error.stack : undefined }, 'search_resources failed');
|
|
120
|
+
return {
|
|
121
|
+
success: false,
|
|
122
|
+
error: {
|
|
123
|
+
code: error instanceof errors_1.MCPServerError ? error.code : 'UNKNOWN_ERROR',
|
|
124
|
+
message: error instanceof Error ? error.message : String(error),
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// Tool definition for registry
|
|
130
|
+
exports.searchResourcesTool = {
|
|
131
|
+
name: 'search_resources',
|
|
132
|
+
description: 'Search for available resources by team, type, or keyword',
|
|
133
|
+
inputSchema: {
|
|
134
|
+
type: 'object',
|
|
135
|
+
properties: {
|
|
136
|
+
team: {
|
|
137
|
+
type: 'string',
|
|
138
|
+
description: 'Filter by team (empty = all teams)',
|
|
139
|
+
},
|
|
140
|
+
type: {
|
|
141
|
+
type: 'string',
|
|
142
|
+
description: 'Filter by resource type',
|
|
143
|
+
enum: ['command', 'skill', 'rule', 'mcp', ''],
|
|
144
|
+
},
|
|
145
|
+
keyword: {
|
|
146
|
+
type: 'string',
|
|
147
|
+
description: 'Search keyword (searches in name, description, tags)',
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
required: ['keyword'],
|
|
151
|
+
},
|
|
152
|
+
handler: searchResources,
|
|
153
|
+
};
|
|
154
|
+
//# sourceMappingURL=search-resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-resources.js","sourceRoot":"","sources":["../../src/tools/search-resources.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAsDH,0CA6FC;AAjJD,4CAAsD;AACtD,0CAA0C;AAC1C,mDAA0D;AAC1D,8DAAiE;AACjE,4CAAiD;AAGjD,yBAAyB;AACzB,MAAM,WAAW,GAAG,IAAI,GAAG,EAAiE,CAAC;AAC7F,MAAM,SAAS,GAAG,CAAC,GAA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