mock-mcp 0.3.1 → 0.5.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 (40) hide show
  1. package/README.md +212 -124
  2. package/dist/adapter/index.cjs +875 -0
  3. package/dist/adapter/index.d.cts +142 -0
  4. package/dist/adapter/index.d.ts +142 -0
  5. package/dist/adapter/index.js +835 -0
  6. package/dist/client/connect.cjs +991 -0
  7. package/dist/client/connect.d.cts +218 -0
  8. package/dist/client/connect.d.ts +211 -7
  9. package/dist/client/connect.js +941 -20
  10. package/dist/client/index.cjs +992 -0
  11. package/dist/client/index.d.cts +3 -0
  12. package/dist/client/index.d.ts +3 -2
  13. package/dist/client/index.js +951 -2
  14. package/dist/daemon/index.cjs +717 -0
  15. package/dist/daemon/index.d.cts +62 -0
  16. package/dist/daemon/index.d.ts +62 -0
  17. package/dist/daemon/index.js +678 -0
  18. package/dist/index.cjs +2708 -0
  19. package/dist/index.d.cts +602 -0
  20. package/dist/index.d.ts +602 -11
  21. package/dist/index.js +2651 -53
  22. package/dist/shared/index.cjs +506 -0
  23. package/dist/shared/index.d.cts +241 -0
  24. package/dist/shared/index.d.ts +241 -0
  25. package/dist/shared/index.js +423 -0
  26. package/dist/types-bEGXLBF0.d.cts +190 -0
  27. package/dist/types-bEGXLBF0.d.ts +190 -0
  28. package/package.json +45 -4
  29. package/dist/client/batch-mock-collector.d.ts +0 -111
  30. package/dist/client/batch-mock-collector.js +0 -308
  31. package/dist/client/util.d.ts +0 -1
  32. package/dist/client/util.js +0 -3
  33. package/dist/connect.cjs +0 -400
  34. package/dist/connect.d.cts +0 -82
  35. package/dist/server/index.d.ts +0 -1
  36. package/dist/server/index.js +0 -1
  37. package/dist/server/test-mock-mcp-server.d.ts +0 -73
  38. package/dist/server/test-mock-mcp-server.js +0 -419
  39. package/dist/types.d.ts +0 -45
  40. package/dist/types.js +0 -2
