#!/usr/bin/env bash # LiveTable MCPをClaude Desktop / Claude Codeに登録するインストーラ set -u # Node.jsが無い場合、既知のパッケージマネージャがあれば自動インストールを試みる # (失敗しても案内表示にフォールバックする。強制インストールはしない)。 ensure_node() { if command -v node >/dev/null 2>&1; then return 0 fi echo "Node.js was not found — attempting to install it automatically." if command -v brew >/dev/null 2>&1; then brew install node elif command -v apt-get >/dev/null 2>&1; then sudo apt-get update && sudo apt-get install -y nodejs npm fi if command -v node >/dev/null 2>&1; then return 0 fi echo "Could not install Node.js automatically. Install the LTS from https://nodejs.org and run this again." return 1 } if ensure_node; then node - <<'LIVETABLE_MCP_EOF' const fs = require("fs"); const os = require("os"); const path = require("path"); function configPath(dirName) { if (process.platform === "win32") return path.join(process.env.LOCALAPPDATA || path.join(os.homedir(), "AppData", "Local"), dirName, "claude_desktop_config.json"); if (process.platform === "darwin") return path.join(os.homedir(), "Library", "Application Support", dirName, "claude_desktop_config.json"); return path.join(os.homedir(), ".config", dirName, "claude_desktop_config.json"); } let anyOk = false; for (const dirName of ["Claude","Claude-3p"]) { const p = configPath(dirName); let config = {}; if (fs.existsSync(p)) { try { config = JSON.parse(fs.readFileSync(p, "utf8")); } catch (e) { console.log("Could not read the existing Claude Desktop config file at " + p + ". Skipped this file without changing it to avoid overwriting it."); continue; } } config.mcpServers = config.mcpServers || {}; config.mcpServers["livetable"] = { command: "npx", args: [ "-y", "mcp-remote@0.8.6", "https://livetable-95ae7ddea565.herokuapp.com/api/mcp", "--static-oauth-client-info", JSON.stringify({ client_id: "06e2d141576e50dea33b396b72cb84b2" }), "--static-oauth-client-metadata", JSON.stringify({ scope: "openid email offline_access" }) ] }; fs.mkdirSync(path.dirname(p), { recursive: true }); fs.writeFileSync(p, JSON.stringify(config, null, 2)); console.log("[OK] Claude Desktop (" + dirName + "): registered LiveTable MCP."); console.log("File modified: " + p); anyOk = true; } if (!anyOk) process.exit(1); LIVETABLE_MCP_EOF fi if command -v claude >/dev/null 2>&1; then claude mcp remove livetable -s user >/dev/null 2>&1 if claude mcp add livetable --transport http --scope user --client-id 06e2d141576e50dea33b396b72cb84b2 https://livetable-95ae7ddea565.herokuapp.com/api/mcp; then echo "[OK] Claude Code: registered LiveTable MCP." else echo "[FAILED] Claude Code: could not register LiveTable MCP (see the error above)." fi else echo "Claude Code CLI ('claude') was not found. Skipped Claude Code setup — install Claude Code and rerun this script to add it there too." fi