@elliotding/ai-agent-mcp 0.1.25 → 0.1.27

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 (53) hide show
  1. package/package.json +4 -1
  2. package/.prompt-cache/cmd-cmd-client-sdk-ai-hub-generate-testcase.md +0 -101
  3. package/.prompt-cache/cmd-cmd-client-sdk-ai-hub-submit_zct_job.md +0 -158
  4. package/.prompt-cache/skill-skill-client-sdk-ai-hub-analyze-conf-status.md +0 -311
  5. package/.prompt-cache/skill-skill-client-sdk-ai-hub-analyze-sdk-log.md +0 -64
  6. package/.prompt-cache/skill-skill-client-sdk-ai-hub-analyze-zmb-log-errors.md +0 -84
  7. package/ai-resource-telemetry.json +0 -40
  8. package/src/api/cached-client.ts +0 -144
  9. package/src/api/client.ts +0 -697
  10. package/src/auth/index.ts +0 -11
  11. package/src/auth/middleware.ts +0 -244
  12. package/src/auth/permissions.ts +0 -323
  13. package/src/auth/token-validator.ts +0 -292
  14. package/src/cache/cache-manager.ts +0 -243
  15. package/src/cache/index.ts +0 -6
  16. package/src/cache/redis-client.ts +0 -249
  17. package/src/config/constants.ts +0 -33
  18. package/src/config/index.ts +0 -269
  19. package/src/filesystem/manager.ts +0 -235
  20. package/src/git/multi-source-manager.ts +0 -654
  21. package/src/git/operations.ts +0 -93
  22. package/src/index.ts +0 -157
  23. package/src/monitoring/health.ts +0 -132
  24. package/src/prompts/cache.ts +0 -140
  25. package/src/prompts/generator.ts +0 -143
  26. package/src/prompts/index.ts +0 -20
  27. package/src/prompts/manager.ts +0 -718
  28. package/src/resources/index.ts +0 -13
  29. package/src/resources/loader.ts +0 -563
  30. package/src/server/http.ts +0 -549
  31. package/src/server.ts +0 -206
  32. package/src/session/manager.ts +0 -296
  33. package/src/telemetry/index.ts +0 -10
  34. package/src/telemetry/manager.ts +0 -419
  35. package/src/tools/index.ts +0 -13
  36. package/src/tools/manage-subscription.ts +0 -388
  37. package/src/tools/registry.ts +0 -97
  38. package/src/tools/resolve-prompt-content.ts +0 -113
  39. package/src/tools/search-resources.ts +0 -185
  40. package/src/tools/sync-resources.ts +0 -829
  41. package/src/tools/track-usage.ts +0 -113
  42. package/src/tools/uninstall-resource.ts +0 -199
  43. package/src/tools/upload-resource.ts +0 -431
  44. package/src/transport/sse.ts +0 -308
  45. package/src/types/errors.ts +0 -146
  46. package/src/types/index.ts +0 -7
  47. package/src/types/mcp.ts +0 -61
  48. package/src/types/resources.ts +0 -141
  49. package/src/types/tools.ts +0 -305
  50. package/src/utils/cursor-paths.ts +0 -135
  51. package/src/utils/log-cleaner.ts +0 -92
  52. package/src/utils/logger.ts +0 -333
  53. package/src/utils/validation.ts +0 -262
