@juspay/neurolink 9.42.0 → 9.43.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 (116) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/auth/anthropicOAuth.js +12 -0
  3. package/dist/browser/neurolink.min.js +335 -334
  4. package/dist/cli/commands/mcp.d.ts +6 -0
  5. package/dist/cli/commands/mcp.js +200 -184
  6. package/dist/cli/commands/proxy.js +560 -518
  7. package/dist/core/baseProvider.d.ts +6 -1
  8. package/dist/core/baseProvider.js +219 -232
  9. package/dist/core/factory.d.ts +3 -0
  10. package/dist/core/factory.js +140 -190
  11. package/dist/core/modules/ToolsManager.d.ts +1 -0
  12. package/dist/core/modules/ToolsManager.js +40 -42
  13. package/dist/core/toolEvents.d.ts +3 -0
  14. package/dist/core/toolEvents.js +7 -0
  15. package/dist/evaluation/pipeline/evaluationPipeline.js +5 -2
  16. package/dist/evaluation/scorers/scorerRegistry.d.ts +3 -0
  17. package/dist/evaluation/scorers/scorerRegistry.js +356 -284
  18. package/dist/lib/auth/anthropicOAuth.js +12 -0
  19. package/dist/lib/core/baseProvider.d.ts +6 -1
  20. package/dist/lib/core/baseProvider.js +219 -232
  21. package/dist/lib/core/factory.d.ts +3 -0
  22. package/dist/lib/core/factory.js +140 -190
  23. package/dist/lib/core/modules/ToolsManager.d.ts +1 -0
  24. package/dist/lib/core/modules/ToolsManager.js +40 -42
  25. package/dist/lib/core/toolEvents.d.ts +3 -0
  26. package/dist/lib/core/toolEvents.js +8 -0
  27. package/dist/lib/evaluation/pipeline/evaluationPipeline.js +5 -2
  28. package/dist/lib/evaluation/scorers/scorerRegistry.d.ts +3 -0
  29. package/dist/lib/evaluation/scorers/scorerRegistry.js +356 -284
  30. package/dist/lib/mcp/toolRegistry.d.ts +2 -0
  31. package/dist/lib/mcp/toolRegistry.js +32 -31
  32. package/dist/lib/neurolink.d.ts +38 -0
  33. package/dist/lib/neurolink.js +1890 -1707
  34. package/dist/lib/providers/googleAiStudio.js +0 -5
  35. package/dist/lib/providers/googleNativeGemini3.d.ts +4 -0
  36. package/dist/lib/providers/googleNativeGemini3.js +39 -1
  37. package/dist/lib/providers/googleVertex.d.ts +10 -0
  38. package/dist/lib/providers/googleVertex.js +445 -445
  39. package/dist/lib/providers/litellm.d.ts +1 -0
  40. package/dist/lib/providers/litellm.js +73 -64
  41. package/dist/lib/providers/ollama.js +17 -4
  42. package/dist/lib/providers/openAI.d.ts +2 -0
  43. package/dist/lib/providers/openAI.js +139 -140
  44. package/dist/lib/proxy/claudeFormat.js +14 -5
  45. package/dist/lib/proxy/oauthFetch.js +298 -318
  46. package/dist/lib/proxy/proxyConfig.js +3 -1
  47. package/dist/lib/proxy/proxyFetch.js +250 -222
  48. package/dist/lib/proxy/proxyHealth.d.ts +17 -0
  49. package/dist/lib/proxy/proxyHealth.js +55 -0
  50. package/dist/lib/proxy/requestLogger.js +140 -48
  51. package/dist/lib/proxy/routingPolicy.d.ts +33 -0
  52. package/dist/lib/proxy/routingPolicy.js +255 -0
  53. package/dist/lib/proxy/snapshotPersistence.d.ts +2 -0
  54. package/dist/lib/proxy/snapshotPersistence.js +41 -0
  55. package/dist/lib/proxy/sseInterceptor.js +36 -11
  56. package/dist/lib/server/routes/claudeProxyRoutes.d.ts +2 -1
  57. package/dist/lib/server/routes/claudeProxyRoutes.js +2916 -2377
  58. package/dist/lib/services/server/ai/observability/instrumentation.js +194 -218
  59. package/dist/lib/tasks/backends/bullmqBackend.js +24 -18
  60. package/dist/lib/tasks/store/redisTaskStore.js +42 -17
  61. package/dist/lib/tasks/taskManager.d.ts +2 -0
  62. package/dist/lib/tasks/taskManager.js +100 -5
  63. package/dist/lib/telemetry/telemetryService.js +9 -5
  64. package/dist/lib/types/cli.d.ts +4 -0
  65. package/dist/lib/types/proxyTypes.d.ts +211 -1
  66. package/dist/lib/types/tools.d.ts +18 -0
  67. package/dist/lib/utils/providerHealth.d.ts +1 -0
  68. package/dist/lib/utils/providerHealth.js +46 -31
  69. package/dist/lib/utils/providerUtils.js +11 -22
  70. package/dist/lib/utils/schemaConversion.d.ts +1 -0
  71. package/dist/lib/utils/schemaConversion.js +3 -0
  72. package/dist/mcp/toolRegistry.d.ts +2 -0
  73. package/dist/mcp/toolRegistry.js +32 -31
  74. package/dist/neurolink.d.ts +38 -0
  75. package/dist/neurolink.js +1890 -1707
  76. package/dist/providers/googleAiStudio.js +0 -5
  77. package/dist/providers/googleNativeGemini3.d.ts +4 -0
  78. package/dist/providers/googleNativeGemini3.js +39 -1
  79. package/dist/providers/googleVertex.d.ts +10 -0
  80. package/dist/providers/googleVertex.js +445 -445
  81. package/dist/providers/litellm.d.ts +1 -0
  82. package/dist/providers/litellm.js +73 -64
  83. package/dist/providers/ollama.js +17 -4
  84. package/dist/providers/openAI.d.ts +2 -0
  85. package/dist/providers/openAI.js +139 -140
  86. package/dist/proxy/claudeFormat.js +14 -5
  87. package/dist/proxy/oauthFetch.js +298 -318
  88. package/dist/proxy/proxyConfig.js +3 -1
  89. package/dist/proxy/proxyFetch.js +250 -222
  90. package/dist/proxy/proxyHealth.d.ts +17 -0
  91. package/dist/proxy/proxyHealth.js +54 -0
  92. package/dist/proxy/requestLogger.js +140 -48
  93. package/dist/proxy/routingPolicy.d.ts +33 -0
  94. package/dist/proxy/routingPolicy.js +254 -0
  95. package/dist/proxy/snapshotPersistence.d.ts +2 -0
  96. package/dist/proxy/snapshotPersistence.js +40 -0
  97. package/dist/proxy/sseInterceptor.js +36 -11
  98. package/dist/server/routes/claudeProxyRoutes.d.ts +2 -1
  99. package/dist/server/routes/claudeProxyRoutes.js +2916 -2377
  100. package/dist/services/server/ai/observability/instrumentation.js +194 -218
  101. package/dist/tasks/backends/bullmqBackend.js +24 -18
  102. package/dist/tasks/store/redisTaskStore.js +42 -17
  103. package/dist/tasks/taskManager.d.ts +2 -0
  104. package/dist/tasks/taskManager.js +100 -5
  105. package/dist/telemetry/telemetryService.js +9 -5
  106. package/dist/types/cli.d.ts +4 -0
  107. package/dist/types/proxyTypes.d.ts +211 -1
  108. package/dist/types/tools.d.ts +18 -0
  109. package/dist/utils/providerHealth.d.ts +1 -0
  110. package/dist/utils/providerHealth.js +46 -31
  111. package/dist/utils/providerUtils.js +12 -22
  112. package/dist/utils/schemaConversion.d.ts +1 -0
  113. package/dist/utils/schemaConversion.js +3 -0
  114. package/package.json +3 -2
  115. package/scripts/observability/check-proxy-telemetry.mjs +1 -1
  116. package/scripts/observability/manage-local-openobserve.sh +36 -5
