@proofofprotocol/inscribe-mcp 0.3.5 → 0.3.6
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 +37 -9
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
|
@@ -149,19 +149,28 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
149
149
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
150
150
|
const { name, arguments: args } = request.params;
|
|
151
151
|
const startTime = Date.now();
|
|
152
|
+
const requestId = request.id || `req_${Date.now()}`;
|
|
152
153
|
|
|
153
|
-
// Debug: Agent → MCP (request received)
|
|
154
|
+
// Debug: Agent → MCP (request received) - LAN analyzer style
|
|
154
155
|
debugLog('agent_to_mcp', {
|
|
155
156
|
tool: name,
|
|
156
|
-
|
|
157
|
+
method: 'tools/call',
|
|
158
|
+
requestId,
|
|
159
|
+
argsKeys: args ? Object.keys(args) : [],
|
|
160
|
+
argsPreview: args ? JSON.stringify(args).slice(0, 100) : null,
|
|
161
|
+
direction: 'IN'
|
|
157
162
|
});
|
|
158
163
|
|
|
159
164
|
const tool = allTools.find(t => t.name === name);
|
|
160
165
|
|
|
161
166
|
if (!tool) {
|
|
167
|
+
const duration = Date.now() - startTime;
|
|
162
168
|
debugLog('mcp_error', {
|
|
163
169
|
tool: name,
|
|
164
|
-
|
|
170
|
+
requestId,
|
|
171
|
+
error: 'Unknown tool',
|
|
172
|
+
duration,
|
|
173
|
+
direction: 'ERR'
|
|
165
174
|
});
|
|
166
175
|
|
|
167
176
|
return {
|
|
@@ -174,25 +183,39 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
174
183
|
// Debug: MCP → Chain (processing)
|
|
175
184
|
debugLog('mcp_to_chain', {
|
|
176
185
|
tool: name,
|
|
177
|
-
|
|
186
|
+
requestId,
|
|
187
|
+
action: 'CALL',
|
|
188
|
+
direction: 'OUT'
|
|
178
189
|
});
|
|
179
190
|
|
|
180
191
|
const result = await tool.handler(args || {});
|
|
181
192
|
const duration = Date.now() - startTime;
|
|
182
193
|
|
|
194
|
+
// Extract key info from result for debug
|
|
195
|
+
const resultPreview = result ? {
|
|
196
|
+
success: result.success,
|
|
197
|
+
txId: result.txId || result.inscription_id || result.topic_id,
|
|
198
|
+
type: result.type
|
|
199
|
+
} : null;
|
|
200
|
+
|
|
183
201
|
// Debug: Chain → MCP (response)
|
|
184
202
|
debugLog('chain_to_mcp', {
|
|
185
203
|
tool: name,
|
|
204
|
+
requestId,
|
|
186
205
|
status: 'SUCCESS',
|
|
187
206
|
duration,
|
|
188
|
-
|
|
207
|
+
resultPreview,
|
|
208
|
+
direction: 'IN'
|
|
189
209
|
});
|
|
190
210
|
|
|
191
211
|
// Debug: MCP → Agent (returning result)
|
|
192
212
|
debugLog('mcp_to_agent', {
|
|
193
213
|
tool: name,
|
|
214
|
+
requestId,
|
|
194
215
|
status: 'SUCCESS',
|
|
195
|
-
duration
|
|
216
|
+
duration,
|
|
217
|
+
responseSize: JSON.stringify(result).length,
|
|
218
|
+
direction: 'OUT'
|
|
196
219
|
});
|
|
197
220
|
|
|
198
221
|
return {
|
|
@@ -204,17 +227,22 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
204
227
|
// Debug: Chain → MCP (error)
|
|
205
228
|
debugLog('chain_to_mcp', {
|
|
206
229
|
tool: name,
|
|
230
|
+
requestId,
|
|
207
231
|
status: 'FAILED',
|
|
208
232
|
duration,
|
|
209
|
-
error: error.message
|
|
233
|
+
error: error.message,
|
|
234
|
+
errorType: error.constructor.name,
|
|
235
|
+
direction: 'IN'
|
|
210
236
|
});
|
|
211
237
|
|
|
212
238
|
// Debug: MCP → Agent (returning error)
|
|
213
239
|
debugLog('mcp_to_agent', {
|
|
214
240
|
tool: name,
|
|
241
|
+
requestId,
|
|
215
242
|
status: 'ERROR',
|
|
216
243
|
duration,
|
|
217
|
-
error: error.message
|
|
244
|
+
error: error.message,
|
|
245
|
+
direction: 'OUT'
|
|
218
246
|
});
|
|
219
247
|
|
|
220
248
|
return {
|
|
@@ -236,7 +264,7 @@ async function main() {
|
|
|
236
264
|
if (isDebugEnabled()) {
|
|
237
265
|
console.error('Debug mode is currently ON (hot-reloadable)');
|
|
238
266
|
debugLog('server_start', {
|
|
239
|
-
version: '0.3.
|
|
267
|
+
version: '0.3.6',
|
|
240
268
|
tools: allTools.map(t => t.name)
|
|
241
269
|
});
|
|
242
270
|
}
|