@@ -1,185 +0,0 @@
1
- /**
2
- * search_resources Tool
3
- * Search for available resources
4
- */
5
-
6
- import { logger, logToolCall } from '../utils/logger';
7
- import { apiClient } from '../api/client';
8
- import { filesystemManager } from '../filesystem/manager';
9
- import { getCursorResourcePath } from '../utils/cursor-paths.js';
10
- import { MCPServerError } from '../types/errors';
11
- import type { SearchResourcesParams, SearchResourcesResult, ToolResult } from '../types/tools';
12
- // Simple in-memory cache
13
- const searchCache = new Map<string, { results: SearchResourcesResult; timestamp: number }>();
14
- const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
15
-
16
- /**
17
- * Generate cache key from search parameters
18
- */
19
- function getCacheKey(params: SearchResourcesParams): string {
20
- return JSON.stringify({
21
- team: params.team || '',
22
- type: params.type || '',
23
- keyword: params.keyword || '',
24
- });
25
- }
26
-
27
- /**
28
- * Get cached search results if available and not expired
29
- */
30
- function getCachedResults(cacheKey: string): SearchResourcesResult | null {
31
- const cached = searchCache.get(cacheKey);
32
- if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
33
- logger.debug({ cacheKey }, 'Search cache hit');
34
- return cached.results;
35
- }
36
-
37
- if (cached) {
38
- // Remove expired cache entry
39
- searchCache.delete(cacheKey);
40
- logger.debug({ cacheKey }, 'Search cache expired, removed');
41
- }
42
-
43
- return null;
44
- }
45
-
46
- /**
47
- * Cache search results
48
- */
49
- function cacheResults(cacheKey: string, results: SearchResourcesResult): void {
50
- searchCache.set(cacheKey, {
51
- results,
52
- timestamp: Date.now(),
53
- });
54
- logger.debug({ cacheKey, total: results.total }, 'Search results cached');
55
- }
56
-
57
- export async function searchResources(params: unknown): Promise<ToolResult<SearchResourcesResult>> {
58
- const startTime = Date.now();
59
-
60
- // Type assertion for params
61
- const typedParams = params as SearchResourcesParams;
62
-
63
- logger.info({ tool: 'search_resources', params }, 'search_resources called');
64
-
65
- try {
66
- // Generate cache key
67
- const cacheKey = getCacheKey(typedParams);
68
-
69
- // Check cache first
70
- const cachedResult = getCachedResults(cacheKey);
71
- if (cachedResult) {
72
- const duration = Date.now() - startTime;
73
- logToolCall('search_resources', 'user-id', params as Record<string, unknown>, duration);
74
-
75
- logger.info({ total: cachedResult.total, duration, cached: true }, 'search_resources completed (cache hit)');
76
-
77
- return {
78
- success: true,
79
- data: cachedResult,
80
- };
81
- }
82
-
83
- // Search via API
84
- logger.debug({ team: typedParams.team, type: typedParams.type, keyword: typedParams.keyword }, 'Searching resources...');
85
-
86
- const searchResults = await apiClient.searchResources(
87
- {
88
- team: typedParams.team,
89
- type: typedParams.type,
90
- keyword: typedParams.keyword,
91
- },
92
- typedParams.user_token
93
- );
94
-
95
- // Check subscription and installation status for each result
96
- const enhancedResults = await Promise.all(
97
- searchResults.results.map(async (resource) => {
98
- // Check if installed locally in the Cursor directory for this resource type
99
- let isInstalled = false;
100
- try {
101
- const resourcePath = getCursorResourcePath(resource.type, resource.name);
102
- isInstalled = await filesystemManager.fileExists(resourcePath);
103
- } catch {
104
- // Unknown type or path check failed — treat as not installed
105
- isInstalled = false;
106
- }
107
-
108
- return {
109
- ...resource,
110
- is_installed: isInstalled,
111
- };
112
- })
113
- );
114
-
115
- // Build final result
116
- const result: SearchResourcesResult = {
117
- total: searchResults.total,
118
- results: enhancedResults,
119
- };
120
-
121
- // Cache the results
122
- cacheResults(cacheKey, result);
123
-
124
- const duration = Date.now() - startTime;
125
- logToolCall('search_resources', 'user-id', params as Record<string, unknown>, duration);
126
-
127
- logger.info(
128
- {
129
- team: typedParams.team,
130
- type: typedParams.type,
131
- keyword: typedParams.keyword,
132
- total: result.total,
133
- duration,
134
- cached: false,
135
- },
136
- 'search_resources completed successfully'
137
- );
138
-
139
- return {
140
- success: true,
141
- data: result,
142
- };
143
- } catch (error) {
144
- logger.error({ error, tool: 'search_resources', errorStack: error instanceof Error ? error.stack : undefined }, 'search_resources failed');
145
- return {
146
- success: false,
147
- error: {
148
- code: error instanceof MCPServerError ? error.code : 'UNKNOWN_ERROR',
149
- message: error instanceof Error ? error.message : String(error),
150
- },
151
- };
152
- }
153
- }
154
-
155
- // Tool definition for registry
156
- export const searchResourcesTool = {
157
- name: 'search_resources',
158
- description: 'Search for available resources by team, type, or keyword',
159
- inputSchema: {
160
- type: 'object' as const,
161
- properties: {
162
- team: {
163
- type: 'string',
164
- description: 'Filter by team (empty = all teams)',
165
- },
166
- type: {
167
- type: 'string',
168
- description: 'Filter by resource type',
169
- enum: ['command', 'skill', 'rule', 'mcp', ''],
170
- },
171
- keyword: {
172
- type: 'string',
173
- description: 'Search keyword (searches in name, description, tags)',
174
- },
175
- user_token: {
176
- type: 'string',
177
- description:
178
- 'DO NOT set this field — it is automatically injected by the MCP server from ' +
179
- 'the authenticated SSE connection. The server always provides the correct token.',
180
- },
181
- },
182
- required: ['keyword'],
183
- },
184
- handler: searchResources,
185
- };