@thxmxx/telegram-mcp 1.3.2 → 1.3.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/setup.js +67 -32
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thxmxx/telegram-mcp",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Telegram bridge for Claude Code — notify, ask and choose via your phone",
5
5
  "type": "module",
6
6
  "repository": {
package/src/setup.js CHANGED
@@ -17,17 +17,21 @@ import { mkdirSync, writeFileSync, existsSync } from "node:fs";
17
17
  import { join } from "node:path";
18
18
  import { homedir } from "node:os";
19
19
 
20
- const rl = createInterface({ input, output });
20
+ const rl = createInterface({ input, output });
21
21
  const ask = (q) => rl.question(q);
22
22
 
23
- const BOLD = "\x1b[1m";
23
+ const BOLD = "\x1b[1m";
24
24
  const GREEN = "\x1b[32m";
25
- const CYAN = "\x1b[36m";
26
- const DIM = "\x1b[2m";
25
+ const CYAN = "\x1b[36m";
26
+ const DIM = "\x1b[2m";
27
27
  const RESET = "\x1b[0m";
28
28
 
29
- const ok = (msg) => console.log(`${GREEN}✔${RESET} ${msg}`);
30
- const die = (msg) => { console.error(`\x1b[31m✘${RESET} ${msg}`); rl.close(); exit(1); };
29
+ const ok = (msg) => console.log(`${GREEN}✔${RESET} ${msg}`);
30
+ const die = (msg) => {
31
+ console.error(`\x1b[31m✘${RESET} ${msg}`);
32
+ rl.close();
33
+ exit(1);
34
+ };
31
35
 
32
36
  // ── Pre-flight ────────────────────────────────────────────────────────────────
33
37
 
@@ -38,7 +42,9 @@ if (major < 18) die(`Node.js 18+ required (you have ${process.versions.node})`);
38
42
  ok(`Node.js ${process.versions.node}`);
39
43
 
40
44
  try {
41
- const ver = execFileSync("claude", ["--version"], { encoding: "utf8" }).trim();
45
+ const ver = execFileSync("claude", ["--version"], {
46
+ encoding: "utf8",
47
+ }).trim();
42
48
  ok(`Claude Code: ${ver}`);
43
49
  } catch {
44
50
  die("`claude` not found. Install: https://docs.claude.ai/claude-code");
@@ -72,41 +78,65 @@ const serverPath = new URL("./index.js", import.meta.url).pathname;
72
78
 
73
79
  // Remove existing registration first so token updates take effect
74
80
  try {
75
- execFileSync("claude", ["mcp", "remove", "telegram-mcp", "--scope", "user"], { stdio: "ignore" });
81
+ execFileSync("claude", ["mcp", "remove", "telegram-mcp", "--scope", "user"], {
82
+ stdio: "ignore",
83
+ });
76
84
  } catch {
77
85
  try {
78
- execFileSync("claude", ["mcp", "remove", "telegram-mcp"], { stdio: "ignore" });
86
+ execFileSync("claude", ["mcp", "remove", "telegram-mcp"], {
87
+ stdio: "ignore",
88
+ });
79
89
  } catch {
80
90
  // Not registered yet — that's fine
81
91
  }
82
92
  }
83
93
 
84
94
  try {
85
- execFileSync("claude", [
86
- "mcp", "add", "--scope", "user",
87
- "telegram-mcp",
88
- "-e", `TELEGRAM_BOT_TOKEN=${token}`,
89
- "-e", `TELEGRAM_CHAT_ID=${chatId}`,
90
- "--", "node", serverPath,
91
- ], { stdio: "inherit" });
95
+ execFileSync(
96
+ "claude",
97
+ [
98
+ "mcp",
99
+ "add",
100
+ "--scope",
101
+ "user",
102
+ "telegram-mcp",
103
+ "-e",
104
+ `TELEGRAM_BOT_TOKEN=${token}`,
105
+ "-e",
106
+ `TELEGRAM_CHAT_ID=${chatId}`,
107
+ "--",
108
+ "node",
109
+ serverPath,
110
+ ],
111
+ { stdio: "inherit" },
112
+ );
92
113
  } catch {
93
114
  // Fallback: older Claude Code versions without --scope flag
94
115
  try {
95
- execFileSync("claude", [
96
- "mcp", "add",
97
- "telegram-mcp",
98
- "-e", `TELEGRAM_BOT_TOKEN=${token}`,
99
- "-e", `TELEGRAM_CHAT_ID=${chatId}`,
100
- "--", "node", serverPath,
101
- ], { stdio: "inherit" });
116
+ execFileSync(
117
+ "claude",
118
+ [
119
+ "mcp",
120
+ "add",
121
+ "telegram-mcp",
122
+ "-e",
123
+ `TELEGRAM_BOT_TOKEN=${token}`,
124
+ "-e",
125
+ `TELEGRAM_CHAT_ID=${chatId}`,
126
+ "--",
127
+ "node",
128
+ serverPath,
129
+ ],
130
+ { stdio: "inherit" },
131
+ );
102
132
  } catch {
103
133
  die(
104
134
  "`claude mcp add` failed.\n" +
105
- " Update Claude Code: https://docs.claude.ai/claude-code\n\n" +
106
- " Manual config:\n" +
107
- ` TELEGRAM_BOT_TOKEN=${token}\n` +
108
- ` TELEGRAM_CHAT_ID=${chatId}\n` +
109
- ` command: node ${serverPath}`
135
+ " Update Claude Code: https://docs.claude.ai/claude-code\n\n" +
136
+ " Manual config:\n" +
137
+ ` TELEGRAM_BOT_TOKEN=${token}\n` +
138
+ ` TELEGRAM_CHAT_ID=${chatId}\n` +
139
+ ` command: node ${serverPath}`,
110
140
  );
111
141
  }
112
142
  }
@@ -119,7 +149,9 @@ const commandsDir = join(homedir(), ".claude", "commands");
119
149
  mkdirSync(commandsDir, { recursive: true });
120
150
 
121
151
  const commandPath = join(commandsDir, "use-telegram.md");
122
- writeFileSync(commandPath, `# use-telegram
152
+ writeFileSync(
153
+ commandPath,
154
+ `# use-telegram
123
155
 
124
156
  Activate Telegram integration for this Claude Code session.
125
157
 
@@ -165,7 +197,8 @@ After completing any task, ALWAYS call telegram_listen (no arguments).
165
197
  - This keeps the session alive indefinitely until timeout (1 hour of inactivity)
166
198
 
167
199
  Never exit or stop after a task — always loop back to telegram_listen.
168
- `);
200
+ `,
201
+ );
169
202
 
170
203
  ok(`Slash command installed → ${commandPath}`);
171
204
 
@@ -188,5 +221,7 @@ ${GREEN}${BOLD}All done!${RESET}
188
221
  ${DIM}"deploy to staging, ask me via telegram if anything is unclear"${RESET}
189
222
 
190
223
  Each session auto-identifies itself as ${BOLD}[folder#id]${RESET} in Telegram.
191
- ${DIM}No need to run init again unless you change your bot token.${RESET}
192
- `);
224
+
225
+ ${BOLD}⚠️ Restart Claude Code now${RESET} to apply the new credentials.
226
+ ${DIM}The MCP server only picks up token changes on restart.${RESET}
227
+ `);