@vibecheckai/cli 3.9.1 → 4.0.1

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 (86) hide show
  1. package/README.md +1 -1
  2. package/bin/runners/context/generators/cursor-enhanced.js +99 -13
  3. package/mcp-server/.eslintrc.json +24 -0
  4. package/mcp-server/README.md +425 -135
  5. package/mcp-server/SPEC.md +583 -0
  6. package/mcp-server/configs/README.md +172 -0
  7. package/mcp-server/configs/claude-desktop-pro.json +31 -0
  8. package/mcp-server/configs/claude-desktop-with-workspace.json +25 -0
  9. package/mcp-server/configs/claude-desktop.json +19 -0
  10. package/mcp-server/configs/cursor-mcp.json +21 -0
  11. package/mcp-server/configs/windsurf-mcp.json +17 -0
  12. package/mcp-server/mcp-config.example.json +9 -0
  13. package/mcp-server/package-lock.json +1631 -0
  14. package/mcp-server/package.json +49 -34
  15. package/mcp-server/src/cli.ts +185 -0
  16. package/mcp-server/src/index.ts +85 -0
  17. package/mcp-server/src/server.ts +1933 -0
  18. package/mcp-server/src/services/cache-service.ts +466 -0
  19. package/mcp-server/src/services/cli-service.ts +345 -0
  20. package/mcp-server/src/services/context-manager.ts +717 -0
  21. package/mcp-server/src/services/firewall-service.ts +662 -0
  22. package/mcp-server/src/services/git-service.ts +671 -0
  23. package/mcp-server/src/services/index.ts +52 -0
  24. package/mcp-server/src/services/prompt-builder-service.ts +1031 -0
  25. package/mcp-server/src/services/session-service.ts +550 -0
  26. package/mcp-server/src/services/tier-service.ts +470 -0
  27. package/mcp-server/src/types.ts +351 -0
  28. package/mcp-server/tsconfig.json +16 -27
  29. package/package.json +6 -6
  30. package/mcp-server/.guardrail/audit/audit.log.jsonl +0 -2
  31. package/mcp-server/.specs/architecture.mdc +0 -90
  32. package/mcp-server/.specs/security.mdc +0 -30
  33. package/mcp-server/HARDENING_SUMMARY.md +0 -299
  34. package/mcp-server/agent-checkpoint.js +0 -364
  35. package/mcp-server/agent-firewall-interceptor.js +0 -500
  36. package/mcp-server/architect-tools.js +0 -707
  37. package/mcp-server/audit-mcp.js +0 -206
  38. package/mcp-server/authority-tools.js +0 -569
  39. package/mcp-server/codebase-architect-tools.js +0 -838
  40. package/mcp-server/conductor/conflict-resolver.js +0 -588
  41. package/mcp-server/conductor/execution-planner.js +0 -544
  42. package/mcp-server/conductor/index.js +0 -377
  43. package/mcp-server/conductor/lock-manager.js +0 -615
  44. package/mcp-server/conductor/request-queue.js +0 -550
  45. package/mcp-server/conductor/session-manager.js +0 -500
  46. package/mcp-server/conductor/tools.js +0 -510
  47. package/mcp-server/consolidated-tools.js +0 -1170
  48. package/mcp-server/deprecation-middleware.js +0 -282
  49. package/mcp-server/handlers/index.ts +0 -15
  50. package/mcp-server/handlers/tool-handler.ts +0 -593
  51. package/mcp-server/hygiene-tools.js +0 -428
  52. package/mcp-server/index-v1.js +0 -698
  53. package/mcp-server/index.js +0 -2940
  54. package/mcp-server/intelligence-tools.js +0 -664
  55. package/mcp-server/intent-drift-tools.js +0 -873
  56. package/mcp-server/intent-firewall-interceptor.js +0 -529
  57. package/mcp-server/lib/api-client.cjs +0 -13
  58. package/mcp-server/lib/cache-wrapper.cjs +0 -383
  59. package/mcp-server/lib/error-envelope.js +0 -138
  60. package/mcp-server/lib/executor.ts +0 -499
  61. package/mcp-server/lib/index.ts +0 -29
  62. package/mcp-server/lib/logger.cjs +0 -30
  63. package/mcp-server/lib/rate-limiter.js +0 -166
  64. package/mcp-server/lib/sandbox.test.ts +0 -519
  65. package/mcp-server/lib/sandbox.ts +0 -395
  66. package/mcp-server/lib/types.ts +0 -267
  67. package/mcp-server/logger.js +0 -173
  68. package/mcp-server/manifest.json +0 -473
  69. package/mcp-server/mdc-generator.js +0 -298
  70. package/mcp-server/premium-tools.js +0 -1275
  71. package/mcp-server/proof-tools.js +0 -571
  72. package/mcp-server/registry/tool-registry.js +0 -586
  73. package/mcp-server/registry/tools.json +0 -619
  74. package/mcp-server/registry.test.ts +0 -340
  75. package/mcp-server/test-mcp.js +0 -108
  76. package/mcp-server/test-tools.js +0 -36
  77. package/mcp-server/tests/tier-gating.test.js +0 -297
  78. package/mcp-server/tier-auth.js +0 -767
  79. package/mcp-server/tools/index.js +0 -72
  80. package/mcp-server/tools-reorganized.ts +0 -244
  81. package/mcp-server/tools-v3.js +0 -1004
  82. package/mcp-server/truth-context.js +0 -622
  83. package/mcp-server/truth-firewall-tools.js +0 -2183
  84. package/mcp-server/vibecheck-2.0-tools.js +0 -761
  85. package/mcp-server/vibecheck-mcp-server-3.2.0.tgz +0 -0
  86. package/mcp-server/vibecheck-tools.js +0 -1075
