#!/usr/bin/env node
/**
* AgentBTC MCP Claude Desktop Setup
* Specifically for Claude Desktop integration
*/
import { readFileSync, writeFileSync, existsSync } from 'fs';
import { join } from 'path';
import { homedir } from 'os';
// Detect Claude Desktop config location by platform
function getClaudeConfigPath() {
const platform = process.platform;
switch (platform) {
case 'darwin':
return join(homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
case 'win32':
return join(homedir(), 'AppData', 'Roaming', 'Claude', 'claude_desktop_config.json');
case 'linux':
return join(homedir(), '.config', 'claude', 'claude_desktop_config.json');
default:
return join(homedir(), '.claude', 'claude_desktop_config.json');
}
}
// Default AgentBTC MCP configuration for Claude Desktop
function getDefaultMcpConfig() {
return {
"command": "agentbtc-mcp",
"args": ["start"],
"env": {
"AGENTBTC_LND_HOST": "localhost:10009",
"AGENTBTC_LND_MACAROON": join(homedir(), '.lnd/data/chain/bitcoin/mainnet/readonly.macaroon'),
"AGENTBTC_API_URL": "http://localhost:8000"
}
};
}
// Main setup function
function main() {
console.log('๐ค AgentBTC MCP ร Claude Desktop Setup');
console.log('');
const claudeConfigPath = getClaudeConfigPath();
console.log(`Claude Desktop config: ${claudeConfigPath}`);
// Check if Claude Desktop is installed
if (!existsSync(claudeConfigPath)) {
console.log('');
console.log('โ Claude Desktop config not found!');
console.log('');
console.log('Please make sure:');
console.log('1. Claude Desktop is installed');
console.log('2. You have run Claude Desktop at least once');
console.log('3. Claude Desktop has created its config directory');
console.log('');
console.log('If Claude Desktop is installed but config doesn\'t exist, create it manually:');
console.log('');
console.log(` mkdir -p "${claudeConfigPath.split('/').slice(0, -1).join('/')}"`);
console.log(` echo '{}' > "${claudeConfigPath}"`);
console.log('');
process.exit(1);
}
// Read existing config
let claudeConfig = {};
try {
const configText = readFileSync(claudeConfigPath, 'utf8');
claudeConfig = JSON.parse(configText);
} catch (e) {
console.log('โ ๏ธ Could not read existing Claude config, creating new one...');
claudeConfig = {};
}
// Ensure mcpServers section exists
if (!claudeConfig.mcpServers) {
claudeConfig.mcpServers = {};
}
// Check if AgentBTC is already configured
if (claudeConfig.mcpServers.agentbtc) {
console.log('');
console.log('โ ๏ธ AgentBTC MCP is already configured in Claude Desktop.');
console.log('');
console.log('Current configuration:');
console.log(JSON.stringify(claudeConfig.mcpServers.agentbtc, null, 2));
console.log('');
console.log('To update the configuration, edit the file manually or remove the existing entry.');
process.exit(0);
}
// Add AgentBTC MCP configuration
claudeConfig.mcpServers.agentbtc = getDefaultMcpConfig();
// Write updated config
try {
writeFileSync(claudeConfigPath, JSON.stringify(claudeConfig, null, 2));
console.log('');
console.log('โ
AgentBTC MCP added to Claude Desktop!');
} catch (e) {
console.log('');
console.log(`โ Failed to update Claude Desktop config: ${e.message}`);
console.log('');
console.log('Please manually add this configuration to your Claude Desktop config:');
console.log('');
console.log(JSON.stringify({ mcpServers: { agentbtc: getDefaultMcpConfig() } }, null, 2));
process.exit(1);
}
// Show what was added
console.log('');
console.log('Configuration added:');
console.log(JSON.stringify(claudeConfig.mcpServers.agentbtc, null, 2));
console.log('');
console.log('๐ Next steps:');
console.log('1. Restart Claude Desktop');
console.log('2. Update Lightning node settings if needed:');
console.log(` - Edit: ${claudeConfigPath}`);
console.log(' - Set correct AGENTBTC_LND_HOST and AGENTBTC_LND_MACAROON');
console.log('3. Test the connection: agentbtc-mcp test');
console.log('4. Try Bitcoin payments in Claude: "Pay 100 sats for market data"');
console.log('');
console.log('๐ Ready to use Bitcoin payments in Claude Desktop!');
}
main();