@proofofprotocol/inscribe-mcp 0.2.0 → 0.3.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/README.md CHANGED
@@ -45,13 +45,21 @@ Hedera Testnet アカウントは [portal.hedera.com](https://portal.hedera.com)
45
45
 
46
46
  ### 3. Claude Desktop に接続
47
47
 
48
+ ```bash
49
+ # 自動設定(推奨)
50
+ inscribe-mcp setup-mcp --claude-desktop
51
+
52
+ # または手動設定
53
+ inscribe-mcp setup-mcp --show-json
54
+ ```
55
+
48
56
  `claude_desktop_config.json`:
49
57
  ```json
50
58
  {
51
59
  "mcpServers": {
52
60
  "inscribe": {
53
61
  "command": "npx",
54
- "args": ["@proofofprotocol/inscribe-mcp-server"]
62
+ "args": ["-y", "@proofofprotocol/inscribe-mcp", "inscribe-mcp-server"]
55
63
  }
56
64
  }
57
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proofofprotocol/inscribe-mcp",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
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",
@@ -0,0 +1,205 @@
1
+ /**
2
+ * setup-mcp command
3
+ *
4
+ * Configure MCP client to use inscribe-mcp server.
5
+ */
6
+
7
+ import { Command } from 'commander';
8
+ import { createInterface } from 'readline';
9
+ import { existsSync, readFileSync, writeFileSync, copyFileSync } from 'fs';
10
+ import { homedir, platform } from 'os';
11
+ import { join } from 'path';
12
+ import { EXIT_CODES } from '../lib/exit-codes.js';
13
+ import { configExists } from '../lib/config.js';
14
+
15
+ // Simple prompt helper
16
+ function prompt(question) {
17
+ const rl = createInterface({
18
+ input: process.stdin,
19
+ output: process.stdout
20
+ });
21
+
22
+ return new Promise((resolve) => {
23
+ rl.question(question, (answer) => {
24
+ rl.close();
25
+ resolve(answer.trim());
26
+ });
27
+ });
28
+ }
29
+
30
+ // ANSI colors
31
+ const colors = {
32
+ green: (s) => `\x1b[32m${s}\x1b[0m`,
33
+ yellow: (s) => `\x1b[33m${s}\x1b[0m`,
34
+ red: (s) => `\x1b[31m${s}\x1b[0m`,
35
+ cyan: (s) => `\x1b[36m${s}\x1b[0m`,
36
+ bold: (s) => `\x1b[1m${s}\x1b[0m`,
37
+ dim: (s) => `\x1b[2m${s}\x1b[0m`
38
+ };
39
+
40
+ // Get Claude Desktop config path based on OS
41
+ function getClaudeDesktopConfigPath() {
42
+ const os = platform();
43
+ if (os === 'darwin') {
44
+ return join(homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
45
+ } else if (os === 'win32') {
46
+ return join(process.env.APPDATA || join(homedir(), 'AppData', 'Roaming'), 'Claude', 'claude_desktop_config.json');
47
+ } else {
48
+ // Linux
49
+ return join(homedir(), '.config', 'Claude', 'claude_desktop_config.json');
50
+ }
51
+ }
52
+
53
+ // MCP server config for inscribe
54
+ const INSCRIBE_MCP_CONFIG = {
55
+ command: 'npx',
56
+ args: ['-y', '@proofofprotocol/inscribe-mcp', 'inscribe-mcp-server']
57
+ };
58
+
59
+ // Generate JSON snippet for display
60
+ function generateJsonSnippet() {
61
+ return JSON.stringify({
62
+ mcpServers: {
63
+ inscribe: INSCRIBE_MCP_CONFIG
64
+ }
65
+ }, null, 2);
66
+ }
67
+
68
+ export const setupMcpCommand = new Command('setup-mcp')
69
+ .description('Configure MCP client to use inscribe-mcp server')
70
+ .option('--claude-desktop', 'Configure Claude Desktop automatically')
71
+ .option('--show-json', 'Just show the JSON configuration')
72
+ .action(async (options) => {
73
+ console.log('');
74
+ console.log(colors.bold('inscribe-mcp MCP Setup'));
75
+ console.log('─'.repeat(40));
76
+ console.log('');
77
+
78
+ // Check if inscribe-mcp is configured
79
+ if (!configExists()) {
80
+ console.log(colors.yellow('⚠ inscribe-mcp is not configured yet.'));
81
+ console.log('');
82
+ console.log('Run ' + colors.cyan('inscribe-mcp init') + ' first to set up your Hedera account.');
83
+ console.log('');
84
+ process.exit(EXIT_CODES.ERROR);
85
+ }
86
+
87
+ // If --show-json, just display and exit
88
+ if (options.showJson) {
89
+ console.log('Add this to your MCP client configuration:');
90
+ console.log('');
91
+ console.log(colors.cyan(generateJsonSnippet()));
92
+ console.log('');
93
+ process.exit(EXIT_CODES.SUCCESS);
94
+ }
95
+
96
+ // If --claude-desktop, skip selection
97
+ let clientChoice = options.claudeDesktop ? 'claude' : null;
98
+
99
+ if (!clientChoice) {
100
+ console.log(colors.bold('Select MCP Client'));
101
+ console.log('');
102
+ console.log(' 1) ' + colors.cyan('Claude Desktop') + colors.dim(' (auto-configure)'));
103
+ console.log(' 2) ' + colors.dim('Other MCP client') + colors.dim(' (show JSON)'));
104
+ console.log('');
105
+
106
+ while (!clientChoice) {
107
+ const choice = await prompt('Select (1 or 2): ');
108
+ if (choice === '1') clientChoice = 'claude';
109
+ else if (choice === '2') clientChoice = 'other';
110
+ else console.log(colors.red('Invalid selection. Enter 1 or 2.'));
111
+ }
112
+ console.log('');
113
+ }
114
+
115
+ if (clientChoice === 'other') {
116
+ // Just show JSON
117
+ console.log(colors.bold('MCP Configuration'));
118
+ console.log('');
119
+ console.log('Add this to your MCP client configuration:');
120
+ console.log('');
121
+ console.log(colors.cyan(generateJsonSnippet()));
122
+ console.log('');
123
+ process.exit(EXIT_CODES.SUCCESS);
124
+ }
125
+
126
+ // Claude Desktop configuration
127
+ console.log(colors.bold('Claude Desktop Configuration'));
128
+ console.log('');
129
+
130
+ const configPath = getClaudeDesktopConfigPath();
131
+ console.log('Config file: ' + colors.dim(configPath));
132
+ console.log('');
133
+
134
+ // Check if config file exists
135
+ let existingConfig = { mcpServers: {} };
136
+ let configFileExists = false;
137
+
138
+ if (existsSync(configPath)) {
139
+ configFileExists = true;
140
+ try {
141
+ const content = readFileSync(configPath, 'utf-8');
142
+ existingConfig = JSON.parse(content);
143
+ if (!existingConfig.mcpServers) {
144
+ existingConfig.mcpServers = {};
145
+ }
146
+ } catch (error) {
147
+ console.log(colors.yellow('⚠ Could not parse existing config, will create new one.'));
148
+ existingConfig = { mcpServers: {} };
149
+ }
150
+ }
151
+
152
+ // Check if inscribe is already configured
153
+ if (existingConfig.mcpServers.inscribe) {
154
+ console.log(colors.yellow('inscribe is already configured in Claude Desktop.'));
155
+ console.log('');
156
+ const confirm = await prompt('Overwrite? (yes/no): ');
157
+ if (confirm.toLowerCase() !== 'yes') {
158
+ console.log('Aborted.');
159
+ process.exit(EXIT_CODES.SUCCESS);
160
+ }
161
+ console.log('');
162
+ }
163
+
164
+ // Backup existing config if it exists
165
+ if (configFileExists) {
166
+ const backupPath = configPath + '.backup.' + Date.now();
167
+ try {
168
+ copyFileSync(configPath, backupPath);
169
+ console.log(colors.green('✓') + ' Backup created: ' + colors.dim(backupPath));
170
+ } catch (error) {
171
+ console.log(colors.yellow('⚠ Could not create backup: ' + error.message));
172
+ }
173
+ }
174
+
175
+ // Add inscribe config
176
+ existingConfig.mcpServers.inscribe = INSCRIBE_MCP_CONFIG;
177
+
178
+ // Write new config
179
+ try {
180
+ writeFileSync(configPath, JSON.stringify(existingConfig, null, 2), 'utf-8');
181
+ console.log(colors.green('✓') + ' Configuration updated');
182
+ } catch (error) {
183
+ console.log(colors.red('✗ Failed to write config: ' + error.message));
184
+ console.log('');
185
+ console.log('You may need to create the config file manually:');
186
+ console.log(colors.cyan(configPath));
187
+ console.log('');
188
+ console.log('With content:');
189
+ console.log(colors.cyan(generateJsonSnippet()));
190
+ console.log('');
191
+ process.exit(EXIT_CODES.ERROR);
192
+ }
193
+
194
+ console.log('');
195
+ console.log('─'.repeat(40));
196
+ console.log(colors.green(colors.bold('✓ Setup Complete!')));
197
+ console.log('');
198
+ console.log('Next steps:');
199
+ console.log(' 1. ' + colors.cyan('Restart Claude Desktop'));
200
+ console.log(' 2. Look for "inscribe" in the MCP tools menu');
201
+ console.log(' 3. Try: "このテキストを刻んで: Hello World"');
202
+ console.log('');
203
+
204
+ process.exit(EXIT_CODES.SUCCESS);
205
+ });
package/src/cli/index.js CHANGED
@@ -17,6 +17,7 @@ import { configCommand } from './commands/config.js';
17
17
  import { balanceCommand } from './commands/balance.js';
18
18
  import { logCommand } from './commands/log.js';
19
19
  import { showCommand } from './commands/show.js';
20
+ import { setupMcpCommand } from './commands/setup-mcp.js';
20
21
 
21
22
  const __filename = fileURLToPath(import.meta.url);
22
23
  const __dirname = dirname(__filename);
@@ -35,6 +36,7 @@ program
35
36
 
36
37
  // Register commands
37
38
  program.addCommand(initCommand);
39
+ program.addCommand(setupMcpCommand);
38
40
  program.addCommand(configCommand);
39
41
  program.addCommand(balanceCommand);
40
42
  program.addCommand(logCommand);