@proofofprotocol/inscribe-mcp 0.3.5 → 0.3.7
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/package.json +1 -1
- package/src/cli/commands/show.js +109 -37
- package/src/lib/logger.js +22 -2
- package/src/server.js +48 -10
package/package.json
CHANGED
package/src/cli/commands/show.js
CHANGED
|
@@ -317,75 +317,147 @@ export const showCommand = new Command('show')
|
|
|
317
317
|
// Debug trace section
|
|
318
318
|
if (options.debug) {
|
|
319
319
|
console.log('');
|
|
320
|
-
console.log(colors.bold('MCP Sequence Debug Traces'));
|
|
320
|
+
console.log(colors.bold('MCP Sequence Debug Traces (LAN Analyzer View)'));
|
|
321
321
|
console.log(line);
|
|
322
322
|
|
|
323
|
-
const traces = getDebugTraces(logsDir,
|
|
323
|
+
const traces = getDebugTraces(logsDir, 100);
|
|
324
324
|
|
|
325
325
|
if (traces.length === 0) {
|
|
326
326
|
console.log(colors.dim('No debug traces found.'));
|
|
327
327
|
console.log('');
|
|
328
|
-
console.log('To enable debug logging
|
|
329
|
-
console.log(colors.cyan('
|
|
328
|
+
console.log('To enable debug logging:');
|
|
329
|
+
console.log(colors.cyan(' inscribe-mcp debug on'));
|
|
330
330
|
console.log('');
|
|
331
|
-
console.log('
|
|
331
|
+
console.log('Or set environment variable:');
|
|
332
|
+
console.log(colors.cyan(' export INSCRIBE_MCP_DEBUG=1'));
|
|
332
333
|
} else {
|
|
333
334
|
const sequences = formatSequenceTrace(traces);
|
|
334
335
|
|
|
335
336
|
if (sequences.length === 0) {
|
|
336
337
|
console.log(colors.dim('No complete sequences found.'));
|
|
337
338
|
} else {
|
|
338
|
-
//
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
339
|
+
// LAN Analyzer style header
|
|
340
|
+
console.log('');
|
|
341
|
+
console.log(colors.dim('┌──────────────┬───────┬────────────────────┬───────────────────────────────────────┐'));
|
|
342
|
+
console.log(colors.dim('│ Timestamp │ Dir │ Phase │ Details │'));
|
|
343
|
+
console.log(colors.dim('├──────────────┼───────┼────────────────────┼───────────────────────────────────────┤'));
|
|
344
|
+
|
|
345
|
+
// Direction symbols
|
|
346
|
+
const dirSymbols = {
|
|
347
|
+
'IN': colors.green('←IN '),
|
|
348
|
+
'OUT': colors.cyan('→OUT'),
|
|
349
|
+
'ERR': colors.red('✗ERR')
|
|
344
350
|
};
|
|
345
351
|
|
|
346
352
|
const phaseLabels = {
|
|
347
353
|
'agent_to_mcp': 'Agent → MCP',
|
|
348
354
|
'mcp_to_chain': 'MCP → Chain',
|
|
349
355
|
'chain_to_mcp': 'Chain → MCP',
|
|
350
|
-
'mcp_to_agent': 'MCP → Agent'
|
|
356
|
+
'mcp_to_agent': 'MCP → Agent',
|
|
357
|
+
'mcp_error': 'MCP Error'
|
|
351
358
|
};
|
|
352
359
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
console.log('');
|
|
360
|
+
for (const seq of sequences.slice(-8)) { // Last 8 sequences
|
|
361
|
+
// Sequence header
|
|
362
|
+
const seqTime = new Date(seq.timestamp);
|
|
363
|
+
const timeStr = seqTime.toLocaleTimeString('en-US', { hour12: false });
|
|
364
|
+
const msStr = String(seqTime.getMilliseconds()).padStart(3, '0');
|
|
359
365
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
366
|
+
console.log(colors.dim('│') + colors.bold(` ${timeStr}.${msStr}`) + colors.dim(' │ │ ') +
|
|
367
|
+
colors.cyan(colors.bold(`[${seq.tool}]`)).padEnd(28) + colors.dim(' │') +
|
|
368
|
+
colors.dim(' ─────────────────────────────────────── │'));
|
|
363
369
|
|
|
364
370
|
for (const phase of seq.phases) {
|
|
365
|
-
const
|
|
366
|
-
const
|
|
367
|
-
|
|
371
|
+
const phaseTime = new Date(phase.timestamp);
|
|
372
|
+
const pTimeStr = phaseTime.toLocaleTimeString('en-US', { hour12: false });
|
|
373
|
+
const pMsStr = String(phaseTime.getMilliseconds()).padStart(3, '0');
|
|
374
|
+
|
|
375
|
+
const dir = dirSymbols[phase.direction] || colors.dim('─── ');
|
|
376
|
+
const phaseLabel = (phaseLabels[phase.phase] || phase.phase).padEnd(18);
|
|
377
|
+
|
|
378
|
+
// Build details string based on phase type
|
|
379
|
+
let details = [];
|
|
380
|
+
|
|
381
|
+
// Agent → MCP phase: show method, requestId, args
|
|
382
|
+
if (phase.phase === 'agent_to_mcp') {
|
|
383
|
+
if (phase.method) {
|
|
384
|
+
details.push(colors.cyan(phase.method));
|
|
385
|
+
}
|
|
386
|
+
if (phase.requestId) {
|
|
387
|
+
const shortId = String(phase.requestId).slice(-8);
|
|
388
|
+
details.push(`id:${shortId}`);
|
|
389
|
+
}
|
|
390
|
+
if (phase.argsKeys && phase.argsKeys.length > 0) {
|
|
391
|
+
details.push(`[${phase.argsKeys.join(',')}]`);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
368
394
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
395
|
+
// MCP → Chain phase: show action
|
|
396
|
+
if (phase.phase === 'mcp_to_chain') {
|
|
397
|
+
if (phase.action) {
|
|
398
|
+
details.push(colors.yellow(phase.action));
|
|
399
|
+
}
|
|
400
|
+
if (phase.requestId) {
|
|
401
|
+
const shortId = String(phase.requestId).slice(-8);
|
|
402
|
+
details.push(`id:${shortId}`);
|
|
403
|
+
}
|
|
372
404
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
405
|
+
|
|
406
|
+
// Chain → MCP phase: show status, duration, txId
|
|
407
|
+
if (phase.phase === 'chain_to_mcp') {
|
|
408
|
+
if (phase.status) {
|
|
409
|
+
const statusColor = phase.status === 'SUCCESS' ? colors.green : colors.red;
|
|
410
|
+
details.push(statusColor(phase.status));
|
|
411
|
+
}
|
|
412
|
+
if (phase.duration !== undefined) {
|
|
413
|
+
details.push(colors.yellow(`${phase.duration}ms`));
|
|
414
|
+
}
|
|
415
|
+
if (phase.resultPreview && phase.resultPreview.txId) {
|
|
416
|
+
const shortTx = String(phase.resultPreview.txId).slice(0, 16);
|
|
417
|
+
details.push(`tx:${shortTx}...`);
|
|
418
|
+
}
|
|
419
|
+
if (phase.error) {
|
|
420
|
+
details.push(colors.red(phase.error.slice(0, 20)));
|
|
421
|
+
}
|
|
377
422
|
}
|
|
378
|
-
|
|
379
|
-
|
|
423
|
+
|
|
424
|
+
// MCP → Agent phase: show status, duration, size
|
|
425
|
+
if (phase.phase === 'mcp_to_agent') {
|
|
426
|
+
if (phase.status) {
|
|
427
|
+
const statusColor = phase.status === 'SUCCESS' ? colors.green : colors.red;
|
|
428
|
+
details.push(statusColor(phase.status));
|
|
429
|
+
}
|
|
430
|
+
if (phase.duration !== undefined) {
|
|
431
|
+
details.push(colors.yellow(`${phase.duration}ms`));
|
|
432
|
+
}
|
|
433
|
+
if (phase.responseSize) {
|
|
434
|
+
details.push(`${phase.responseSize}b`);
|
|
435
|
+
}
|
|
436
|
+
if (phase.error) {
|
|
437
|
+
details.push(colors.red(phase.error.slice(0, 20)));
|
|
438
|
+
}
|
|
380
439
|
}
|
|
381
|
-
|
|
382
|
-
|
|
440
|
+
|
|
441
|
+
// MCP Error phase
|
|
442
|
+
if (phase.phase === 'mcp_error') {
|
|
443
|
+
if (phase.error) {
|
|
444
|
+
details.push(colors.red(phase.error));
|
|
445
|
+
}
|
|
446
|
+
if (phase.duration !== undefined) {
|
|
447
|
+
details.push(colors.yellow(`${phase.duration}ms`));
|
|
448
|
+
}
|
|
383
449
|
}
|
|
384
450
|
|
|
385
|
-
|
|
451
|
+
const detailStr = details.join(' ').slice(0, 37).padEnd(37);
|
|
452
|
+
|
|
453
|
+
console.log(colors.dim('│ ') + `${pTimeStr}.${pMsStr}` + colors.dim(' │ ') +
|
|
454
|
+
dir + colors.dim(' │ ') + phaseLabel + colors.dim(' │ ') + detailStr + colors.dim(' │'));
|
|
386
455
|
}
|
|
387
|
-
console.log('');
|
|
388
456
|
}
|
|
457
|
+
|
|
458
|
+
console.log(colors.dim('└──────────────┴───────┴────────────────────┴───────────────────────────────────────┘'));
|
|
459
|
+
console.log('');
|
|
460
|
+
console.log(colors.dim(`Showing last ${Math.min(8, sequences.length)} of ${sequences.length} sequences`));
|
|
389
461
|
}
|
|
390
462
|
}
|
|
391
463
|
}
|
package/src/lib/logger.js
CHANGED
|
@@ -128,7 +128,17 @@ export function logDebugTrace({
|
|
|
128
128
|
result = null,
|
|
129
129
|
duration = null,
|
|
130
130
|
args = null,
|
|
131
|
-
error = null
|
|
131
|
+
error = null,
|
|
132
|
+
// LAN analyzer style additional fields
|
|
133
|
+
method = null,
|
|
134
|
+
requestId = null,
|
|
135
|
+
argsKeys = null,
|
|
136
|
+
argsPreview = null,
|
|
137
|
+
action = null,
|
|
138
|
+
direction = null,
|
|
139
|
+
resultPreview = null,
|
|
140
|
+
responseSize = null,
|
|
141
|
+
errorType = null
|
|
132
142
|
}) {
|
|
133
143
|
// Only log if debug mode is enabled
|
|
134
144
|
if (!isDebugEnabled()) return;
|
|
@@ -143,7 +153,17 @@ export function logDebugTrace({
|
|
|
143
153
|
result,
|
|
144
154
|
duration,
|
|
145
155
|
args,
|
|
146
|
-
error
|
|
156
|
+
error,
|
|
157
|
+
// LAN analyzer style additional fields
|
|
158
|
+
method,
|
|
159
|
+
requestId,
|
|
160
|
+
argsKeys,
|
|
161
|
+
argsPreview,
|
|
162
|
+
action,
|
|
163
|
+
direction,
|
|
164
|
+
resultPreview,
|
|
165
|
+
responseSize,
|
|
166
|
+
errorType
|
|
147
167
|
});
|
|
148
168
|
}
|
|
149
169
|
|
package/src/server.js
CHANGED
|
@@ -82,7 +82,17 @@ function debugLog(phase, data = {}) {
|
|
|
82
82
|
args: data.args,
|
|
83
83
|
status: data.status,
|
|
84
84
|
duration: data.duration,
|
|
85
|
-
error: data.error
|
|
85
|
+
error: data.error,
|
|
86
|
+
// LAN analyzer style fields
|
|
87
|
+
method: data.method,
|
|
88
|
+
requestId: data.requestId,
|
|
89
|
+
argsKeys: data.argsKeys,
|
|
90
|
+
argsPreview: data.argsPreview,
|
|
91
|
+
action: data.action,
|
|
92
|
+
direction: data.direction,
|
|
93
|
+
resultPreview: data.resultPreview,
|
|
94
|
+
responseSize: data.responseSize,
|
|
95
|
+
errorType: data.errorType
|
|
86
96
|
});
|
|
87
97
|
}
|
|
88
98
|
|
|
@@ -149,19 +159,28 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
149
159
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
150
160
|
const { name, arguments: args } = request.params;
|
|
151
161
|
const startTime = Date.now();
|
|
162
|
+
const requestId = request.id || `req_${Date.now()}`;
|
|
152
163
|
|
|
153
|
-
// Debug: Agent → MCP (request received)
|
|
164
|
+
// Debug: Agent → MCP (request received) - LAN analyzer style
|
|
154
165
|
debugLog('agent_to_mcp', {
|
|
155
166
|
tool: name,
|
|
156
|
-
|
|
167
|
+
method: 'tools/call',
|
|
168
|
+
requestId,
|
|
169
|
+
argsKeys: args ? Object.keys(args) : [],
|
|
170
|
+
argsPreview: args ? JSON.stringify(args).slice(0, 100) : null,
|
|
171
|
+
direction: 'IN'
|
|
157
172
|
});
|
|
158
173
|
|
|
159
174
|
const tool = allTools.find(t => t.name === name);
|
|
160
175
|
|
|
161
176
|
if (!tool) {
|
|
177
|
+
const duration = Date.now() - startTime;
|
|
162
178
|
debugLog('mcp_error', {
|
|
163
179
|
tool: name,
|
|
164
|
-
|
|
180
|
+
requestId,
|
|
181
|
+
error: 'Unknown tool',
|
|
182
|
+
duration,
|
|
183
|
+
direction: 'ERR'
|
|
165
184
|
});
|
|
166
185
|
|
|
167
186
|
return {
|
|
@@ -174,25 +193,39 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
174
193
|
// Debug: MCP → Chain (processing)
|
|
175
194
|
debugLog('mcp_to_chain', {
|
|
176
195
|
tool: name,
|
|
177
|
-
|
|
196
|
+
requestId,
|
|
197
|
+
action: 'CALL',
|
|
198
|
+
direction: 'OUT'
|
|
178
199
|
});
|
|
179
200
|
|
|
180
201
|
const result = await tool.handler(args || {});
|
|
181
202
|
const duration = Date.now() - startTime;
|
|
182
203
|
|
|
204
|
+
// Extract key info from result for debug
|
|
205
|
+
const resultPreview = result ? {
|
|
206
|
+
success: result.success,
|
|
207
|
+
txId: result.txId || result.inscription_id || result.topic_id,
|
|
208
|
+
type: result.type
|
|
209
|
+
} : null;
|
|
210
|
+
|
|
183
211
|
// Debug: Chain → MCP (response)
|
|
184
212
|
debugLog('chain_to_mcp', {
|
|
185
213
|
tool: name,
|
|
214
|
+
requestId,
|
|
186
215
|
status: 'SUCCESS',
|
|
187
216
|
duration,
|
|
188
|
-
|
|
217
|
+
resultPreview,
|
|
218
|
+
direction: 'IN'
|
|
189
219
|
});
|
|
190
220
|
|
|
191
221
|
// Debug: MCP → Agent (returning result)
|
|
192
222
|
debugLog('mcp_to_agent', {
|
|
193
223
|
tool: name,
|
|
224
|
+
requestId,
|
|
194
225
|
status: 'SUCCESS',
|
|
195
|
-
duration
|
|
226
|
+
duration,
|
|
227
|
+
responseSize: JSON.stringify(result).length,
|
|
228
|
+
direction: 'OUT'
|
|
196
229
|
});
|
|
197
230
|
|
|
198
231
|
return {
|
|
@@ -204,17 +237,22 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
204
237
|
// Debug: Chain → MCP (error)
|
|
205
238
|
debugLog('chain_to_mcp', {
|
|
206
239
|
tool: name,
|
|
240
|
+
requestId,
|
|
207
241
|
status: 'FAILED',
|
|
208
242
|
duration,
|
|
209
|
-
error: error.message
|
|
243
|
+
error: error.message,
|
|
244
|
+
errorType: error.constructor.name,
|
|
245
|
+
direction: 'IN'
|
|
210
246
|
});
|
|
211
247
|
|
|
212
248
|
// Debug: MCP → Agent (returning error)
|
|
213
249
|
debugLog('mcp_to_agent', {
|
|
214
250
|
tool: name,
|
|
251
|
+
requestId,
|
|
215
252
|
status: 'ERROR',
|
|
216
253
|
duration,
|
|
217
|
-
error: error.message
|
|
254
|
+
error: error.message,
|
|
255
|
+
direction: 'OUT'
|
|
218
256
|
});
|
|
219
257
|
|
|
220
258
|
return {
|
|
@@ -236,7 +274,7 @@ async function main() {
|
|
|
236
274
|
if (isDebugEnabled()) {
|
|
237
275
|
console.error('Debug mode is currently ON (hot-reloadable)');
|
|
238
276
|
debugLog('server_start', {
|
|
239
|
-
version: '0.3.
|
|
277
|
+
version: '0.3.7',
|
|
240
278
|
tools: allTools.map(t => t.name)
|
|
241
279
|
});
|
|
242
280
|
}
|