#!/bin/sh # One-line setup of the tacito-mcp MCP server (https://tacito.hu/mcp-szerver; tools/tacito-mcp): # # curl -fsSL https://tacito.hu/mcp-szerver/install.sh | sh # # It asks for the TACITo API key and the mode, installs the npm package `tacito-mcp` into ~/.tacito-mcp, and adds # the server "tacito" to every MCP client it finds: Claude Code and Codex through their own `mcp add` command, # Claude Desktop and Cursor by merging one entry into their JSON settings file (the previous file is kept next to # it as .tacito-backup). macOS and Linux. TACITO_API_KEY and TACITO_MCP_MODE in the environment skip the # questions. Run it again to change the key or the mode, or to update the package. # # The clients start ~/.tacito-mcp/tacito-mcp, a launcher with full paths, and not `npx tacito-mcp`: npx looks first # in the folder the client was opened in, so a copy planted in a project would run with the key. The key and the # mode are in ~/.tacito-mcp/env (mode 0600) only: never on a command line and not in the clients' settings. # # Everything is inside main(), called on the last line, so a download that was cut short runs nothing. Child # commands read /dev/null, never the rest of this script, and their output is discarded. set -eu PAGE='https://tacito.hu/mcp-szerver' # Sets mcpServers.tacito in the JSON settings file in argv[1] to the launcher (TACITO_LAUNCHER) and keeps everything # else. Exit 3: the file is not a JSON object (left untouched). A link that points nowhere fails (left untouched). MERGE_JS=' const fs = require("fs"); const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value); const shown = process.argv[1]; let file = shown; let settings = {}; let mode = 0o600; if (fs.lstatSync(shown, { throwIfNoEntry: false })) { file = fs.realpathSync(shown); // a symlinked settings file stays a link: its target is rewritten const text = fs.readFileSync(file, "utf8"); try { settings = text.trim() ? JSON.parse(text) : {}; } catch { process.exit(3); } if (!isObject(settings) || (settings.mcpServers !== undefined && !isObject(settings.mcpServers))) process.exit(3); mode = fs.statSync(file).mode & 0o777; // The backup: private from its first byte, and without the key a hand-made "tacito" entry held (the key now // lives in one file only). Whatever is at that name is removed first, never written through. const old = settings.mcpServers?.tacito?.env?.TACITO_API_KEY; fs.rmSync(shown + ".tacito-backup", { force: true }); fs.writeFileSync(shown + ".tacito-backup", typeof old === "string" && old ? text.split(old).join("tacit_...") : text, { mode: 0o600, flag: "wx" }); fs.chmodSync(shown + ".tacito-backup", 0o600); } settings.mcpServers = { ...settings.mcpServers, tacito: { command: process.env.TACITO_LAUNCHER } }; const next = file + ".tacito-new-" + process.pid; fs.writeFileSync(next, JSON.stringify(settings, null, 2) + "\n", { mode, flag: "wx" }); fs.chmodSync(next, mode); // the mode the file had, whatever the umask fs.renameSync(next, file); ' key='' mode='' added='' failed='' saved_tty='' dir='' fail() { printf 'Hiba: %s\n' "$*" >&2; exit 1; } has_tty() { (: /dev/null; } note_added() { added="${added:+$added, }$1"; printf ' %s: beállítva%s\n' "$1" "${2:+ ($2)}"; } note_failed() { failed="${failed:+$failed, }$1"; printf ' %s: %s\n' "$1" "$2" >&2; } # $1 = client name, $2 = its JSON settings file merge_settings() { backup='' [ -e "$2" ] && backup="az előző változat: $2.tacito-backup" status=0 TACITO_LAUNCHER="$dir/tacito-mcp" node -e "$MERGE_JS" "$2" /dev/null 2>&1 || status=$? case $status in 0) note_added "$1" "$backup" ;; 3) note_failed "$1" "a beállításfájl nem érvényes JSON, ezért nem módosítottam: $2" ;; *) note_failed "$1" "nem sikerült a beállításfájlt írni: $2" ;; esac } # The package, the key file and the launcher in $dir. Nothing of it is taken from the folder this was started in. install_server() { umask 077 mkdir -p "$dir" chmod 700 "$dir" # Run inside $dir, so an .npmrc of the current folder is not read; --ignore-scripts: nothing of a package runs here. (cd "$dir" && npm install --prefix "$dir" --ignore-scripts --no-audit --no-fund --loglevel=error \ "${TACITO_MCP_PACKAGE:-tacito-mcp@latest}" /dev/null 2>&1) || fail "Nem sikerült telepíteni a tacito-mcp csomagot (npm install) ide: $dir. Ellenőrizd az internetkapcsolatot, majd futtasd újra." [ -f "$dir/node_modules/tacito-mcp/dist/index.js" ] || fail "A telepített csomag hiányos: $dir" # New files of this run only, so the umask above makes them private before the key is written. rm -f "$dir/env.new.$$" "$dir/tacito-mcp.new.$$" printf 'TACITO_API_KEY=%s\nTACITO_MCP_MODE=%s\n' "$key" "$mode" >"$dir/env.new.$$" mv -f "$dir/env.new.$$" "$dir/env" { printf '#!/bin/sh\n' printf '# Written by %s/install.sh. Starts the tacito-mcp server with the key and the mode in ./env.\n' "$PAGE" # The client's environment may come from the folder it was opened in. These would load a file from there # (NODE_OPTIONS, NODE_PATH), send the key to another host (TACITO_BASE_URL) or accept a forged certificate # (NODE_TLS_REJECT_UNAUTHORIZED, NODE_EXTRA_CA_CERTS). Cleared before ./env is read, so a value set there holds. printf 'set -eu\nunset NODE_OPTIONS NODE_PATH TACITO_BASE_URL NODE_TLS_REJECT_UNAUTHORIZED NODE_EXTRA_CA_CERTS\n' printf 'set -a\n. "%s/env"\nset +a\n' "$dir" printf 'exec "%s" "%s/node_modules/tacito-mcp/dist/index.js"\n' "$(command -v node)" "$dir" } >"$dir/tacito-mcp.new.$$" chmod 700 "$dir/tacito-mcp.new.$$" mv -f "$dir/tacito-mcp.new.$$" "$dir/tacito-mcp" } main() { if ! command -v node >/dev/null 2>&1 || ! command -v npm >/dev/null 2>&1 || ! node -e 'process.exit(Number(process.versions.node.split(".")[0]) >= 18 ? 0 : 1)' /dev/null' EXIT trap 'exit 130' INT TERM stty -echo /dev/tty IFS= read -r key /dev/tty if [ -z "$mode" ]; then printf 'Mód (read: csak olvas | draft: piszkozatot is készít | full: számlát is kiállít) [draft]: ' >/dev/tty IFS= read -r mode /dev/null 2>&1 && ! command -v codex >/dev/null 2>&1 && [ ! -d "$desktop" ] && [ ! -d "$HOME/.cursor" ]; then fail "Nem találtam MCP-klienst ezen a gépen (Claude Code, Codex, Claude Desktop, Cursor). Kézi beállítás: $PAGE" fi install_server claude_code='' if command -v claude >/dev/null 2>&1; then # A second `add` is refused while the name exists, and the default scope is the current folder only. claude mcp remove tacito --scope user /dev/null 2>&1 || true if claude mcp add tacito --scope user -- "$dir/tacito-mcp" /dev/null 2>&1; then note_added 'Claude Code' claude_code=1 else note_failed 'Claude Code' "a \"claude mcp add\" parancs nem sikerült. Ha volt korábbi \"tacito\" bejegyzés, azt a szkript már törölte; kézzel így adhatod hozzá: claude mcp add tacito --scope user -- \"$dir/tacito-mcp\"" fi fi if command -v codex >/dev/null 2>&1; then if codex mcp add tacito -- "$dir/tacito-mcp" /dev/null 2>&1; then note_added 'Codex' else note_failed 'Codex' 'a "codex mcp add" parancs nem sikerült' fi fi if [ -d "$desktop" ]; then merge_settings 'Claude Desktop' "$desktop/claude_desktop_config.json"; fi if [ -d "$HOME/.cursor" ]; then merge_settings 'Cursor' "$HOME/.cursor/mcp.json"; fi if [ -n "$added" ]; then printf 'Kész: a "tacito" szerver %s módban van beállítva (%s). Indítsd újra a klienst, hogy betöltse.\n' "$mode" "$added" printf 'A szerver és a kulcs helye: %s. Frissítés, más kulcs vagy más mód: futtasd újra ezt a parancsot.\n' "$dir" if [ -n "$claude_code" ]; then printf 'Claude Code: ha egy projektmappában korábban külön is hozzáadtad a "tacito" szervert, abban a mappában az marad érvényben. Ott így törölheted: claude mcp remove tacito --scope local\n' fi if [ "$mode" = full ]; then printf 'Figyelem: full módban az asszisztens számlát is kiállíthat. A kiállított számla nem törölhető.\n' fi fi if [ -n "$failed" ]; then fail "Nem sikerült: $failed. Kézi beállítás: $PAGE" fi } main "$@"