@@ -0,0 +1,142 @@
1
+ import { GetStatusResult, ListRunsResult, ClaimNextBatchResult, ProvideBatchResult, GetBatchResult, RunInfo } from '../shared/index.cjs';
2
+ import { M as MockResponseDescriptor, D as DaemonRegistry } from '../types-bEGXLBF0.cjs';
3
+ import 'node:fs';
4
+
5
+ /**
6
+ * MCP Adapter - The MCP stdio server that bridges AI clients to the Daemon.
7
+ *
8
+ * Each MCP client (Cursor, Claude Desktop, etc.) spawns one Adapter process.
9
+ * The Adapter:
10
+ * - Exposes MCP tools (claim_next_batch, provide_batch_mock_data, get_status)
11
+ * - Discovers and connects to ALL active Daemons via IPC
12
+ * - Does NOT bind any ports (avoids conflicts)
13
+ * - Works across projects without requiring --project-root
14
+ */
15
+ type Logger$1 = Pick<Console, "log" | "warn" | "error"> & {
16
+ debug?: (...args: unknown[]) => void;
17
+ };
18
+ interface AdapterOptions {
19
+ logger?: Logger$1;
20
+ version?: string;
21
+ }
22
+ declare function runAdapter(opts?: AdapterOptions): Promise<void>;
23
+
24
+ /**
25
+ * Daemon Client - HTTP/JSON-RPC client for communicating with the Daemon.
26
+ *
27
+ * Used by the MCP Adapter to call daemon RPC methods.
28
+ */
29
+
30
+ declare class DaemonClient {
31
+ private readonly ipcPath;
32
+ private readonly token;
33
+ private readonly adapterId;
34
+ constructor(ipcPath: string, token: string, adapterId: string);
35
+ getStatus(): Promise<GetStatusResult>;
36
+ listRuns(): Promise<ListRunsResult>;
37
+ claimNextBatch(args: {
38
+ runId?: string;
39
+ leaseMs?: number;
40
+ }): Promise<ClaimNextBatchResult | null>;
41
+ provideBatch(args: {
42
+ batchId: string;
43
+ claimToken: string;
44
+ mocks: MockResponseDescriptor[];
45
+ }): Promise<ProvideBatchResult>;
46
+ releaseBatch(args: {
47
+ batchId: string;
48
+ claimToken: string;
49
+ reason?: string;
50
+ }): Promise<{
51
+ ok: boolean;
52
+ }>;
53
+ getBatch(batchId: string): Promise<GetBatchResult>;
54
+ private rpc;
55
+ }
56
+
57
+ /**
58
+ * MultiDaemonClient - Aggregates multiple daemon connections for cross-project operation.
59
+ *
60
+ * This client discovers all active daemons and can perform operations across them.
61
+ * It's designed for MCP adapters that need to work without knowing the specific project root.
62
+ */
63
+
64
+ type Logger = Pick<Console, "log" | "warn" | "error"> & {
65
+ debug?: (...args: unknown[]) => void;
66
+ };
67
+ interface MultiDaemonClientOptions {
68
+ logger?: Logger;
69
+ cacheDir?: string;
70
+ }
71
+ interface DaemonConnection {
72
+ registry: DaemonRegistry;
73
+ healthy: boolean;
74
+ }
75
+ interface ExtendedRunInfo extends RunInfo {
76
+ projectId: string;
77
+ projectRoot: string;
78
+ }
79
+ interface AggregatedStatusResult {
80
+ daemons: (GetStatusResult & {
81
+ healthy: boolean;
82
+ })[];
83
+ totalRuns: number;
84
+ totalPending: number;
85
+ totalClaimed: number;
86
+ }
87
+ declare class MultiDaemonClient {
88
+ private readonly logger;
89
+ private readonly cacheDir?;
90
+ private readonly adapterId;
91
+ constructor(opts?: MultiDaemonClientOptions);
92
+ /**
93
+ * Discover all active and healthy daemons.
94
+ */
95
+ discoverDaemons(): Promise<DaemonConnection[]>;
96
+ /**
97
+ * Get aggregated status from all daemons.
98
+ */
99
+ getAggregatedStatus(): Promise<AggregatedStatusResult>;
100
+ /**
101
+ * List all runs across all daemons.
102
+ */
103
+ listAllRuns(): Promise<ExtendedRunInfo[]>;
104
+ /**
105
+ * Claim the next available batch from any daemon.
106
+ * Searches through all daemons in order until finding one with a pending batch.
107
+ */
108
+ claimNextBatch(args: {
109
+ runId?: string;
110
+ leaseMs?: number;
111
+ }): Promise<(ClaimNextBatchResult & {
112
+ projectId: string;
113
+ projectRoot: string;
114
+ }) | null>;
115
+ /**
116
+ * Provide mock data for a batch.
117
+ * Automatically routes to the correct daemon based on batchId.
118
+ */
119
+ provideBatch(args: {
120
+ batchId: string;
121
+ claimToken: string;
122
+ mocks: MockResponseDescriptor[];
123
+ }): Promise<ProvideBatchResult>;
124
+ /**
125
+ * Release a batch.
126
+ */
127
+ releaseBatch(args: {
128
+ batchId: string;
129
+ claimToken: string;
130
+ reason?: string;
131
+ }): Promise<{
132
+ ok: boolean;
133
+ message?: string;
134
+ }>;
135
+ /**
136
+ * Get a specific batch by ID.
137
+ */
138
+ getBatch(batchId: string): Promise<GetBatchResult | null>;
139
+ private rpc;
140
+ }
141
+
142
+ export { type AdapterOptions, type AggregatedStatusResult, DaemonClient, type ExtendedRunInfo, MultiDaemonClient, type MultiDaemonClientOptions, runAdapter };
@@ -0,0 +1,142 @@
1
+ import { GetStatusResult, ListRunsResult, ClaimNextBatchResult, ProvideBatchResult, GetBatchResult, RunInfo } from '../shared/index.js';
2
+ import { M as MockResponseDescriptor, D as DaemonRegistry } from '../types-bEGXLBF0.js';
3
+ import 'node:fs';
4
+
5
+ /**
6
+ * MCP Adapter - The MCP stdio server that bridges AI clients to the Daemon.
7
+ *
8
+ * Each MCP client (Cursor, Claude Desktop, etc.) spawns one Adapter process.
9
+ * The Adapter:
10
+ * - Exposes MCP tools (claim_next_batch, provide_batch_mock_data, get_status)
11
+ * - Discovers and connects to ALL active Daemons via IPC
12
+ * - Does NOT bind any ports (avoids conflicts)
13
+ * - Works across projects without requiring --project-root
14
+ */
15
+ type Logger$1 = Pick<Console, "log" | "warn" | "error"> & {
16
+ debug?: (...args: unknown[]) => void;
17
+ };
18
+ interface AdapterOptions {
19
+ logger?: Logger$1;
20
+ version?: string;
21
+ }
22
+ declare function runAdapter(opts?: AdapterOptions): Promise<void>;
23
+
24
+ /**
25
+ * Daemon Client - HTTP/JSON-RPC client for communicating with the Daemon.
26
+ *
27
+ * Used by the MCP Adapter to call daemon RPC methods.
28
+ */
29
+
30
+ declare class DaemonClient {
31
+ private readonly ipcPath;
32
+ private readonly token;
33
+ private readonly adapterId;
34
+ constructor(ipcPath: string, token: string, adapterId: string);
35
+ getStatus(): Promise<GetStatusResult>;
36
+ listRuns(): Promise<ListRunsResult>;
37
+ claimNextBatch(args: {
38
+ runId?: string;
39
+ leaseMs?: number;
40
+ }): Promise<ClaimNextBatchResult | null>;
41
+ provideBatch(args: {
42
+ batchId: string;
43
+ claimToken: string;
44
+ mocks: MockResponseDescriptor[];
45
+ }): Promise<ProvideBatchResult>;
46
+ releaseBatch(args: {
47
+ batchId: string;
48
+ claimToken: string;
49
+ reason?: string;
50
+ }): Promise<{
51
+ ok: boolean;
52
+ }>;
53
+ getBatch(batchId: string): Promise<GetBatchResult>;
54
+ private rpc;
55
+ }
56
+
57
+ /**
58
+ * MultiDaemonClient - Aggregates multiple daemon connections for cross-project operation.
59
+ *
60
+ * This client discovers all active daemons and can perform operations across them.
61
+ * It's designed for MCP adapters that need to work without knowing the specific project root.
62
+ */
63
+
64
+ type Logger = Pick<Console, "log" | "warn" | "error"> & {
65
+ debug?: (...args: unknown[]) => void;
66
+ };
67
+ interface MultiDaemonClientOptions {
68
+ logger?: Logger;
69
+ cacheDir?: string;
70
+ }
71
+ interface DaemonConnection {
72
+ registry: DaemonRegistry;
73
+ healthy: boolean;
74
+ }
75
+ interface ExtendedRunInfo extends RunInfo {
76
+ projectId: string;
77
+ projectRoot: string;
78
+ }
79
+ interface AggregatedStatusResult {
80
+ daemons: (GetStatusResult & {
81
+ healthy: boolean;
82
+ })[];
83
+ totalRuns: number;
84
+ totalPending: number;
85
+ totalClaimed: number;
86
+ }
87
+ declare class MultiDaemonClient {
88
+ private readonly logger;
89
+ private readonly cacheDir?;
90
+ private readonly adapterId;
91
+ constructor(opts?: MultiDaemonClientOptions);
92
+ /**
93
+ * Discover all active and healthy daemons.
94
+ */
95
+ discoverDaemons(): Promise<DaemonConnection[]>;
96
+ /**
97
+ * Get aggregated status from all daemons.
98
+ */
99
+ getAggregatedStatus(): Promise<AggregatedStatusResult>;
100
+ /**
101
+ * List all runs across all daemons.
102
+ */
103
+ listAllRuns(): Promise<ExtendedRunInfo[]>;
104
+ /**
105
+ * Claim the next available batch from any daemon.
106
+ * Searches through all daemons in order until finding one with a pending batch.
107
+ */
108
+ claimNextBatch(args: {
109
+ runId?: string;
110
+ leaseMs?: number;
111
+ }): Promise<(ClaimNextBatchResult & {
112
+ projectId: string;
113
+ projectRoot: string;
114
+ }) | null>;
115
+ /**
116
+ * Provide mock data for a batch.
117
+ * Automatically routes to the correct daemon based on batchId.
118
+ */
119
+ provideBatch(args: {
120
+ batchId: string;
121
+ claimToken: string;
122
+ mocks: MockResponseDescriptor[];
123
+ }): Promise<ProvideBatchResult>;
124
+ /**
125
+ * Release a batch.
126
+ */
127
+ releaseBatch(args: {
128
+ batchId: string;
129
+ claimToken: string;
130
+ reason?: string;
131
+ }): Promise<{
132
+ ok: boolean;
133
+ message?: string;
134
+ }>;
135
+ /**
136
+ * Get a specific batch by ID.
137
+ */
138
+ getBatch(batchId: string): Promise<GetBatchResult | null>;
139
+ private rpc;
140
+ }
141
+
142
+ export { type AdapterOptions, type AggregatedStatusResult, DaemonClient, type ExtendedRunInfo, MultiDaemonClient, type MultiDaemonClientOptions, runAdapter };