@proofofprotocol/inscribe-mcp 0.3.3 → 0.3.5
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/debug.js +5 -4
- package/src/lib/logger.js +45 -4
- package/src/server.js +23 -12
package/package.json
CHANGED
|
@@ -85,9 +85,10 @@ export const debugCommand = new Command('debug')
|
|
|
85
85
|
console.log(`Auto-off: in ${durationMinutes} minutes`);
|
|
86
86
|
console.log('');
|
|
87
87
|
console.log(colors.bold('Next steps:'));
|
|
88
|
-
console.log(' 1.
|
|
89
|
-
console.log(' 2.
|
|
90
|
-
console.log('
|
|
88
|
+
console.log(' 1. Use inscribe tools to generate debug traces');
|
|
89
|
+
console.log(' 2. ' + colors.cyan('inscribe-mcp show --debug') + ' to view traces');
|
|
90
|
+
console.log('');
|
|
91
|
+
console.log(colors.dim('No restart required - takes effect immediately.'));
|
|
91
92
|
console.log('');
|
|
92
93
|
process.exit(EXIT_CODES.SUCCESS);
|
|
93
94
|
}
|
|
@@ -97,7 +98,7 @@ export const debugCommand = new Command('debug')
|
|
|
97
98
|
console.log('');
|
|
98
99
|
console.log(colors.green('✓') + ' Debug mode ' + colors.dim('OFF'));
|
|
99
100
|
console.log('');
|
|
100
|
-
console.log('
|
|
101
|
+
console.log(colors.dim('Takes effect immediately.'));
|
|
101
102
|
console.log('');
|
|
102
103
|
process.exit(EXIT_CODES.SUCCESS);
|
|
103
104
|
}
|
package/src/lib/logger.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Used by MCP Server to record all tool executions.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { existsSync, mkdirSync, appendFileSync } from 'fs';
|
|
8
|
+
import { existsSync, mkdirSync, appendFileSync, readFileSync } from 'fs';
|
|
9
9
|
import { homedir } from 'os';
|
|
10
10
|
import { join } from 'path';
|
|
11
11
|
|
|
@@ -80,6 +80,41 @@ export function logToolExecution({
|
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Check if debug mode is enabled (config or env)
|
|
85
|
+
*/
|
|
86
|
+
function isDebugEnabled() {
|
|
87
|
+
// Environment variable takes precedence
|
|
88
|
+
if (process.env.INSCRIBE_MCP_DEBUG === '1' || process.env.INSCRIBE_MCP_DEBUG === 'true') {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Check config file
|
|
93
|
+
const configPath = join(homedir(), '.inscribe-mcp', 'config.json');
|
|
94
|
+
if (!existsSync(configPath)) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
const config = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
100
|
+
if (!config.debug || !config.debug.enabled) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Check expiry
|
|
105
|
+
if (config.debug.expiresAt) {
|
|
106
|
+
const expiry = new Date(config.debug.expiresAt);
|
|
107
|
+
if (Date.now() > expiry.getTime()) {
|
|
108
|
+
return false; // Expired
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return true;
|
|
113
|
+
} catch {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
83
118
|
/**
|
|
84
119
|
* Log a debug sequence trace
|
|
85
120
|
* @param {Object} options - Debug trace options
|
|
@@ -90,10 +125,13 @@ export function logDebugTrace({
|
|
|
90
125
|
payload = null,
|
|
91
126
|
status = null,
|
|
92
127
|
txId = null,
|
|
93
|
-
result = null
|
|
128
|
+
result = null,
|
|
129
|
+
duration = null,
|
|
130
|
+
args = null,
|
|
131
|
+
error = null
|
|
94
132
|
}) {
|
|
95
133
|
// Only log if debug mode is enabled
|
|
96
|
-
if (!
|
|
134
|
+
if (!isDebugEnabled()) return;
|
|
97
135
|
|
|
98
136
|
writeLog({
|
|
99
137
|
level: 'debug',
|
|
@@ -102,7 +140,10 @@ export function logDebugTrace({
|
|
|
102
140
|
payload,
|
|
103
141
|
status,
|
|
104
142
|
txId,
|
|
105
|
-
result
|
|
143
|
+
result,
|
|
144
|
+
duration,
|
|
145
|
+
args,
|
|
146
|
+
error
|
|
106
147
|
});
|
|
107
148
|
}
|
|
108
149
|
|
package/src/server.js
CHANGED
|
@@ -20,6 +20,9 @@ import { existsSync, readFileSync } from 'fs';
|
|
|
20
20
|
import { homedir } from 'os';
|
|
21
21
|
import { join } from 'path';
|
|
22
22
|
|
|
23
|
+
// Logger for file-based debug traces (import early for use in debugLog)
|
|
24
|
+
import { logDebugTrace } from './lib/logger.js';
|
|
25
|
+
|
|
23
26
|
/**
|
|
24
27
|
* Check if debug mode is enabled (config or env)
|
|
25
28
|
*/
|
|
@@ -55,14 +58,12 @@ function isDebugEnabled() {
|
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
|
|
58
|
-
// Debug mode check (evaluated at startup)
|
|
59
|
-
const DEBUG = isDebugEnabled();
|
|
60
|
-
|
|
61
61
|
/**
|
|
62
|
-
* Debug log to stderr (safe for MCP stdio transport)
|
|
62
|
+
* Debug log to stderr AND file (safe for MCP stdio transport)
|
|
63
|
+
* Checks config on each call for hot-reload support
|
|
63
64
|
*/
|
|
64
65
|
function debugLog(phase, data = {}) {
|
|
65
|
-
if (!
|
|
66
|
+
if (!isDebugEnabled()) return;
|
|
66
67
|
|
|
67
68
|
const timestamp = new Date().toISOString();
|
|
68
69
|
const message = {
|
|
@@ -73,6 +74,16 @@ function debugLog(phase, data = {}) {
|
|
|
73
74
|
|
|
74
75
|
// Output to stderr to avoid interfering with MCP JSON-RPC over stdout
|
|
75
76
|
console.error(`[DEBUG] ${JSON.stringify(message)}`);
|
|
77
|
+
|
|
78
|
+
// Also write to file for `inscribe-mcp show --debug`
|
|
79
|
+
logDebugTrace({
|
|
80
|
+
phase,
|
|
81
|
+
tool: data.tool,
|
|
82
|
+
args: data.args,
|
|
83
|
+
status: data.status,
|
|
84
|
+
duration: data.duration,
|
|
85
|
+
error: data.error
|
|
86
|
+
});
|
|
76
87
|
}
|
|
77
88
|
|
|
78
89
|
// Layer 1 Tools (Primary)
|
|
@@ -218,16 +229,16 @@ async function main() {
|
|
|
218
229
|
const transport = new StdioServerTransport();
|
|
219
230
|
await server.connect(transport);
|
|
220
231
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
232
|
+
// Log startup (debug mode is now hot-reloadable)
|
|
233
|
+
console.error('inscribe-mcp server started (stdio)');
|
|
234
|
+
|
|
235
|
+
// Initial debug log if enabled
|
|
236
|
+
if (isDebugEnabled()) {
|
|
237
|
+
console.error('Debug mode is currently ON (hot-reloadable)');
|
|
224
238
|
debugLog('server_start', {
|
|
225
|
-
version: '0.3.
|
|
226
|
-
debug: true,
|
|
239
|
+
version: '0.3.5',
|
|
227
240
|
tools: allTools.map(t => t.name)
|
|
228
241
|
});
|
|
229
|
-
} else {
|
|
230
|
-
console.error('inscribe-mcp server started (stdio)');
|
|
231
242
|
}
|
|
232
243
|
}
|
|
233
244
|
|