mock-mcp 0.2.0 → 0.2.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.
package/dist/index.js
CHANGED
|
@@ -27,9 +27,9 @@ async function runCli() {
|
|
|
27
27
|
enableMcpTransport,
|
|
28
28
|
});
|
|
29
29
|
await server.start();
|
|
30
|
-
console.
|
|
30
|
+
console.error(`🎯 Test Mock MCP server ready on ws://localhost:${server.port ?? port}`);
|
|
31
31
|
const shutdown = async () => {
|
|
32
|
-
console.
|
|
32
|
+
console.error("👋 Shutting down Test Mock MCP server...");
|
|
33
33
|
await server.stop();
|
|
34
34
|
process.exit(0);
|
|
35
35
|
};
|
|
@@ -130,7 +130,7 @@ export class TestMockMCPServer {
|
|
|
130
130
|
};
|
|
131
131
|
batch.ws.send(JSON.stringify(payload));
|
|
132
132
|
this.pendingBatches.delete(batchId);
|
|
133
|
-
this.logger.
|
|
133
|
+
this.logger.error(`✅ Delivered ${mocks.length} mock(s) to test process for ${batchId}`);
|
|
134
134
|
return this.buildToolResponse(JSON.stringify({
|
|
135
135
|
success: true,
|
|
136
136
|
message: `Provided mock data for ${batchId}`,
|
|
@@ -147,7 +147,7 @@ export class TestMockMCPServer {
|
|
|
147
147
|
wss.once("listening", () => {
|
|
148
148
|
const address = wss.address();
|
|
149
149
|
this.actualPort = address?.port ?? desiredPort;
|
|
150
|
-
this.logger.
|
|
150
|
+
this.logger.error(`🚀 WebSocket server listening on ws://localhost:${this.actualPort}`);
|
|
151
151
|
resolve();
|
|
152
152
|
});
|
|
153
153
|
wss.once("error", (error) => {
|
|
@@ -228,7 +228,7 @@ export class TestMockMCPServer {
|
|
|
228
228
|
this.mcpServer.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
229
229
|
const toolName = request.params.name;
|
|
230
230
|
if (toolName === "get_pending_batches") {
|
|
231
|
-
this.logger.
|
|
231
|
+
this.logger.error("📋 MCP client inspected pending batches");
|
|
232
232
|
return this.buildToolResponse(JSON.stringify(this.getPendingBatches(), null, 2));
|
|
233
233
|
}
|
|
234
234
|
if (toolName === "provide_batch_mock_data") {
|
|
@@ -243,14 +243,14 @@ export class TestMockMCPServer {
|
|
|
243
243
|
this.transport =
|
|
244
244
|
this.options.transportFactory?.() ?? new StdioServerTransport();
|
|
245
245
|
await this.mcpServer.connect(this.transport);
|
|
246
|
-
this.logger.
|
|
246
|
+
this.logger.error("✅ MCP server is ready (stdio transport)");
|
|
247
247
|
}
|
|
248
248
|
handleConnection(ws) {
|
|
249
|
-
this.logger.
|
|
249
|
+
this.logger.error("🔌 Test process connected");
|
|
250
250
|
this.clients.add(ws);
|
|
251
251
|
ws.on("message", (data) => this.handleClientMessage(ws, data));
|
|
252
252
|
ws.on("close", () => {
|
|
253
|
-
this.logger.
|
|
253
|
+
this.logger.error("🔌 Test process disconnected");
|
|
254
254
|
this.clients.delete(ws);
|
|
255
255
|
this.dropBatchesForClient(ws);
|
|
256
256
|
});
|
|
@@ -292,11 +292,11 @@ export class TestMockMCPServer {
|
|
|
292
292
|
ws,
|
|
293
293
|
expiresAt,
|
|
294
294
|
});
|
|
295
|
-
this.logger.
|
|
295
|
+
this.logger.error([
|
|
296
296
|
`📥 Received ${requests.length} request(s) (${batchId})`,
|
|
297
297
|
...requests.map((req, index) => ` ${index + 1}. ${req.method} ${req.endpoint} (${req.requestId})`),
|
|
298
298
|
].join("\n"));
|
|
299
|
-
this.logger.
|
|
299
|
+
this.logger.error("⏳ Awaiting mock data from MCP client...");
|
|
300
300
|
}
|
|
301
301
|
dropBatchesForClient(ws) {
|
|
302
302
|
for (const [batchId, batch] of this.pendingBatches) {
|
|
@@ -325,7 +325,7 @@ export class TestMockMCPServer {
|
|
|
325
325
|
const entry = this.buildLogEntry(batch, mocks);
|
|
326
326
|
const filePath = path.join(directory, `mock-${batch.batchId}.json`);
|
|
327
327
|
await writeFile(filePath, JSON.stringify(entry, null, 2), "utf8");
|
|
328
|
-
this.logger.
|
|
328
|
+
this.logger.error(`📝 Saved mock batch ${batch.batchId} to ${filePath}`);
|
|
329
329
|
}
|
|
330
330
|
buildLogEntry(batch, mocks) {
|
|
331
331
|
const mockMap = new Map(mocks.map((mock) => [mock.requestId, mock]));
|