@@ -1,593 +0,0 @@
1
- /**
2
- * Universal Tool Handler
3
- *
4
- * Registry-driven dispatcher for all MCP tools.
5
- *
6
- * Pipeline:
7
- * 1) Load tool definition from registry
8
- * 2) Validate input schema
9
- * 3) Sandbox path validation
10
- * 4) Execute CLI command
11
- * 5) Parse output into canonical JSON
12
- * 6) Validate output schema
13
- * 7) Return response with error envelope
14
- */
15
-
16
- import * as fs from "node:fs";
17
- import * as path from "node:path";
18
- import { fileURLToPath } from "node:url";
19
- import Ajv from "ajv";
20
- import type {
21
- RunRequest,
22
- RunResponse,
23
- ErrorEnvelope,
24
- ErrorCode,
25
- ToolDefinition,
26
- ToolResult,
27
- ValidationError,
28
- Finding,
29
- } from "../lib/types.js";
30
- import { resolveSandboxPath, configFromRunRequest, type SandboxConfig } from "../lib/sandbox.js";
31
- import { CliExecutor, parseCliOutput, sortFindings, buildCliArgs } from "../lib/executor.js";
32
-
33
- // ESM __dirname equivalent
34
- const __filename = fileURLToPath(import.meta.url);
35
- const __dirname = path.dirname(__filename);
36
-
37
- /**
38
- * Simple PathSandbox wrapper class using the sandbox functions
39
- */
40
- class PathSandbox {
41
- private config: SandboxConfig;
42
-
43
- constructor(options: { projectRoot: string }) {
44
- this.config = {
45
- workspaceRoot: options.projectRoot,
46
- includeThirdParty: false,
47
- includeGenerated: false,
48
- };
49
- }
50
-
51
- assertAllowed(inputPath: string): string {
52
- const result = resolveSandboxPath(inputPath, this.config);
53
- if (!result.valid) {
54
- const error = new Error(result.error || "Path not allowed") as Error & { violationType?: string };
55
- error.violationType = result.errorCode;
56
- throw error;
57
- }
58
- return result.resolvedPath!;
59
- }
60
-
61
- validate(inputPath: string): { allowed: boolean; error?: string } {
62
- const result = resolveSandboxPath(inputPath, this.config);
63
- return {
64
- allowed: result.valid,
65
- error: result.error,
66
- };
67
- }
68
- }
69
-
70
- // ═══════════════════════════════════════════════════════════════════════════════
71
- // REGISTRY
72
- // ═══════════════════════════════════════════════════════════════════════════════
73
-
74
- interface ToolRegistry {
75
- version: string;
76
- tools: Record<string, ToolDefinition>;
77
- $defs?: Record<string, unknown>;
78
- }
79
-
80
- let registryCache: ToolRegistry | null = null;
81
-
82
- /**
83
- * Load tool registry (cached)
84
- */
85
- function loadRegistry(): ToolRegistry {
86
- if (registryCache) return registryCache;
87
-
88
- const registryPath = path.join(__dirname, "../registry/tools.json");
89
- const content = fs.readFileSync(registryPath, "utf-8");
90
- registryCache = JSON.parse(content) as ToolRegistry;
91
- return registryCache;
92
- }
93
-
94
- /**
95
- * Get tool definition by name (supports aliases)
96
- */
97
- function getToolDefinition(toolName: string): ToolDefinition | null {
98
- const registry = loadRegistry();
99
-
100
- // Direct match
101
- if (registry.tools[toolName]) {
102
- return registry.tools[toolName];
103
- }
104
-
105
- // Search aliases
106
- for (const tool of Object.values(registry.tools)) {
107
- if (tool.aliases?.includes(toolName)) {
108
- return tool;
109
- }
110
- }
111
-
112
- return null;
113
- }
114
-
115
- // ═══════════════════════════════════════════════════════════════════════════════
116
- // VALIDATION
117
- // ═══════════════════════════════════════════════════════════════════════════════
118
-
119
- const AjvClass = Ajv.default || Ajv;
120
- const ajv = new AjvClass({ allErrors: true, strict: false });
121
-
122
- /**
123
- * Validate data against JSON schema
124
- */
125
- function validateSchema(
126
- data: unknown,
127
- schema: unknown,
128
- _schemaName: string
129
- ): ValidationError[] {
130
- const validate = ajv.compile(schema as object);
131
- const valid = validate(data);
132
-
133
- if (valid) return [];
134
-
135
- return (validate.errors || []).map((err: { instancePath?: string; message?: string; params?: { allowedValues?: string[] }; data?: unknown }) => ({
136
- path: err.instancePath || "/",
137
- message: err.message || "Validation failed",
138
- expected: err.params?.allowedValues?.join(", "),
139
- actual: String(err.data),
140
- }));
141
- }
142
-
143
- // ═══════════════════════════════════════════════════════════════════════════════
144
- // ERROR HELPERS
145
- // ═══════════════════════════════════════════════════════════════════════════════
146
-
147
- const ERROR_NEXT_STEPS: Record<ErrorCode, string[]> = {
148
- INPUT_VALIDATION: [
149
- "Check the tool's inputSchema for required fields",
150
- "Ensure all values match expected types",
151
- "Review the validation errors for specifics",
152
- ],
153
- TOOL_NOT_FOUND: [
154
- "Check the tool name is spelled correctly",
155
- "Use 'vibecheck.scan' format for tool names",
156
- "List available tools with the registry",
157
- ],
158
- TIER_REQUIRED: [
159
- "This tool requires a Pro subscription ($49/mo)",
160
- "Upgrade at https://vibecheckai.dev/pricing",
161
- "Some tools have free alternatives",
162
- ],
163
- NOT_ENTITLED: [
164
- "This tool requires a Pro subscription ($49/mo)",
165
- "Upgrade at https://vibecheckai.dev/pricing",
166
- "Run: vibecheck upgrade",
167
- ],
168
- OPTION_NOT_ENTITLED: [
169
- "This option requires a Pro subscription ($49/mo)",
170
- "The base tool is available on FREE tier",
171
- "Upgrade at https://vibecheckai.dev/pricing",
172
- ],
173
- PATH_VIOLATION: [
174
- "Ensure paths are within the project directory",
175
- "Do not use absolute paths or path traversal (..)",
176
- "Check for symlinks pointing outside the project",
177
- ],
178
- EXECUTOR_FAILED: [
179
- "Check the CLI command output for details",
180
- "Run 'vibecheck doctor' to diagnose issues",
181
- "Ensure dependencies are installed",
182
- ],
183
- OUTPUT_PARSE_ERROR: [
184
- "The CLI output was not valid JSON",
185
- "This may indicate a CLI bug",
186
- "Try running the command directly for debugging",
187
- ],
188
- OUTPUT_VALIDATION: [
189
- "The CLI output didn't match expected schema",
190
- "This may indicate a version mismatch",
191
- "Please report this issue",
192
- ],
193
- TIMEOUT: [
194
- "The command timed out",
195
- "Try a smaller scope (fewer files/categories)",
196
- "Increase timeout if running intensive operations",
197
- ],
198
- INTERNAL_ERROR: [
199
- "An unexpected error occurred",
200
- "Please report this issue with the requestId",
201
- "https://github.com/vibecheckai/vibecheck/issues",
202
- ],
203
- INVALID_API_KEY: [
204
- "The API key is invalid or expired",
205
- "Run: vibecheck login",
206
- "Check your credentials at https://vibecheckai.dev/dashboard",
207
- ],
208
- RATE_LIMITED: [
209
- "Too many requests - please wait and try again",
210
- "Consider upgrading for higher limits",
211
- "https://vibecheckai.dev/pricing",
212
- ],
213
- };
214
-
215
- function createErrorEnvelope(
216
- code: ErrorCode,
217
- message: string,
218
- requestId: string,
219
- extra?: Partial<ErrorEnvelope>
220
- ): ErrorEnvelope {
221
- return {
222
- code,
223
- message,
224
- nextSteps: ERROR_NEXT_STEPS[code],
225
- requestId,
226
- ...extra,
227
- };
228
- }
229
-
230
- // ═══════════════════════════════════════════════════════════════════════════════
231
- // MAIN HANDLER
232
- // ═══════════════════════════════════════════════════════════════════════════════
233
-
234
- /**
235
- * Handle a tool execution request
236
- */
237
- export async function handleToolRequest(request: RunRequest): Promise<RunResponse> {
238
- const startedAt = new Date().toISOString();
239
- const startTime = Date.now();
240
-
241
- const baseMetadata = {
242
- startedAt,
243
- completedAt: "",
244
- durationMs: 0,
245
- tool: request.tool,
246
- };
247
-
248
- try {
249
- // 1) Load tool definition
250
- const toolDef = getToolDefinition(request.tool);
251
- if (!toolDef) {
252
- return buildErrorResponse(
253
- request,
254
- createErrorEnvelope("TOOL_NOT_FOUND", `Unknown tool: ${request.tool}`, request.requestId),
255
- baseMetadata,
256
- startTime
257
- );
258
- }
259
-
260
- // 2) Check tier access (aligned with CLI entitlements-v2.js)
261
- const userTier = request.context?.tier || "free";
262
-
263
- // Developer mode bypass (blocked in production environments)
264
- const isDevProBypassAllowed = (): boolean => {
265
- if (process.env.NODE_ENV === "production") return false;
266
- if (process.env.CI === "true" || process.env.CI === "1") return false;
267
- return process.env.VIBECHECK_DEV_PRO === "1";
268
- };
269
- const isDevMode = isDevProBypassAllowed();
270
-
271
- if (toolDef.tier === "pro" && userTier !== "pro" && !isDevMode) {
272
- return buildErrorResponse(
273
- request,
274
- createErrorEnvelope(
275
- "NOT_ENTITLED",
276
- "Requires PRO",
277
- request.requestId,
278
- {
279
- userAction: "Open billing",
280
- retryable: false,
281
- tier: userTier,
282
- required: "pro",
283
- tool: toolDef.name,
284
- upgradeUrl: "https://vibecheckai.dev/pricing",
285
- }
286
- ),
287
- baseMetadata,
288
- startTime
289
- );
290
- }
291
-
292
- // 3) Validate input schema
293
- const inputErrors = validateSchema(request.args, toolDef.inputSchema, "input");
294
- if (inputErrors.length > 0) {
295
- return buildErrorResponse(
296
- request,
297
- createErrorEnvelope(
298
- "INPUT_VALIDATION",
299
- "Input validation failed",
300
- request.requestId,
301
- { validationErrors: inputErrors }
302
- ),
303
- baseMetadata,
304
- startTime
305
- );
306
- }
307
-
308
- // 4) Resolve and sandbox project path
309
- const projectPath = String(request.args.projectPath || request.context?.projectRoot || ".");
310
- let sandbox: PathSandbox;
311
- let resolvedProjectPath: string;
312
-
313
- try {
314
- // Determine project root (use provided or current working directory)
315
- const baseProjectRoot = request.context?.projectRoot || process.cwd();
316
- sandbox = new PathSandbox({ projectRoot: baseProjectRoot });
317
- resolvedProjectPath = sandbox.assertAllowed(projectPath);
318
- } catch (err) {
319
- const error = err as Error & { violationType?: string };
320
- return buildErrorResponse(
321
- request,
322
- createErrorEnvelope(
323
- "PATH_VIOLATION",
324
- error.message,
325
- request.requestId,
326
- { receipt: `violation: ${error.violationType}` }
327
- ),
328
- baseMetadata,
329
- startTime
330
- );
331
- }
332
-
333
- // Validate any other path arguments
334
- const pathArgs = ["outputPath", "file", "filePath"];
335
- for (const argName of pathArgs) {
336
- const argValue = request.args[argName];
337
- if (argValue && typeof argValue === "string") {
338
- const result = sandbox.validate(argValue);
339
- if (!result.allowed) {
340
- return buildErrorResponse(
341
- request,
342
- createErrorEnvelope(
343
- "PATH_VIOLATION",
344
- `Invalid path in '${argName}': ${result.error}`,
345
- request.requestId
346
- ),
347
- baseMetadata,
348
- startTime
349
- );
350
- }
351
- }
352
- }
353
-
354
- // 5) Build CLI arguments
355
- const cliArgs = buildCliArgs(
356
- { ...request.args, projectPath: resolvedProjectPath },
357
- toolDef.cli.argMap,
358
- toolDef.cli.fixedFlags
359
- );
360
-
361
- // 6) Execute CLI command
362
- const executor = new CliExecutor({
363
- cwd: resolvedProjectPath,
364
- timeoutMs: toolDef.cli.timeoutMs || 300000,
365
- requestId: request.requestId,
366
- traceId: request.traceId,
367
- });
368
-
369
- const execResult = await executor.execute(toolDef.cli.command, cliArgs);
370
-
371
- // Check for timeout
372
- if (execResult.timedOut) {
373
- return buildErrorResponse(
374
- request,
375
- createErrorEnvelope(
376
- "TIMEOUT",
377
- `Command timed out after ${toolDef.cli.timeoutMs}ms`,
378
- request.requestId
379
- ),
380
- {
381
- ...baseMetadata,
382
- cliCommand: `vibecheck ${toolDef.cli.command}`,
383
- exitCode: execResult.exitCode,
384
- },
385
- startTime
386
- );
387
- }
388
-
389
- // Check for execution failure (exit code > 2 indicates error, not just findings)
390
- if (execResult.exitCode > 10) {
391
- return buildErrorResponse(
392
- request,
393
- createErrorEnvelope(
394
- "EXECUTOR_FAILED",
395
- execResult.stderr || `CLI exited with code ${execResult.exitCode}`,
396
- request.requestId,
397
- { receipt: `exit_code: ${execResult.exitCode}` }
398
- ),
399
- {
400
- ...baseMetadata,
401
- cliCommand: `vibecheck ${toolDef.cli.command}`,
402
- exitCode: execResult.exitCode,
403
- },
404
- startTime
405
- );
406
- }
407
-
408
- // 7) Parse CLI output
409
- let toolResult: ToolResult;
410
- try {
411
- toolResult = parseCliOutput(execResult.stdout, execResult.stderr);
412
- } catch (err) {
413
- return buildErrorResponse(
414
- request,
415
- createErrorEnvelope(
416
- "OUTPUT_PARSE_ERROR",
417
- `Failed to parse CLI output: ${(err as Error).message}`,
418
- request.requestId
419
- ),
420
- {
421
- ...baseMetadata,
422
- cliCommand: `vibecheck ${toolDef.cli.command}`,
423
- exitCode: execResult.exitCode,
424
- },
425
- startTime
426
- );
427
- }
428
-
429
- // 8) Sort findings for stable output
430
- if (toolResult.findings) {
431
- toolResult.findings = sortFindings(toolResult.findings);
432
- }
433
-
434
- // 9) Validate output schema (soft validation - log but don't fail)
435
- const outputErrors = validateSchema(toolResult, toolDef.outputSchema, "output");
436
- if (outputErrors.length > 0) {
437
- // Log but don't fail - output schema validation is informational
438
- console.error(
439
- `[WARN] Output schema validation errors for ${toolDef.name}:`,
440
- JSON.stringify(outputErrors)
441
- );
442
- }
443
-
444
- // 10) Build success response
445
- const completedAt = new Date().toISOString();
446
- return {
447
- requestId: request.requestId,
448
- traceId: request.traceId,
449
- ok: true,
450
- data: toolResult,
451
- metadata: {
452
- startedAt,
453
- completedAt,
454
- durationMs: Date.now() - startTime,
455
- tool: toolDef.name,
456
- cliCommand: `vibecheck ${toolDef.cli.command}`,
457
- exitCode: execResult.exitCode,
458
- },
459
- };
460
- } catch (err) {
461
- // Catch-all for unexpected errors
462
- const error = err as Error;
463
- return buildErrorResponse(
464
- request,
465
- createErrorEnvelope(
466
- "INTERNAL_ERROR",
467
- "An unexpected error occurred",
468
- request.requestId,
469
- { receipt: error.message }
470
- ),
471
- baseMetadata,
472
- startTime
473
- );
474
- }
475
- }
476
-
477
- /**
478
- * Build error response
479
- */
480
- function buildErrorResponse(
481
- request: RunRequest,
482
- error: ErrorEnvelope,
483
- metadata: Partial<RunResponse["metadata"]>,
484
- startTime: number
485
- ): RunResponse {
486
- const completedAt = new Date().toISOString();
487
- return {
488
- requestId: request.requestId,
489
- traceId: request.traceId,
490
- ok: false,
491
- error,
492
- metadata: {
493
- startedAt: metadata.startedAt || completedAt,
494
- completedAt,
495
- durationMs: Date.now() - startTime,
496
- tool: metadata.tool || request.tool,
497
- cliCommand: metadata.cliCommand,
498
- exitCode: metadata.exitCode,
499
- },
500
- };
501
- }
502
-
503
- // ═══════════════════════════════════════════════════════════════════════════════
504
- // REGISTRY UTILITIES (exported for testing)
505
- // ═══════════════════════════════════════════════════════════════════════════════
506
-
507
- export function getAllTools(): ToolDefinition[] {
508
- const registry = loadRegistry();
509
- return Object.values(registry.tools);
510
- }
511
-
512
- export function getToolByName(name: string): ToolDefinition | null {
513
- return getToolDefinition(name);
514
- }
515
-
516
- export function listToolNames(): string[] {
517
- const registry = loadRegistry();
518
- return Object.keys(registry.tools);
519
- }
520
-
521
- export function getToolsByTier(tier: "free" | "pro"): ToolDefinition[] {
522
- return getAllTools().filter((t) => t.tier === tier);
523
- }
524
-
525
- export function getToolsByCategory(category: string): ToolDefinition[] {
526
- return getAllTools().filter((t) => t.category === category);
527
- }
528
-
529
- /**
530
- * Validate the entire registry
531
- */
532
- export function validateRegistry(): { valid: boolean; errors: string[] } {
533
- const errors: string[] = [];
534
- const registry = loadRegistry();
535
-
536
- for (const [name, tool] of Object.entries(registry.tools)) {
537
- // Check name matches key
538
- if (tool.name !== name) {
539
- errors.push(`Tool '${name}' has mismatched name property: '${tool.name}'`);
540
- }
541
-
542
- // Check required fields
543
- if (!tool.tier) errors.push(`Tool '${name}' missing tier`);
544
- if (!tool.category) errors.push(`Tool '${name}' missing category`);
545
- if (!tool.inputSchema) errors.push(`Tool '${name}' missing inputSchema`);
546
- if (!tool.outputSchema) errors.push(`Tool '${name}' missing outputSchema`);
547
- if (!tool.cli) errors.push(`Tool '${name}' missing cli mapping`);
548
- if (!tool.cli?.command) errors.push(`Tool '${name}' missing cli.command`);
549
- if (!tool.cli?.argMap) errors.push(`Tool '${name}' missing cli.argMap`);
550
-
551
- // Validate tier
552
- if (tool.tier && !["free", "pro"].includes(tool.tier)) {
553
- errors.push(`Tool '${name}' has invalid tier: '${tool.tier}'`);
554
- }
555
-
556
- // Validate input schema is valid JSON Schema
557
- if (tool.inputSchema) {
558
- try {
559
- ajv.compile(tool.inputSchema);
560
- } catch (err) {
561
- errors.push(`Tool '${name}' has invalid inputSchema: ${(err as Error).message}`);
562
- }
563
- }
564
-
565
- // Validate output schema is valid JSON Schema
566
- if (tool.outputSchema) {
567
- try {
568
- ajv.compile(tool.outputSchema);
569
- } catch (err) {
570
- errors.push(`Tool '${name}' has invalid outputSchema: ${(err as Error).message}`);
571
- }
572
- }
573
- }
574
-
575
- return {
576
- valid: errors.length === 0,
577
- errors,
578
- };
579
- }
580
-
581
- // ═══════════════════════════════════════════════════════════════════════════════
582
- // DEFAULT EXPORT
583
- // ═══════════════════════════════════════════════════════════════════════════════
584
-
585
- export default {
586
- handleToolRequest,
587
- getAllTools,
588
- getToolByName,
589
- listToolNames,
590
- getToolsByTier,
591
- getToolsByCategory,
592
- validateRegistry,
593
- };