@mcpspec/shared 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MCPSpec Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,1062 @@
1
+ import { Writable, Readable } from 'node:stream';
2
+ import { z } from 'zod';
3
+
4
+ declare const EXIT_CODES: {
5
+ readonly SUCCESS: 0;
6
+ readonly TEST_FAILURE: 1;
7
+ readonly ERROR: 2;
8
+ readonly CONFIG_ERROR: 3;
9
+ readonly CONNECTION_ERROR: 4;
10
+ readonly TIMEOUT: 5;
11
+ readonly SECURITY_FINDINGS: 6;
12
+ readonly VALIDATION_ERROR: 7;
13
+ readonly INTERRUPTED: 130;
14
+ };
15
+ type ExitCode = (typeof EXIT_CODES)[keyof typeof EXIT_CODES];
16
+
17
+ type MessageDirection = 'outgoing' | 'incoming';
18
+ interface ProtocolLogEntry {
19
+ id: string;
20
+ timestamp: number;
21
+ direction: MessageDirection;
22
+ message: Record<string, unknown>;
23
+ jsonrpcId?: string | number | null;
24
+ method?: string;
25
+ isError?: boolean;
26
+ roundTripMs?: number;
27
+ }
28
+
29
+ interface SavedServerConnection {
30
+ id: string;
31
+ name: string;
32
+ transport: TransportType;
33
+ command?: string;
34
+ args?: string[];
35
+ url?: string;
36
+ env?: Record<string, string>;
37
+ createdAt: string;
38
+ updatedAt: string;
39
+ }
40
+ interface SavedCollection {
41
+ id: string;
42
+ name: string;
43
+ description?: string;
44
+ yaml: string;
45
+ createdAt: string;
46
+ updatedAt: string;
47
+ }
48
+ interface TestRunRecord {
49
+ id: string;
50
+ collectionId?: string;
51
+ collectionName: string;
52
+ serverId?: string;
53
+ status: 'running' | 'completed' | 'failed' | 'cancelled';
54
+ summary?: TestSummary;
55
+ results?: TestResult[];
56
+ startedAt: string;
57
+ completedAt?: string;
58
+ duration?: number;
59
+ }
60
+ interface ApiResponse<T> {
61
+ data: T;
62
+ }
63
+ interface ApiListResponse<T> {
64
+ data: T[];
65
+ total: number;
66
+ }
67
+ interface ApiError {
68
+ error: string;
69
+ message: string;
70
+ details?: unknown;
71
+ }
72
+
73
+ type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting' | 'disconnecting' | 'error';
74
+ interface ConnectionConfig {
75
+ maxReconnectAttempts: number;
76
+ reconnectBackoff: 'exponential';
77
+ initialReconnectDelay: number;
78
+ maxReconnectDelay: number;
79
+ }
80
+ interface ProcessConfig {
81
+ command: string;
82
+ args: string[];
83
+ cwd?: string;
84
+ env?: Record<string, string>;
85
+ timeout?: number;
86
+ }
87
+ interface ManagedProcess {
88
+ id: string;
89
+ pid: number;
90
+ command: string;
91
+ args: string[];
92
+ startedAt: Date;
93
+ stdin: Writable;
94
+ stdout: Readable;
95
+ stderr: Readable;
96
+ }
97
+ interface TimeoutConfig {
98
+ test: number;
99
+ mcpCall: number;
100
+ transport: number;
101
+ assertion: number;
102
+ cleanup: number;
103
+ }
104
+ declare const DEFAULT_TIMEOUTS: TimeoutConfig;
105
+ interface RateLimitConfig {
106
+ maxCallsPerSecond: number;
107
+ maxConcurrent: number;
108
+ backoff: {
109
+ initial: number;
110
+ multiplier: number;
111
+ max: number;
112
+ };
113
+ }
114
+ declare const DEFAULT_RATE_LIMIT: RateLimitConfig;
115
+ type TransportType = 'stdio' | 'sse' | 'streamable-http';
116
+ interface ServerConfig {
117
+ name?: string;
118
+ transport: TransportType;
119
+ command?: string;
120
+ args?: string[];
121
+ url?: string;
122
+ env?: Record<string, string>;
123
+ timeouts?: Partial<TimeoutConfig>;
124
+ }
125
+ interface CollectionDefinition {
126
+ schemaVersion?: string;
127
+ name: string;
128
+ description?: string;
129
+ server: string | ServerConfig;
130
+ environments?: Record<string, EnvironmentDefinition>;
131
+ defaultEnvironment?: string;
132
+ tests: TestDefinition[];
133
+ }
134
+ interface EnvironmentDefinition {
135
+ variables: Record<string, string>;
136
+ }
137
+ interface TestDefinition {
138
+ id?: string;
139
+ name: string;
140
+ tags?: string[];
141
+ timeout?: number;
142
+ retries?: number;
143
+ type?: 'tool' | 'resource';
144
+ tool?: string;
145
+ call?: string;
146
+ input?: Record<string, unknown>;
147
+ with?: Record<string, unknown>;
148
+ assertions?: AssertionDefinition[];
149
+ expect?: SimpleExpectation[];
150
+ expectError?: boolean;
151
+ extract?: ExtractionDefinition[];
152
+ }
153
+ type SimpleExpectation = {
154
+ exists: string;
155
+ } | {
156
+ equals: [string, unknown];
157
+ } | {
158
+ contains: [string, unknown];
159
+ } | {
160
+ matches: [string, string];
161
+ };
162
+ interface AssertionDefinition {
163
+ type: AssertionType;
164
+ path?: string;
165
+ value?: unknown;
166
+ expected?: unknown;
167
+ pattern?: string;
168
+ maxMs?: number;
169
+ operator?: string;
170
+ expr?: string;
171
+ }
172
+ type AssertionType = 'schema' | 'equals' | 'contains' | 'exists' | 'matches' | 'type' | 'length' | 'latency' | 'mimeType' | 'expression';
173
+ interface ExtractionDefinition {
174
+ name: string;
175
+ path: string;
176
+ }
177
+ interface TestRunResult {
178
+ id: string;
179
+ collectionName: string;
180
+ startedAt: Date;
181
+ completedAt: Date;
182
+ duration: number;
183
+ results: TestResult[];
184
+ summary: TestSummary;
185
+ }
186
+ interface TestResult {
187
+ testId: string;
188
+ testName: string;
189
+ status: 'passed' | 'failed' | 'skipped' | 'error';
190
+ duration: number;
191
+ assertions: AssertionResult[];
192
+ error?: string;
193
+ extractedVariables?: Record<string, unknown>;
194
+ }
195
+ interface AssertionResult {
196
+ type: AssertionType;
197
+ passed: boolean;
198
+ message: string;
199
+ expected?: unknown;
200
+ actual?: unknown;
201
+ }
202
+ interface TestSummary {
203
+ total: number;
204
+ passed: number;
205
+ failed: number;
206
+ skipped: number;
207
+ errors: number;
208
+ duration: number;
209
+ }
210
+ type ReporterType = 'console' | 'json' | 'junit' | 'html' | 'tap';
211
+ type SecurityScanMode = 'passive' | 'active' | 'aggressive';
212
+ type SeverityLevel = 'info' | 'low' | 'medium' | 'high' | 'critical';
213
+ interface SecurityFinding {
214
+ id: string;
215
+ rule: string;
216
+ severity: SeverityLevel;
217
+ title: string;
218
+ description: string;
219
+ evidence?: string;
220
+ remediation?: string;
221
+ }
222
+ interface SecurityScanConfig {
223
+ mode: SecurityScanMode;
224
+ rules?: string[];
225
+ severityThreshold?: SeverityLevel;
226
+ acknowledgeRisk?: boolean;
227
+ timeout?: number;
228
+ maxProbesPerTool?: number;
229
+ }
230
+ interface SecurityScanResult {
231
+ id: string;
232
+ serverName: string;
233
+ mode: SecurityScanMode;
234
+ startedAt: Date;
235
+ completedAt: Date;
236
+ findings: SecurityFinding[];
237
+ summary: SecurityScanSummary;
238
+ }
239
+ interface SecurityScanSummary {
240
+ totalFindings: number;
241
+ bySeverity: Record<SeverityLevel, number>;
242
+ byRule: Record<string, number>;
243
+ }
244
+ interface BenchmarkConfig {
245
+ iterations: number;
246
+ warmupIterations: number;
247
+ concurrency: number;
248
+ timeout: number;
249
+ }
250
+ interface BenchmarkResult {
251
+ toolName: string;
252
+ iterations: number;
253
+ stats: BenchmarkStats;
254
+ errors: number;
255
+ startedAt: Date;
256
+ completedAt: Date;
257
+ }
258
+ interface BenchmarkStats {
259
+ min: number;
260
+ max: number;
261
+ mean: number;
262
+ median: number;
263
+ p95: number;
264
+ p99: number;
265
+ stddev: number;
266
+ }
267
+ interface ProfileEntry {
268
+ toolName: string;
269
+ startMs: number;
270
+ durationMs: number;
271
+ success: boolean;
272
+ error?: string;
273
+ }
274
+ interface WaterfallEntry {
275
+ label: string;
276
+ startMs: number;
277
+ durationMs: number;
278
+ }
279
+ interface MCPScore {
280
+ overall: number;
281
+ categories: {
282
+ documentation: number;
283
+ errorHandling: number;
284
+ schemaQuality: number;
285
+ performance: number;
286
+ security: number;
287
+ };
288
+ }
289
+ type WSClientMessage = {
290
+ type: 'subscribe';
291
+ channel: string;
292
+ } | {
293
+ type: 'unsubscribe';
294
+ channel: string;
295
+ } | {
296
+ type: 'ping';
297
+ };
298
+ type WSServerMessage = {
299
+ type: 'subscribed';
300
+ channel: string;
301
+ } | {
302
+ type: 'event';
303
+ channel: string;
304
+ event: string;
305
+ data: unknown;
306
+ } | {
307
+ type: 'pong';
308
+ };
309
+ interface ErrorTemplate {
310
+ title: string;
311
+ description: string;
312
+ suggestions: string[];
313
+ docs?: string;
314
+ }
315
+
316
+ declare const createServerSchema: z.ZodObject<{
317
+ name: z.ZodString;
318
+ transport: z.ZodEnum<["stdio", "sse", "streamable-http"]>;
319
+ command: z.ZodOptional<z.ZodString>;
320
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
321
+ url: z.ZodOptional<z.ZodString>;
322
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
323
+ }, "strip", z.ZodTypeAny, {
324
+ name: string;
325
+ transport: "stdio" | "sse" | "streamable-http";
326
+ command?: string | undefined;
327
+ args?: string[] | undefined;
328
+ url?: string | undefined;
329
+ env?: Record<string, string> | undefined;
330
+ }, {
331
+ name: string;
332
+ transport: "stdio" | "sse" | "streamable-http";
333
+ command?: string | undefined;
334
+ args?: string[] | undefined;
335
+ url?: string | undefined;
336
+ env?: Record<string, string> | undefined;
337
+ }>;
338
+ declare const updateServerSchema: z.ZodObject<{
339
+ name: z.ZodOptional<z.ZodString>;
340
+ transport: z.ZodOptional<z.ZodEnum<["stdio", "sse", "streamable-http"]>>;
341
+ command: z.ZodOptional<z.ZodOptional<z.ZodString>>;
342
+ args: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
343
+ url: z.ZodOptional<z.ZodOptional<z.ZodString>>;
344
+ env: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
345
+ }, "strip", z.ZodTypeAny, {
346
+ name?: string | undefined;
347
+ transport?: "stdio" | "sse" | "streamable-http" | undefined;
348
+ command?: string | undefined;
349
+ args?: string[] | undefined;
350
+ url?: string | undefined;
351
+ env?: Record<string, string> | undefined;
352
+ }, {
353
+ name?: string | undefined;
354
+ transport?: "stdio" | "sse" | "streamable-http" | undefined;
355
+ command?: string | undefined;
356
+ args?: string[] | undefined;
357
+ url?: string | undefined;
358
+ env?: Record<string, string> | undefined;
359
+ }>;
360
+ declare const createCollectionSchema: z.ZodObject<{
361
+ name: z.ZodString;
362
+ description: z.ZodOptional<z.ZodString>;
363
+ yaml: z.ZodString;
364
+ }, "strip", z.ZodTypeAny, {
365
+ name: string;
366
+ yaml: string;
367
+ description?: string | undefined;
368
+ }, {
369
+ name: string;
370
+ yaml: string;
371
+ description?: string | undefined;
372
+ }>;
373
+ declare const updateCollectionSchema: z.ZodObject<{
374
+ name: z.ZodOptional<z.ZodString>;
375
+ description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
376
+ yaml: z.ZodOptional<z.ZodString>;
377
+ }, "strip", z.ZodTypeAny, {
378
+ name?: string | undefined;
379
+ description?: string | undefined;
380
+ yaml?: string | undefined;
381
+ }, {
382
+ name?: string | undefined;
383
+ description?: string | undefined;
384
+ yaml?: string | undefined;
385
+ }>;
386
+ declare const triggerRunSchema: z.ZodObject<{
387
+ collectionId: z.ZodString;
388
+ serverId: z.ZodOptional<z.ZodString>;
389
+ environment: z.ZodOptional<z.ZodString>;
390
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
391
+ parallelism: z.ZodOptional<z.ZodNumber>;
392
+ }, "strip", z.ZodTypeAny, {
393
+ collectionId: string;
394
+ serverId?: string | undefined;
395
+ environment?: string | undefined;
396
+ tags?: string[] | undefined;
397
+ parallelism?: number | undefined;
398
+ }, {
399
+ collectionId: string;
400
+ serverId?: string | undefined;
401
+ environment?: string | undefined;
402
+ tags?: string[] | undefined;
403
+ parallelism?: number | undefined;
404
+ }>;
405
+ declare const inspectConnectSchema: z.ZodObject<{
406
+ transport: z.ZodEnum<["stdio", "sse", "streamable-http"]>;
407
+ command: z.ZodOptional<z.ZodString>;
408
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
409
+ url: z.ZodOptional<z.ZodString>;
410
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
411
+ }, "strip", z.ZodTypeAny, {
412
+ transport: "stdio" | "sse" | "streamable-http";
413
+ command?: string | undefined;
414
+ args?: string[] | undefined;
415
+ url?: string | undefined;
416
+ env?: Record<string, string> | undefined;
417
+ }, {
418
+ transport: "stdio" | "sse" | "streamable-http";
419
+ command?: string | undefined;
420
+ args?: string[] | undefined;
421
+ url?: string | undefined;
422
+ env?: Record<string, string> | undefined;
423
+ }>;
424
+ declare const inspectCallSchema: z.ZodObject<{
425
+ sessionId: z.ZodString;
426
+ tool: z.ZodString;
427
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
428
+ }, "strip", z.ZodTypeAny, {
429
+ tool: string;
430
+ sessionId: string;
431
+ input?: Record<string, unknown> | undefined;
432
+ }, {
433
+ tool: string;
434
+ sessionId: string;
435
+ input?: Record<string, unknown> | undefined;
436
+ }>;
437
+ declare const auditStartSchema: z.ZodObject<{
438
+ transport: z.ZodEnum<["stdio", "sse", "streamable-http"]>;
439
+ command: z.ZodOptional<z.ZodString>;
440
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
441
+ url: z.ZodOptional<z.ZodString>;
442
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
443
+ mode: z.ZodDefault<z.ZodEnum<["passive", "active", "aggressive"]>>;
444
+ rules: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
445
+ }, "strip", z.ZodTypeAny, {
446
+ transport: "stdio" | "sse" | "streamable-http";
447
+ mode: "passive" | "active" | "aggressive";
448
+ command?: string | undefined;
449
+ args?: string[] | undefined;
450
+ url?: string | undefined;
451
+ env?: Record<string, string> | undefined;
452
+ rules?: string[] | undefined;
453
+ }, {
454
+ transport: "stdio" | "sse" | "streamable-http";
455
+ command?: string | undefined;
456
+ args?: string[] | undefined;
457
+ url?: string | undefined;
458
+ env?: Record<string, string> | undefined;
459
+ mode?: "passive" | "active" | "aggressive" | undefined;
460
+ rules?: string[] | undefined;
461
+ }>;
462
+ declare const benchmarkStartSchema: z.ZodObject<{
463
+ transport: z.ZodEnum<["stdio", "sse", "streamable-http"]>;
464
+ command: z.ZodOptional<z.ZodString>;
465
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
466
+ url: z.ZodOptional<z.ZodString>;
467
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
468
+ tool: z.ZodString;
469
+ toolArgs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
470
+ iterations: z.ZodDefault<z.ZodNumber>;
471
+ warmup: z.ZodDefault<z.ZodNumber>;
472
+ timeout: z.ZodDefault<z.ZodNumber>;
473
+ }, "strip", z.ZodTypeAny, {
474
+ tool: string;
475
+ transport: "stdio" | "sse" | "streamable-http";
476
+ toolArgs: Record<string, unknown>;
477
+ iterations: number;
478
+ warmup: number;
479
+ timeout: number;
480
+ command?: string | undefined;
481
+ args?: string[] | undefined;
482
+ url?: string | undefined;
483
+ env?: Record<string, string> | undefined;
484
+ }, {
485
+ tool: string;
486
+ transport: "stdio" | "sse" | "streamable-http";
487
+ command?: string | undefined;
488
+ args?: string[] | undefined;
489
+ url?: string | undefined;
490
+ env?: Record<string, string> | undefined;
491
+ toolArgs?: Record<string, unknown> | undefined;
492
+ iterations?: number | undefined;
493
+ warmup?: number | undefined;
494
+ timeout?: number | undefined;
495
+ }>;
496
+ declare const docsGenerateSchema: z.ZodObject<{
497
+ transport: z.ZodEnum<["stdio", "sse", "streamable-http"]>;
498
+ command: z.ZodOptional<z.ZodString>;
499
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
500
+ url: z.ZodOptional<z.ZodString>;
501
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
502
+ format: z.ZodDefault<z.ZodEnum<["markdown", "html"]>>;
503
+ }, "strip", z.ZodTypeAny, {
504
+ transport: "stdio" | "sse" | "streamable-http";
505
+ format: "html" | "markdown";
506
+ command?: string | undefined;
507
+ args?: string[] | undefined;
508
+ url?: string | undefined;
509
+ env?: Record<string, string> | undefined;
510
+ }, {
511
+ transport: "stdio" | "sse" | "streamable-http";
512
+ command?: string | undefined;
513
+ args?: string[] | undefined;
514
+ url?: string | undefined;
515
+ env?: Record<string, string> | undefined;
516
+ format?: "html" | "markdown" | undefined;
517
+ }>;
518
+ declare const scoreCalculateSchema: z.ZodObject<{
519
+ transport: z.ZodEnum<["stdio", "sse", "streamable-http"]>;
520
+ command: z.ZodOptional<z.ZodString>;
521
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
522
+ url: z.ZodOptional<z.ZodString>;
523
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
524
+ }, "strip", z.ZodTypeAny, {
525
+ transport: "stdio" | "sse" | "streamable-http";
526
+ command?: string | undefined;
527
+ args?: string[] | undefined;
528
+ url?: string | undefined;
529
+ env?: Record<string, string> | undefined;
530
+ }, {
531
+ transport: "stdio" | "sse" | "streamable-http";
532
+ command?: string | undefined;
533
+ args?: string[] | undefined;
534
+ url?: string | undefined;
535
+ env?: Record<string, string> | undefined;
536
+ }>;
537
+
538
+ declare const serverConfigSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
539
+ name: z.ZodOptional<z.ZodString>;
540
+ transport: z.ZodDefault<z.ZodEnum<["stdio", "sse", "streamable-http"]>>;
541
+ command: z.ZodOptional<z.ZodString>;
542
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
543
+ url: z.ZodOptional<z.ZodString>;
544
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
545
+ timeouts: z.ZodOptional<z.ZodObject<{
546
+ connect: z.ZodOptional<z.ZodNumber>;
547
+ call: z.ZodOptional<z.ZodNumber>;
548
+ }, "strip", z.ZodTypeAny, {
549
+ connect?: number | undefined;
550
+ call?: number | undefined;
551
+ }, {
552
+ connect?: number | undefined;
553
+ call?: number | undefined;
554
+ }>>;
555
+ }, "strip", z.ZodTypeAny, {
556
+ transport: "stdio" | "sse" | "streamable-http";
557
+ name?: string | undefined;
558
+ command?: string | undefined;
559
+ args?: string[] | undefined;
560
+ url?: string | undefined;
561
+ env?: Record<string, string> | undefined;
562
+ timeouts?: {
563
+ connect?: number | undefined;
564
+ call?: number | undefined;
565
+ } | undefined;
566
+ }, {
567
+ name?: string | undefined;
568
+ transport?: "stdio" | "sse" | "streamable-http" | undefined;
569
+ command?: string | undefined;
570
+ args?: string[] | undefined;
571
+ url?: string | undefined;
572
+ env?: Record<string, string> | undefined;
573
+ timeouts?: {
574
+ connect?: number | undefined;
575
+ call?: number | undefined;
576
+ } | undefined;
577
+ }>]>;
578
+ declare const simpleExpectationSchema: z.ZodUnion<[z.ZodObject<{
579
+ exists: z.ZodString;
580
+ }, "strip", z.ZodTypeAny, {
581
+ exists: string;
582
+ }, {
583
+ exists: string;
584
+ }>, z.ZodObject<{
585
+ equals: z.ZodTuple<[z.ZodString, z.ZodUnknown], null>;
586
+ }, "strip", z.ZodTypeAny, {
587
+ equals: [string, unknown];
588
+ }, {
589
+ equals: [string, unknown];
590
+ }>, z.ZodObject<{
591
+ contains: z.ZodTuple<[z.ZodString, z.ZodUnknown], null>;
592
+ }, "strip", z.ZodTypeAny, {
593
+ contains: [string, unknown];
594
+ }, {
595
+ contains: [string, unknown];
596
+ }>, z.ZodObject<{
597
+ matches: z.ZodTuple<[z.ZodString, z.ZodString], null>;
598
+ }, "strip", z.ZodTypeAny, {
599
+ matches: [string, string];
600
+ }, {
601
+ matches: [string, string];
602
+ }>]>;
603
+ declare const assertionDefinitionSchema: z.ZodObject<{
604
+ type: z.ZodEnum<["schema", "equals", "contains", "exists", "matches", "type", "length", "latency", "mimeType", "expression"]>;
605
+ path: z.ZodOptional<z.ZodString>;
606
+ value: z.ZodOptional<z.ZodUnknown>;
607
+ expected: z.ZodOptional<z.ZodUnknown>;
608
+ pattern: z.ZodOptional<z.ZodString>;
609
+ maxMs: z.ZodOptional<z.ZodNumber>;
610
+ operator: z.ZodOptional<z.ZodString>;
611
+ expr: z.ZodOptional<z.ZodString>;
612
+ }, "strip", z.ZodTypeAny, {
613
+ type: "schema" | "equals" | "contains" | "exists" | "matches" | "type" | "length" | "latency" | "mimeType" | "expression";
614
+ value?: unknown;
615
+ path?: string | undefined;
616
+ expected?: unknown;
617
+ pattern?: string | undefined;
618
+ maxMs?: number | undefined;
619
+ operator?: string | undefined;
620
+ expr?: string | undefined;
621
+ }, {
622
+ type: "schema" | "equals" | "contains" | "exists" | "matches" | "type" | "length" | "latency" | "mimeType" | "expression";
623
+ value?: unknown;
624
+ path?: string | undefined;
625
+ expected?: unknown;
626
+ pattern?: string | undefined;
627
+ maxMs?: number | undefined;
628
+ operator?: string | undefined;
629
+ expr?: string | undefined;
630
+ }>;
631
+ declare const extractionSchema: z.ZodObject<{
632
+ name: z.ZodString;
633
+ path: z.ZodString;
634
+ }, "strip", z.ZodTypeAny, {
635
+ name: string;
636
+ path: string;
637
+ }, {
638
+ name: string;
639
+ path: string;
640
+ }>;
641
+ declare const testDefinitionSchema: z.ZodObject<{
642
+ id: z.ZodOptional<z.ZodString>;
643
+ name: z.ZodString;
644
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
645
+ timeout: z.ZodOptional<z.ZodNumber>;
646
+ retries: z.ZodOptional<z.ZodNumber>;
647
+ type: z.ZodOptional<z.ZodEnum<["tool", "resource"]>>;
648
+ tool: z.ZodOptional<z.ZodString>;
649
+ call: z.ZodOptional<z.ZodString>;
650
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
651
+ with: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
652
+ assertions: z.ZodOptional<z.ZodArray<z.ZodObject<{
653
+ type: z.ZodEnum<["schema", "equals", "contains", "exists", "matches", "type", "length", "latency", "mimeType", "expression"]>;
654
+ path: z.ZodOptional<z.ZodString>;
655
+ value: z.ZodOptional<z.ZodUnknown>;
656
+ expected: z.ZodOptional<z.ZodUnknown>;
657
+ pattern: z.ZodOptional<z.ZodString>;
658
+ maxMs: z.ZodOptional<z.ZodNumber>;
659
+ operator: z.ZodOptional<z.ZodString>;
660
+ expr: z.ZodOptional<z.ZodString>;
661
+ }, "strip", z.ZodTypeAny, {
662
+ type: "schema" | "equals" | "contains" | "exists" | "matches" | "type" | "length" | "latency" | "mimeType" | "expression";
663
+ value?: unknown;
664
+ path?: string | undefined;
665
+ expected?: unknown;
666
+ pattern?: string | undefined;
667
+ maxMs?: number | undefined;
668
+ operator?: string | undefined;
669
+ expr?: string | undefined;
670
+ }, {
671
+ type: "schema" | "equals" | "contains" | "exists" | "matches" | "type" | "length" | "latency" | "mimeType" | "expression";
672
+ value?: unknown;
673
+ path?: string | undefined;
674
+ expected?: unknown;
675
+ pattern?: string | undefined;
676
+ maxMs?: number | undefined;
677
+ operator?: string | undefined;
678
+ expr?: string | undefined;
679
+ }>, "many">>;
680
+ expect: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
681
+ expectError: z.ZodOptional<z.ZodBoolean>;
682
+ extract: z.ZodOptional<z.ZodArray<z.ZodObject<{
683
+ name: z.ZodString;
684
+ path: z.ZodString;
685
+ }, "strip", z.ZodTypeAny, {
686
+ name: string;
687
+ path: string;
688
+ }, {
689
+ name: string;
690
+ path: string;
691
+ }>, "many">>;
692
+ }, "strip", z.ZodTypeAny, {
693
+ name: string;
694
+ tool?: string | undefined;
695
+ type?: "tool" | "resource" | undefined;
696
+ tags?: string[] | undefined;
697
+ input?: Record<string, unknown> | undefined;
698
+ timeout?: number | undefined;
699
+ call?: string | undefined;
700
+ id?: string | undefined;
701
+ retries?: number | undefined;
702
+ with?: Record<string, unknown> | undefined;
703
+ assertions?: {
704
+ type: "schema" | "equals" | "contains" | "exists" | "matches" | "type" | "length" | "latency" | "mimeType" | "expression";
705
+ value?: unknown;
706
+ path?: string | undefined;
707
+ expected?: unknown;
708
+ pattern?: string | undefined;
709
+ maxMs?: number | undefined;
710
+ operator?: string | undefined;
711
+ expr?: string | undefined;
712
+ }[] | undefined;
713
+ expect?: Record<string, unknown>[] | undefined;
714
+ expectError?: boolean | undefined;
715
+ extract?: {
716
+ name: string;
717
+ path: string;
718
+ }[] | undefined;
719
+ }, {
720
+ name: string;
721
+ tool?: string | undefined;
722
+ type?: "tool" | "resource" | undefined;
723
+ tags?: string[] | undefined;
724
+ input?: Record<string, unknown> | undefined;
725
+ timeout?: number | undefined;
726
+ call?: string | undefined;
727
+ id?: string | undefined;
728
+ retries?: number | undefined;
729
+ with?: Record<string, unknown> | undefined;
730
+ assertions?: {
731
+ type: "schema" | "equals" | "contains" | "exists" | "matches" | "type" | "length" | "latency" | "mimeType" | "expression";
732
+ value?: unknown;
733
+ path?: string | undefined;
734
+ expected?: unknown;
735
+ pattern?: string | undefined;
736
+ maxMs?: number | undefined;
737
+ operator?: string | undefined;
738
+ expr?: string | undefined;
739
+ }[] | undefined;
740
+ expect?: Record<string, unknown>[] | undefined;
741
+ expectError?: boolean | undefined;
742
+ extract?: {
743
+ name: string;
744
+ path: string;
745
+ }[] | undefined;
746
+ }>;
747
+ declare const environmentSchema: z.ZodObject<{
748
+ variables: z.ZodRecord<z.ZodString, z.ZodString>;
749
+ }, "strip", z.ZodTypeAny, {
750
+ variables: Record<string, string>;
751
+ }, {
752
+ variables: Record<string, string>;
753
+ }>;
754
+ declare const collectionSchema: z.ZodObject<{
755
+ schemaVersion: z.ZodOptional<z.ZodString>;
756
+ name: z.ZodString;
757
+ description: z.ZodOptional<z.ZodString>;
758
+ server: z.ZodUnion<[z.ZodString, z.ZodObject<{
759
+ name: z.ZodOptional<z.ZodString>;
760
+ transport: z.ZodDefault<z.ZodEnum<["stdio", "sse", "streamable-http"]>>;
761
+ command: z.ZodOptional<z.ZodString>;
762
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
763
+ url: z.ZodOptional<z.ZodString>;
764
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
765
+ timeouts: z.ZodOptional<z.ZodObject<{
766
+ connect: z.ZodOptional<z.ZodNumber>;
767
+ call: z.ZodOptional<z.ZodNumber>;
768
+ }, "strip", z.ZodTypeAny, {
769
+ connect?: number | undefined;
770
+ call?: number | undefined;
771
+ }, {
772
+ connect?: number | undefined;
773
+ call?: number | undefined;
774
+ }>>;
775
+ }, "strip", z.ZodTypeAny, {
776
+ transport: "stdio" | "sse" | "streamable-http";
777
+ name?: string | undefined;
778
+ command?: string | undefined;
779
+ args?: string[] | undefined;
780
+ url?: string | undefined;
781
+ env?: Record<string, string> | undefined;
782
+ timeouts?: {
783
+ connect?: number | undefined;
784
+ call?: number | undefined;
785
+ } | undefined;
786
+ }, {
787
+ name?: string | undefined;
788
+ transport?: "stdio" | "sse" | "streamable-http" | undefined;
789
+ command?: string | undefined;
790
+ args?: string[] | undefined;
791
+ url?: string | undefined;
792
+ env?: Record<string, string> | undefined;
793
+ timeouts?: {
794
+ connect?: number | undefined;
795
+ call?: number | undefined;
796
+ } | undefined;
797
+ }>]>;
798
+ environments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
799
+ variables: z.ZodRecord<z.ZodString, z.ZodString>;
800
+ }, "strip", z.ZodTypeAny, {
801
+ variables: Record<string, string>;
802
+ }, {
803
+ variables: Record<string, string>;
804
+ }>>>;
805
+ defaultEnvironment: z.ZodOptional<z.ZodString>;
806
+ tests: z.ZodArray<z.ZodObject<{
807
+ id: z.ZodOptional<z.ZodString>;
808
+ name: z.ZodString;
809
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
810
+ timeout: z.ZodOptional<z.ZodNumber>;
811
+ retries: z.ZodOptional<z.ZodNumber>;
812
+ type: z.ZodOptional<z.ZodEnum<["tool", "resource"]>>;
813
+ tool: z.ZodOptional<z.ZodString>;
814
+ call: z.ZodOptional<z.ZodString>;
815
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
816
+ with: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
817
+ assertions: z.ZodOptional<z.ZodArray<z.ZodObject<{
818
+ type: z.ZodEnum<["schema", "equals", "contains", "exists", "matches", "type", "length", "latency", "mimeType", "expression"]>;
819
+ path: z.ZodOptional<z.ZodString>;
820
+ value: z.ZodOptional<z.ZodUnknown>;
821
+ expected: z.ZodOptional<z.ZodUnknown>;
822
+ pattern: z.ZodOptional<z.ZodString>;
823
+ maxMs: z.ZodOptional<z.ZodNumber>;
824
+ operator: z.ZodOptional<z.ZodString>;
825
+ expr: z.ZodOptional<z.ZodString>;
826
+ }, "strip", z.ZodTypeAny, {
827
+ type: "schema" | "equals" | "contains" | "exists" | "matches" | "type" | "length" | "latency" | "mimeType" | "expression";
828
+ value?: unknown;
829
+ path?: string | undefined;
830
+ expected?: unknown;
831
+ pattern?: string | undefined;
832
+ maxMs?: number | undefined;
833
+ operator?: string | undefined;
834
+ expr?: string | undefined;
835
+ }, {
836
+ type: "schema" | "equals" | "contains" | "exists" | "matches" | "type" | "length" | "latency" | "mimeType" | "expression";
837
+ value?: unknown;
838
+ path?: string | undefined;
839
+ expected?: unknown;
840
+ pattern?: string | undefined;
841
+ maxMs?: number | undefined;
842
+ operator?: string | undefined;
843
+ expr?: string | undefined;
844
+ }>, "many">>;
845
+ expect: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
846
+ expectError: z.ZodOptional<z.ZodBoolean>;
847
+ extract: z.ZodOptional<z.ZodArray<z.ZodObject<{
848
+ name: z.ZodString;
849
+ path: z.ZodString;
850
+ }, "strip", z.ZodTypeAny, {
851
+ name: string;
852
+ path: string;
853
+ }, {
854
+ name: string;
855
+ path: string;
856
+ }>, "many">>;
857
+ }, "strip", z.ZodTypeAny, {
858
+ name: string;
859
+ tool?: string | undefined;
860
+ type?: "tool" | "resource" | undefined;
861
+ tags?: string[] | undefined;
862
+ input?: Record<string, unknown> | undefined;
863
+ timeout?: number | undefined;
864
+ call?: string | undefined;
865
+ id?: string | undefined;
866
+ retries?: number | undefined;
867
+ with?: Record<string, unknown> | undefined;
868
+ assertions?: {
869
+ type: "schema" | "equals" | "contains" | "exists" | "matches" | "type" | "length" | "latency" | "mimeType" | "expression";
870
+ value?: unknown;
871
+ path?: string | undefined;
872
+ expected?: unknown;
873
+ pattern?: string | undefined;
874
+ maxMs?: number | undefined;
875
+ operator?: string | undefined;
876
+ expr?: string | undefined;
877
+ }[] | undefined;
878
+ expect?: Record<string, unknown>[] | undefined;
879
+ expectError?: boolean | undefined;
880
+ extract?: {
881
+ name: string;
882
+ path: string;
883
+ }[] | undefined;
884
+ }, {
885
+ name: string;
886
+ tool?: string | undefined;
887
+ type?: "tool" | "resource" | undefined;
888
+ tags?: string[] | undefined;
889
+ input?: Record<string, unknown> | undefined;
890
+ timeout?: number | undefined;
891
+ call?: string | undefined;
892
+ id?: string | undefined;
893
+ retries?: number | undefined;
894
+ with?: Record<string, unknown> | undefined;
895
+ assertions?: {
896
+ type: "schema" | "equals" | "contains" | "exists" | "matches" | "type" | "length" | "latency" | "mimeType" | "expression";
897
+ value?: unknown;
898
+ path?: string | undefined;
899
+ expected?: unknown;
900
+ pattern?: string | undefined;
901
+ maxMs?: number | undefined;
902
+ operator?: string | undefined;
903
+ expr?: string | undefined;
904
+ }[] | undefined;
905
+ expect?: Record<string, unknown>[] | undefined;
906
+ expectError?: boolean | undefined;
907
+ extract?: {
908
+ name: string;
909
+ path: string;
910
+ }[] | undefined;
911
+ }>, "many">;
912
+ }, "strip", z.ZodTypeAny, {
913
+ name: string;
914
+ server: string | {
915
+ transport: "stdio" | "sse" | "streamable-http";
916
+ name?: string | undefined;
917
+ command?: string | undefined;
918
+ args?: string[] | undefined;
919
+ url?: string | undefined;
920
+ env?: Record<string, string> | undefined;
921
+ timeouts?: {
922
+ connect?: number | undefined;
923
+ call?: number | undefined;
924
+ } | undefined;
925
+ };
926
+ tests: {
927
+ name: string;
928
+ tool?: string | undefined;
929
+ type?: "tool" | "resource" | undefined;
930
+ tags?: string[] | undefined;
931
+ input?: Record<string, unknown> | undefined;
932
+ timeout?: number | undefined;
933
+ call?: string | undefined;
934
+ id?: string | undefined;
935
+ retries?: number | undefined;
936
+ with?: Record<string, unknown> | undefined;
937
+ assertions?: {
938
+ type: "schema" | "equals" | "contains" | "exists" | "matches" | "type" | "length" | "latency" | "mimeType" | "expression";
939
+ value?: unknown;
940
+ path?: string | undefined;
941
+ expected?: unknown;
942
+ pattern?: string | undefined;
943
+ maxMs?: number | undefined;
944
+ operator?: string | undefined;
945
+ expr?: string | undefined;
946
+ }[] | undefined;
947
+ expect?: Record<string, unknown>[] | undefined;
948
+ expectError?: boolean | undefined;
949
+ extract?: {
950
+ name: string;
951
+ path: string;
952
+ }[] | undefined;
953
+ }[];
954
+ description?: string | undefined;
955
+ schemaVersion?: string | undefined;
956
+ environments?: Record<string, {
957
+ variables: Record<string, string>;
958
+ }> | undefined;
959
+ defaultEnvironment?: string | undefined;
960
+ }, {
961
+ name: string;
962
+ server: string | {
963
+ name?: string | undefined;
964
+ transport?: "stdio" | "sse" | "streamable-http" | undefined;
965
+ command?: string | undefined;
966
+ args?: string[] | undefined;
967
+ url?: string | undefined;
968
+ env?: Record<string, string> | undefined;
969
+ timeouts?: {
970
+ connect?: number | undefined;
971
+ call?: number | undefined;
972
+ } | undefined;
973
+ };
974
+ tests: {
975
+ name: string;
976
+ tool?: string | undefined;
977
+ type?: "tool" | "resource" | undefined;
978
+ tags?: string[] | undefined;
979
+ input?: Record<string, unknown> | undefined;
980
+ timeout?: number | undefined;
981
+ call?: string | undefined;
982
+ id?: string | undefined;
983
+ retries?: number | undefined;
984
+ with?: Record<string, unknown> | undefined;
985
+ assertions?: {
986
+ type: "schema" | "equals" | "contains" | "exists" | "matches" | "type" | "length" | "latency" | "mimeType" | "expression";
987
+ value?: unknown;
988
+ path?: string | undefined;
989
+ expected?: unknown;
990
+ pattern?: string | undefined;
991
+ maxMs?: number | undefined;
992
+ operator?: string | undefined;
993
+ expr?: string | undefined;
994
+ }[] | undefined;
995
+ expect?: Record<string, unknown>[] | undefined;
996
+ expectError?: boolean | undefined;
997
+ extract?: {
998
+ name: string;
999
+ path: string;
1000
+ }[] | undefined;
1001
+ }[];
1002
+ description?: string | undefined;
1003
+ schemaVersion?: string | undefined;
1004
+ environments?: Record<string, {
1005
+ variables: Record<string, string>;
1006
+ }> | undefined;
1007
+ defaultEnvironment?: string | undefined;
1008
+ }>;
1009
+ declare const timeoutConfigSchema: z.ZodObject<{
1010
+ test: z.ZodDefault<z.ZodNumber>;
1011
+ mcpCall: z.ZodDefault<z.ZodNumber>;
1012
+ transport: z.ZodDefault<z.ZodNumber>;
1013
+ assertion: z.ZodDefault<z.ZodNumber>;
1014
+ cleanup: z.ZodDefault<z.ZodNumber>;
1015
+ }, "strip", z.ZodTypeAny, {
1016
+ transport: number;
1017
+ test: number;
1018
+ mcpCall: number;
1019
+ assertion: number;
1020
+ cleanup: number;
1021
+ }, {
1022
+ transport?: number | undefined;
1023
+ test?: number | undefined;
1024
+ mcpCall?: number | undefined;
1025
+ assertion?: number | undefined;
1026
+ cleanup?: number | undefined;
1027
+ }>;
1028
+ declare const rateLimitConfigSchema: z.ZodObject<{
1029
+ maxCallsPerSecond: z.ZodDefault<z.ZodNumber>;
1030
+ maxConcurrent: z.ZodDefault<z.ZodNumber>;
1031
+ backoff: z.ZodObject<{
1032
+ initial: z.ZodDefault<z.ZodNumber>;
1033
+ multiplier: z.ZodDefault<z.ZodNumber>;
1034
+ max: z.ZodDefault<z.ZodNumber>;
1035
+ }, "strip", z.ZodTypeAny, {
1036
+ initial: number;
1037
+ multiplier: number;
1038
+ max: number;
1039
+ }, {
1040
+ initial?: number | undefined;
1041
+ multiplier?: number | undefined;
1042
+ max?: number | undefined;
1043
+ }>;
1044
+ }, "strip", z.ZodTypeAny, {
1045
+ maxCallsPerSecond: number;
1046
+ maxConcurrent: number;
1047
+ backoff: {
1048
+ initial: number;
1049
+ multiplier: number;
1050
+ max: number;
1051
+ };
1052
+ }, {
1053
+ backoff: {
1054
+ initial?: number | undefined;
1055
+ multiplier?: number | undefined;
1056
+ max?: number | undefined;
1057
+ };
1058
+ maxCallsPerSecond?: number | undefined;
1059
+ maxConcurrent?: number | undefined;
1060
+ }>;
1061
+
1062
+ export { type ApiError, type ApiListResponse, type ApiResponse, type AssertionDefinition, type AssertionResult, type AssertionType, type BenchmarkConfig, type BenchmarkResult, type BenchmarkStats, type CollectionDefinition, type ConnectionConfig, type ConnectionState, DEFAULT_RATE_LIMIT, DEFAULT_TIMEOUTS, EXIT_CODES, type EnvironmentDefinition, type ErrorTemplate, type ExitCode, type ExtractionDefinition, type MCPScore, type ManagedProcess, type MessageDirection, type ProcessConfig, type ProfileEntry, type ProtocolLogEntry, type RateLimitConfig, type ReporterType, type SavedCollection, type SavedServerConnection, type SecurityFinding, type SecurityScanConfig, type SecurityScanMode, type SecurityScanResult, type SecurityScanSummary, type ServerConfig, type SeverityLevel, type SimpleExpectation, type TestDefinition, type TestResult, type TestRunRecord, type TestRunResult, type TestSummary, type TimeoutConfig, type TransportType, type WSClientMessage, type WSServerMessage, type WaterfallEntry, assertionDefinitionSchema, auditStartSchema, benchmarkStartSchema, collectionSchema, createCollectionSchema, createServerSchema, docsGenerateSchema, environmentSchema, extractionSchema, inspectCallSchema, inspectConnectSchema, rateLimitConfigSchema, scoreCalculateSchema, serverConfigSchema, simpleExpectationSchema, testDefinitionSchema, timeoutConfigSchema, triggerRunSchema, updateCollectionSchema, updateServerSchema };
package/dist/index.js ADDED
@@ -0,0 +1,223 @@
1
+ // src/constants/exit-codes.ts
2
+ var EXIT_CODES = {
3
+ SUCCESS: 0,
4
+ TEST_FAILURE: 1,
5
+ ERROR: 2,
6
+ CONFIG_ERROR: 3,
7
+ CONNECTION_ERROR: 4,
8
+ TIMEOUT: 5,
9
+ SECURITY_FINDINGS: 6,
10
+ VALIDATION_ERROR: 7,
11
+ INTERRUPTED: 130
12
+ };
13
+
14
+ // src/types/index.ts
15
+ var DEFAULT_TIMEOUTS = {
16
+ test: 3e4,
17
+ mcpCall: 25e3,
18
+ transport: 2e4,
19
+ assertion: 5e3,
20
+ cleanup: 5e3
21
+ };
22
+ var DEFAULT_RATE_LIMIT = {
23
+ maxCallsPerSecond: 10,
24
+ maxConcurrent: 5,
25
+ backoff: {
26
+ initial: 1e3,
27
+ multiplier: 2,
28
+ max: 3e4
29
+ }
30
+ };
31
+
32
+ // src/schemas/index.ts
33
+ import { z as z2 } from "zod";
34
+
35
+ // src/schemas/api.ts
36
+ import { z } from "zod";
37
+ var createServerSchema = z.object({
38
+ name: z.string().min(1),
39
+ transport: z.enum(["stdio", "sse", "streamable-http"]),
40
+ command: z.string().optional(),
41
+ args: z.array(z.string()).optional(),
42
+ url: z.string().optional(),
43
+ env: z.record(z.string()).optional()
44
+ });
45
+ var updateServerSchema = createServerSchema.partial();
46
+ var createCollectionSchema = z.object({
47
+ name: z.string().min(1),
48
+ description: z.string().optional(),
49
+ yaml: z.string().min(1)
50
+ });
51
+ var updateCollectionSchema = createCollectionSchema.partial();
52
+ var triggerRunSchema = z.object({
53
+ collectionId: z.string().min(1),
54
+ serverId: z.string().optional(),
55
+ environment: z.string().optional(),
56
+ tags: z.array(z.string()).optional(),
57
+ parallelism: z.number().int().min(1).optional()
58
+ });
59
+ var inspectConnectSchema = z.object({
60
+ transport: z.enum(["stdio", "sse", "streamable-http"]),
61
+ command: z.string().optional(),
62
+ args: z.array(z.string()).optional(),
63
+ url: z.string().optional(),
64
+ env: z.record(z.string()).optional()
65
+ });
66
+ var inspectCallSchema = z.object({
67
+ sessionId: z.string().min(1),
68
+ tool: z.string().min(1),
69
+ input: z.record(z.unknown()).optional()
70
+ });
71
+ var auditStartSchema = z.object({
72
+ transport: z.enum(["stdio", "sse", "streamable-http"]),
73
+ command: z.string().optional(),
74
+ args: z.array(z.string()).optional(),
75
+ url: z.string().optional(),
76
+ env: z.record(z.string()).optional(),
77
+ mode: z.enum(["passive", "active", "aggressive"]).default("passive"),
78
+ rules: z.array(z.string()).optional()
79
+ });
80
+ var benchmarkStartSchema = z.object({
81
+ transport: z.enum(["stdio", "sse", "streamable-http"]),
82
+ command: z.string().optional(),
83
+ args: z.array(z.string()).optional(),
84
+ url: z.string().optional(),
85
+ env: z.record(z.string()).optional(),
86
+ tool: z.string().min(1),
87
+ toolArgs: z.record(z.unknown()).default({}),
88
+ iterations: z.number().int().min(1).default(100),
89
+ warmup: z.number().int().min(0).default(5),
90
+ timeout: z.number().int().min(1e3).default(3e4)
91
+ });
92
+ var docsGenerateSchema = z.object({
93
+ transport: z.enum(["stdio", "sse", "streamable-http"]),
94
+ command: z.string().optional(),
95
+ args: z.array(z.string()).optional(),
96
+ url: z.string().optional(),
97
+ env: z.record(z.string()).optional(),
98
+ format: z.enum(["markdown", "html"]).default("markdown")
99
+ });
100
+ var scoreCalculateSchema = z.object({
101
+ transport: z.enum(["stdio", "sse", "streamable-http"]),
102
+ command: z.string().optional(),
103
+ args: z.array(z.string()).optional(),
104
+ url: z.string().optional(),
105
+ env: z.record(z.string()).optional()
106
+ });
107
+
108
+ // src/schemas/index.ts
109
+ var serverConfigSchema = z2.union([
110
+ z2.string(),
111
+ z2.object({
112
+ name: z2.string().optional(),
113
+ transport: z2.enum(["stdio", "sse", "streamable-http"]).default("stdio"),
114
+ command: z2.string().optional(),
115
+ args: z2.array(z2.string()).optional(),
116
+ url: z2.string().optional(),
117
+ env: z2.record(z2.string()).optional(),
118
+ timeouts: z2.object({
119
+ connect: z2.number().optional(),
120
+ call: z2.number().optional()
121
+ }).optional()
122
+ })
123
+ ]);
124
+ var simpleExpectationSchema = z2.union([
125
+ z2.object({ exists: z2.string() }),
126
+ z2.object({ equals: z2.tuple([z2.string(), z2.unknown()]) }),
127
+ z2.object({ contains: z2.tuple([z2.string(), z2.unknown()]) }),
128
+ z2.object({ matches: z2.tuple([z2.string(), z2.string()]) })
129
+ ]);
130
+ var assertionDefinitionSchema = z2.object({
131
+ type: z2.enum([
132
+ "schema",
133
+ "equals",
134
+ "contains",
135
+ "exists",
136
+ "matches",
137
+ "type",
138
+ "length",
139
+ "latency",
140
+ "mimeType",
141
+ "expression"
142
+ ]),
143
+ path: z2.string().optional(),
144
+ value: z2.unknown().optional(),
145
+ expected: z2.unknown().optional(),
146
+ pattern: z2.string().optional(),
147
+ maxMs: z2.number().optional(),
148
+ operator: z2.string().optional(),
149
+ expr: z2.string().optional()
150
+ });
151
+ var extractionSchema = z2.object({
152
+ name: z2.string(),
153
+ path: z2.string()
154
+ });
155
+ var testDefinitionSchema = z2.object({
156
+ id: z2.string().optional(),
157
+ name: z2.string(),
158
+ tags: z2.array(z2.string()).optional(),
159
+ timeout: z2.number().optional(),
160
+ retries: z2.number().optional(),
161
+ type: z2.enum(["tool", "resource"]).optional(),
162
+ tool: z2.string().optional(),
163
+ call: z2.string().optional(),
164
+ input: z2.record(z2.unknown()).optional(),
165
+ with: z2.record(z2.unknown()).optional(),
166
+ assertions: z2.array(assertionDefinitionSchema).optional(),
167
+ expect: z2.array(z2.record(z2.unknown())).optional(),
168
+ expectError: z2.boolean().optional(),
169
+ extract: z2.array(extractionSchema).optional()
170
+ });
171
+ var environmentSchema = z2.object({
172
+ variables: z2.record(z2.string())
173
+ });
174
+ var collectionSchema = z2.object({
175
+ schemaVersion: z2.string().optional(),
176
+ name: z2.string(),
177
+ description: z2.string().optional(),
178
+ server: serverConfigSchema,
179
+ environments: z2.record(environmentSchema).optional(),
180
+ defaultEnvironment: z2.string().optional(),
181
+ tests: z2.array(testDefinitionSchema).min(1)
182
+ });
183
+ var timeoutConfigSchema = z2.object({
184
+ test: z2.number().default(3e4),
185
+ mcpCall: z2.number().default(25e3),
186
+ transport: z2.number().default(2e4),
187
+ assertion: z2.number().default(5e3),
188
+ cleanup: z2.number().default(5e3)
189
+ });
190
+ var rateLimitConfigSchema = z2.object({
191
+ maxCallsPerSecond: z2.number().default(10),
192
+ maxConcurrent: z2.number().default(5),
193
+ backoff: z2.object({
194
+ initial: z2.number().default(1e3),
195
+ multiplier: z2.number().default(2),
196
+ max: z2.number().default(3e4)
197
+ })
198
+ });
199
+ export {
200
+ DEFAULT_RATE_LIMIT,
201
+ DEFAULT_TIMEOUTS,
202
+ EXIT_CODES,
203
+ assertionDefinitionSchema,
204
+ auditStartSchema,
205
+ benchmarkStartSchema,
206
+ collectionSchema,
207
+ createCollectionSchema,
208
+ createServerSchema,
209
+ docsGenerateSchema,
210
+ environmentSchema,
211
+ extractionSchema,
212
+ inspectCallSchema,
213
+ inspectConnectSchema,
214
+ rateLimitConfigSchema,
215
+ scoreCalculateSchema,
216
+ serverConfigSchema,
217
+ simpleExpectationSchema,
218
+ testDefinitionSchema,
219
+ timeoutConfigSchema,
220
+ triggerRunSchema,
221
+ updateCollectionSchema,
222
+ updateServerSchema
223
+ };
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@mcpspec/shared",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "types": "./dist/index.d.ts"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "license": "MIT",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/anthropics/mcpspec.git",
20
+ "directory": "packages/shared"
21
+ },
22
+ "engines": {
23
+ "node": ">=22.0.0"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^22.0.0",
27
+ "tsup": "^8.0.0",
28
+ "typescript": "^5.4.0",
29
+ "vitest": "^2.1.0"
30
+ },
31
+ "dependencies": {
32
+ "zod": "^3.22.0"
33
+ },
34
+ "scripts": {
35
+ "build": "tsup src/index.ts --format esm --dts",
36
+ "test": "vitest run --passWithNoTests",
37
+ "clean": "rm -rf dist .turbo"
38
+ }
39
+ }