@proofofprotocol/inscribe-mcp 0.3.4 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proofofprotocol/inscribe-mcp",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Verifiable inscription for AI agents - inscribe anything to blockchain with Hedera HCS",
5
5
  "type": "module",
6
6
  "main": "src/server.js",
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 (!process.env.INSCRIBE_MCP_DEBUG) return;
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
  */
@@ -56,7 +59,7 @@ function isDebugEnabled() {
56
59
  }
57
60
 
58
61
  /**
59
- * Debug log to stderr (safe for MCP stdio transport)
62
+ * Debug log to stderr AND file (safe for MCP stdio transport)
60
63
  * Checks config on each call for hot-reload support
61
64
  */
62
65
  function debugLog(phase, data = {}) {
@@ -71,6 +74,16 @@ function debugLog(phase, data = {}) {
71
74
 
72
75
  // Output to stderr to avoid interfering with MCP JSON-RPC over stdout
73
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
+ });
74
87
  }
75
88
 
76
89
  // Layer 1 Tools (Primary)
@@ -223,7 +236,7 @@ async function main() {
223
236
  if (isDebugEnabled()) {
224
237
  console.error('Debug mode is currently ON (hot-reloadable)');
225
238
  debugLog('server_start', {
226
- version: '0.3.4',
239
+ version: '0.3.5',
227
240
  tools: allTools.map(t => t.name)
228
241
  });
229
242
  }