@@ -163,4 +163,10 @@ export declare class MCPCommandFactory {
163
163
  * Execute annotate command
164
164
  */
165
165
  private static executeAnnotate;
166
+ private static getMCPStatusWithTimeout;
167
+ private static listToolAnnotations;
168
+ private static collectToolAnnotations;
169
+ private static findToolForAnnotation;
170
+ private static buildAnnotationsFromArgs;
171
+ private static printAnnotationUpdate;
166
172
  }
@@ -115,6 +115,7 @@ const POPULAR_MCP_SERVERS = {
115
115
  description: "Bitbucket repository management and development workflows",
116
116
  },
117
117
  };
118
+ const MCP_STATUS_TIMEOUT_MS = 30_000;
118
119
  /**
119
120
  * MCP CLI command factory
120
121
  */
@@ -565,7 +566,7 @@ export class MCPCommandFactory {
565
566
  ? null
566
567
  : ora("Testing MCP server connections...").start();
567
568
  const sdk = new NeuroLink();
568
- await sdk.getMCPStatus();
569
+ await this.getMCPStatusWithTimeout(sdk, Number(argv.timeout) || MCP_STATUS_TIMEOUT_MS);
569
570
  let serversToTest = await sdk.listMCPServers();
570
571
  if (targetServer) {
571
572
  serversToTest = serversToTest.filter((s) => s.name === targetServer);
@@ -655,7 +656,7 @@ export class MCPCommandFactory {
655
656
  }
656
657
  }
657
658
  const sdk = new NeuroLink();
658
- await sdk.getMCPStatus();
659
+ await this.getMCPStatusWithTimeout(sdk);
659
660
  // Check if server exists and is connected
660
661
  const allServers = await sdk.listMCPServers();
661
662
  const server = allServers.find((s) => s.name === serverName);
@@ -764,7 +765,7 @@ export class MCPCommandFactory {
764
765
  process.exit(1);
765
766
  }
766
767
  const sdk = new NeuroLink();
767
- await sdk.getMCPStatus();
768
+ await this.getMCPStatusWithTimeout(sdk);
768
769
  const allServers = await sdk.listMCPServers();
769
770
  const server = allServers.find((s) => s.name === serverName);
770
771
  if (!server) {
@@ -2234,154 +2235,28 @@ ${tools.length > 0 ? tools.map((t) => `- **${t}**: TODO: Add description`).join(
2234
2235
  try {
2235
2236
  const sdk = new NeuroLink();
2236
2237
  const servers = await sdk.listMCPServers();
2237
- // List mode - show all tools with annotations
2238
2238
  if (argv.list) {
2239
- const spinner = argv.quiet
2240
- ? null
2241
- : ora("Loading tool annotations...").start();
2242
- const allTools = [];
2243
- for (const server of servers) {
2244
- if (server.status !== "connected") {
2245
- continue;
2246
- }
2247
- for (const tool of server.tools || []) {
2248
- const existing = tool
2249
- .annotations;
2250
- const annotations = existing ??
2251
- inferAnnotations({
2252
- name: tool.name,
2253
- description: tool.description,
2254
- });
2255
- allTools.push({
2256
- serverName: server.name,
2257
- serverId: server.id,
2258
- toolName: tool.name,
2259
- description: tool.description,
2260
- annotations,
2261
- });
2262
- }
2263
- }
2264
- if (spinner) {
2265
- spinner.succeed(`Found ${allTools.length} tools`);
2266
- }
2267
- if (argv.format === "json") {
2268
- logger.always(JSON.stringify(allTools, null, 2));
2269
- return;
2270
- }
2271
- logger.always(chalk.bold("\n Tool Annotations:\n"));
2272
- // Group by server
2273
- const byServer = allTools.reduce((acc, tool) => {
2274
- if (!acc[tool.serverId]) {
2275
- acc[tool.serverId] = {
2276
- serverName: tool.serverName,
2277
- tools: [],
2278
- };
2279
- }
2280
- acc[tool.serverId].tools.push(tool);
2281
- return acc;
2282
- }, {});
2283
- for (const [serverId, { serverName, tools }] of Object.entries(byServer)) {
2284
- logger.always(chalk.cyan.bold(`\n${serverName} (${serverId}):`));
2285
- for (const tool of tools) {
2286
- const annotationStr = getAnnotationSummary(tool.annotations);
2287
- logger.always(` ${chalk.yellow(tool.toolName)} ${chalk.gray(annotationStr)}`);
2288
- if (argv.detailed) {
2289
- logger.always(` ${chalk.gray(tool.description)}`);
2290
- }
2291
- }
2292
- }
2293
- logger.always();
2239
+ await this.listToolAnnotations(servers, argv);
2294
2240
  return;
2295
2241
  }
2296
- // Annotate specific tool
2297
2242
  const toolName = argv.tool;
2298
2243
  if (!toolName) {
2299
2244
  logger.error(chalk.red("Tool name is required. Use --tool <name> or --list to see all tools."));
2300
2245
  process.exit(1);
2301
2246
  }
2302
- // Find the tool
2303
- let foundTool = null;
2304
2247
  const serverId = argv.server;
2305
- for (const server of servers) {
2306
- if (serverId && server.id !== serverId) {
2307
- continue;
2308
- }
2309
- for (const tool of server.tools || []) {
2310
- if (tool.name === toolName) {
2311
- foundTool = {
2312
- name: tool.name,
2313
- description: tool.description,
2314
- serverId: server.id,
2315
- serverName: server.name,
2316
- };
2317
- break;
2318
- }
2319
- }
2320
- if (foundTool) {
2321
- break;
2322
- }
2248
+ const foundTool = this.findToolForAnnotation(servers, toolName, serverId);
2249
+ if (foundTool === "ambiguous") {
2250
+ logger.error(chalk.red(`Tool '${toolName}' exists on multiple servers. Use --server <id> to specify which server to annotate.`));
2251
+ logger.always(chalk.yellow("Use 'neurolink mcp annotate --list' to see available tools and their server IDs."));
2252
+ process.exit(1);
2323
2253
  }
2324
2254
  if (!foundTool) {
2325
2255
  logger.error(chalk.red(`Tool '${toolName}' not found.${serverId ? ` Server: ${serverId}` : ""}`));
2326
2256
  logger.always(chalk.yellow("Use 'neurolink mcp annotate --list' to see available tools."));
2327
2257
  process.exit(1);
2328
2258
  }
2329
- // Build annotations from options
2330
- let annotations = {};
2331
- // Parse JSON annotations if provided
2332
- if (argv.annotations) {
2333
- try {
2334
- const parsed = JSON.parse(argv.annotations);
2335
- annotations = { ...annotations, ...parsed };
2336
- }
2337
- catch {
2338
- logger.error(chalk.red("Invalid JSON in --annotations"));
2339
- process.exit(1);
2340
- }
2341
- }
2342
- // Apply individual annotation flags
2343
- if (argv["read-only"] !== undefined) {
2344
- annotations.readOnlyHint = argv["read-only"];
2345
- }
2346
- if (argv.destructive !== undefined) {
2347
- annotations.destructiveHint = argv.destructive;
2348
- }
2349
- if (argv.idempotent !== undefined) {
2350
- annotations.idempotentHint = argv.idempotent;
2351
- }
2352
- if (argv["requires-confirmation"] !== undefined) {
2353
- annotations.requiresConfirmation = argv["requires-confirmation"];
2354
- }
2355
- if (argv.tags) {
2356
- annotations.tags = argv.tags;
2357
- }
2358
- if (argv["estimated-duration"] !== undefined) {
2359
- annotations.estimatedDuration = argv["estimated-duration"];
2360
- }
2361
- if (argv["rate-limit"] !== undefined) {
2362
- annotations.rateLimitHint = argv["rate-limit"];
2363
- }
2364
- if (argv.cost !== undefined) {
2365
- annotations.costHint = argv.cost;
2366
- }
2367
- if (argv.complexity) {
2368
- annotations.complexity = argv.complexity;
2369
- }
2370
- if (argv["security-level"]) {
2371
- annotations.securityLevel = argv["security-level"];
2372
- }
2373
- if (argv.audit !== undefined) {
2374
- annotations.auditRequired = argv.audit;
2375
- }
2376
- // Infer annotations if requested
2377
- if (argv.infer) {
2378
- const inferred = inferAnnotations({
2379
- name: foundTool.name,
2380
- description: foundTool.description,
2381
- });
2382
- annotations = mergeAnnotations(inferred, annotations);
2383
- }
2384
- // Validate annotations
2259
+ const annotations = this.buildAnnotationsFromArgs(argv, foundTool);
2385
2260
  const errors = validateAnnotations(annotations);
2386
2261
  if (errors.length > 0) {
2387
2262
  logger.error(chalk.red("Annotation validation errors:"));
@@ -2396,63 +2271,204 @@ ${tools.length > 0 ? tools.map((t) => `- **${t}**: TODO: Add description`).join(
2396
2271
  logger.always(JSON.stringify(annotations, null, 2));
2397
2272
  return;
2398
2273
  }
2399
- // Display the annotations
2400
- logger.always(chalk.bold("\n Tool Annotation Update:\n"));
2401
- logger.always(` Server: ${chalk.cyan(foundTool.serverName)} (${foundTool.serverId})`);
2402
- logger.always(` Tool: ${chalk.yellow(foundTool.name)}`);
2403
- logger.always(` Description: ${chalk.gray(foundTool.description)}`);
2404
- logger.always();
2405
- logger.always(chalk.bold(" Annotations:"));
2406
- if (annotations.readOnlyHint !== undefined) {
2407
- logger.always(` readOnlyHint: ${annotations.readOnlyHint ? chalk.green("true") : chalk.red("false")}`);
2408
- }
2409
- if (annotations.destructiveHint !== undefined) {
2410
- logger.always(` destructiveHint: ${annotations.destructiveHint ? chalk.red("true") : chalk.green("false")}`);
2411
- }
2412
- if (annotations.idempotentHint !== undefined) {
2413
- logger.always(` idempotentHint: ${annotations.idempotentHint ? chalk.green("true") : chalk.gray("false")}`);
2414
- }
2415
- if (annotations.requiresConfirmation !== undefined) {
2416
- logger.always(` requiresConfirmation: ${annotations.requiresConfirmation ? chalk.yellow("true") : chalk.gray("false")}`);
2417
- }
2418
- if (annotations.tags?.length) {
2419
- logger.always(` tags: ${chalk.blue(annotations.tags.join(", "))}`);
2274
+ this.printAnnotationUpdate(foundTool, annotations);
2275
+ }
2276
+ catch (error) {
2277
+ logger.error(chalk.red(`Annotate command failed: ${error instanceof Error ? error.message : String(error)}`));
2278
+ process.exit(1);
2279
+ }
2280
+ }
2281
+ static async getMCPStatusWithTimeout(sdk, timeoutMs = MCP_STATUS_TIMEOUT_MS) {
2282
+ return withTimeout(sdk.getMCPStatus(), timeoutMs, ErrorFactory.toolTimeout("mcpStatus", timeoutMs));
2283
+ }
2284
+ static async listToolAnnotations(servers, argv) {
2285
+ const spinner = argv.quiet
2286
+ ? null
2287
+ : ora("Loading tool annotations...").start();
2288
+ const allTools = this.collectToolAnnotations(servers);
2289
+ if (spinner) {
2290
+ spinner.succeed(`Found ${allTools.length} tools`);
2291
+ }
2292
+ if (argv.format === "json") {
2293
+ logger.always(JSON.stringify(allTools, null, 2));
2294
+ return;
2295
+ }
2296
+ logger.always(chalk.bold("\n Tool Annotations:\n"));
2297
+ const byServer = allTools.reduce((acc, tool) => {
2298
+ if (!acc[tool.serverId]) {
2299
+ acc[tool.serverId] = {
2300
+ serverName: tool.serverName,
2301
+ tools: [],
2302
+ };
2420
2303
  }
2421
- if (annotations.estimatedDuration !== undefined) {
2422
- logger.always(` estimatedDuration: ${annotations.estimatedDuration}ms`);
2304
+ acc[tool.serverId].tools.push(tool);
2305
+ return acc;
2306
+ }, {});
2307
+ for (const [serverId, { serverName, tools }] of Object.entries(byServer)) {
2308
+ logger.always(chalk.cyan.bold(`\n${serverName} (${serverId}):`));
2309
+ for (const tool of tools) {
2310
+ logger.always(` ${chalk.yellow(tool.toolName)} ${chalk.gray(getAnnotationSummary(tool.annotations))}`);
2311
+ if (argv.detailed) {
2312
+ logger.always(` ${chalk.gray(tool.description)}`);
2313
+ }
2423
2314
  }
2424
- if (annotations.rateLimitHint !== undefined) {
2425
- logger.always(` rateLimitHint: ${annotations.rateLimitHint} calls/min`);
2315
+ }
2316
+ logger.always();
2317
+ }
2318
+ static collectToolAnnotations(servers) {
2319
+ const allTools = [];
2320
+ for (const server of servers) {
2321
+ if (server.status !== "connected") {
2322
+ continue;
2426
2323
  }
2427
- if (annotations.costHint !== undefined) {
2428
- logger.always(` costHint: ${annotations.costHint}`);
2324
+ for (const tool of server.tools || []) {
2325
+ const existing = tool
2326
+ .annotations;
2327
+ allTools.push({
2328
+ serverName: server.name,
2329
+ serverId: server.id,
2330
+ toolName: tool.name,
2331
+ description: tool.description,
2332
+ annotations: existing ??
2333
+ inferAnnotations({
2334
+ name: tool.name,
2335
+ description: tool.description,
2336
+ }),
2337
+ });
2429
2338
  }
2430
- if (annotations.complexity) {
2431
- logger.always(` complexity: ${chalk.cyan(annotations.complexity)}`);
2339
+ }
2340
+ return allTools;
2341
+ }
2342
+ static findToolForAnnotation(servers, toolName, serverId) {
2343
+ const matches = [];
2344
+ for (const server of servers) {
2345
+ if (serverId && server.id !== serverId) {
2346
+ continue;
2347
+ }
2348
+ for (const tool of server.tools || []) {
2349
+ if (tool.name === toolName) {
2350
+ matches.push({
2351
+ name: tool.name,
2352
+ description: tool.description,
2353
+ serverId: server.id,
2354
+ serverName: server.name,
2355
+ });
2356
+ }
2432
2357
  }
2433
- if (annotations.securityLevel) {
2434
- const secColor = annotations.securityLevel === "restricted"
2435
- ? chalk.red
2436
- : annotations.securityLevel === "internal"
2437
- ? chalk.yellow
2438
- : chalk.green;
2439
- logger.always(` securityLevel: ${secColor(annotations.securityLevel)}`);
2358
+ }
2359
+ if (matches.length === 0) {
2360
+ return null;
2361
+ }
2362
+ if (matches.length > 1) {
2363
+ return "ambiguous";
2364
+ }
2365
+ return matches[0] ?? null;
2366
+ }
2367
+ static buildAnnotationsFromArgs(argv, foundTool) {
2368
+ let annotations = {};
2369
+ if (argv.annotations) {
2370
+ try {
2371
+ annotations = {
2372
+ ...annotations,
2373
+ ...JSON.parse(argv.annotations),
2374
+ };
2440
2375
  }
2441
- if (annotations.auditRequired !== undefined) {
2442
- logger.always(` auditRequired: ${annotations.auditRequired ? chalk.yellow("true") : chalk.gray("false")}`);
2376
+ catch {
2377
+ logger.error(chalk.red("Invalid JSON in --annotations"));
2378
+ process.exit(1);
2443
2379
  }
2444
- logger.always();
2445
- logger.always(chalk.gray(" Summary: ") + getAnnotationSummary(annotations));
2446
- logger.always();
2447
- // Note: In a full implementation, this would persist the annotations
2448
- // to a configuration file or database. For now, we just display them.
2449
- logger.always(chalk.blue("Note: Annotations displayed above. To persist annotations, add them to your MCP server configuration."));
2450
- logger.always(chalk.gray(`Example: Add to your server's tool definition or use environment-specific annotation overrides.`));
2451
2380
  }
2452
- catch (error) {
2453
- logger.error(chalk.red(`Annotate command failed: ${error instanceof Error ? error.message : String(error)}`));
2454
- process.exit(1);
2381
+ if (argv["read-only"] !== undefined) {
2382
+ annotations.readOnlyHint = argv["read-only"];
2383
+ }
2384
+ if (argv.destructive !== undefined) {
2385
+ annotations.destructiveHint = argv.destructive;
2386
+ }
2387
+ if (argv.idempotent !== undefined) {
2388
+ annotations.idempotentHint = argv.idempotent;
2389
+ }
2390
+ if (argv["requires-confirmation"] !== undefined) {
2391
+ annotations.requiresConfirmation = argv["requires-confirmation"];
2392
+ }
2393
+ if (argv.tags) {
2394
+ annotations.tags = argv.tags;
2395
+ }
2396
+ if (argv["estimated-duration"] !== undefined) {
2397
+ annotations.estimatedDuration = argv["estimated-duration"];
2398
+ }
2399
+ if (argv["rate-limit"] !== undefined) {
2400
+ annotations.rateLimitHint = argv["rate-limit"];
2401
+ }
2402
+ if (argv.cost !== undefined) {
2403
+ annotations.costHint = argv.cost;
2404
+ }
2405
+ if (argv.complexity) {
2406
+ annotations.complexity = argv.complexity;
2407
+ }
2408
+ if (argv["security-level"]) {
2409
+ annotations.securityLevel = argv["security-level"];
2410
+ }
2411
+ if (argv.audit !== undefined) {
2412
+ annotations.auditRequired = argv.audit;
2413
+ }
2414
+ if (argv.infer) {
2415
+ annotations = mergeAnnotations(inferAnnotations({
2416
+ name: foundTool.name,
2417
+ description: foundTool.description,
2418
+ }), annotations);
2419
+ }
2420
+ return annotations;
2421
+ }
2422
+ static printAnnotationUpdate(foundTool, annotations) {
2423
+ logger.always(chalk.bold("\n Tool Annotation Update:\n"));
2424
+ logger.always(` Server: ${chalk.cyan(foundTool.serverName)} (${foundTool.serverId})`);
2425
+ logger.always(` Tool: ${chalk.yellow(foundTool.name)}`);
2426
+ logger.always(` Description: ${chalk.gray(foundTool.description)}`);
2427
+ logger.always();
2428
+ logger.always(chalk.bold(" Annotations:"));
2429
+ if (annotations.readOnlyHint !== undefined) {
2430
+ logger.always(` readOnlyHint: ${annotations.readOnlyHint ? chalk.green("true") : chalk.red("false")}`);
2431
+ }
2432
+ if (annotations.destructiveHint !== undefined) {
2433
+ logger.always(` destructiveHint: ${annotations.destructiveHint ? chalk.red("true") : chalk.green("false")}`);
2434
+ }
2435
+ if (annotations.idempotentHint !== undefined) {
2436
+ logger.always(` idempotentHint: ${annotations.idempotentHint ? chalk.green("true") : chalk.gray("false")}`);
2437
+ }
2438
+ if (annotations.requiresConfirmation !== undefined) {
2439
+ logger.always(` requiresConfirmation: ${annotations.requiresConfirmation ? chalk.yellow("true") : chalk.gray("false")}`);
2440
+ }
2441
+ if (annotations.tags?.length) {
2442
+ logger.always(` tags: ${chalk.blue(annotations.tags.join(", "))}`);
2443
+ }
2444
+ if (annotations.estimatedDuration !== undefined) {
2445
+ logger.always(` estimatedDuration: ${annotations.estimatedDuration}ms`);
2446
+ }
2447
+ if (annotations.rateLimitHint !== undefined) {
2448
+ logger.always(` rateLimitHint: ${annotations.rateLimitHint} calls/min`);
2449
+ }
2450
+ if (annotations.costHint !== undefined) {
2451
+ logger.always(` costHint: ${annotations.costHint}`);
2452
+ }
2453
+ if (annotations.complexity) {
2454
+ logger.always(` complexity: ${chalk.cyan(annotations.complexity)}`);
2455
+ }
2456
+ if (annotations.securityLevel) {
2457
+ const secColor = annotations.securityLevel === "restricted"
2458
+ ? chalk.red
2459
+ : annotations.securityLevel === "internal"
2460
+ ? chalk.yellow
2461
+ : chalk.green;
2462
+ logger.always(` securityLevel: ${secColor(annotations.securityLevel)}`);
2463
+ }
2464
+ if (annotations.auditRequired !== undefined) {
2465
+ logger.always(` auditRequired: ${annotations.auditRequired ? chalk.yellow("true") : chalk.gray("false")}`);
2455
2466
  }
2467
+ logger.always();
2468
+ logger.always(chalk.gray(" Summary: ") + getAnnotationSummary(annotations));
2469
+ logger.always();
2470
+ logger.always(chalk.blue("Note: Annotations displayed above. To persist annotations, add them to your MCP server configuration."));
2471
+ logger.always(chalk.gray("Example: Add to your server's tool definition or use environment-specific annotation overrides."));
2456
2472
  }
2457
2473
  }
2458
2474
  //# sourceMappingURL=mcp.js.map