@thxmxx/telegram-mcp 1.3.0 → 1.3.2

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 (3) hide show
  1. package/README.md +21 -0
  2. package/package.json +1 -1
  3. package/src/setup.js +40 -58
package/README.md CHANGED
@@ -93,6 +93,27 @@ Re-runs the setup with the latest version — updates the MCP server and the `/u
93
93
 
94
94
  On first use, Claude Code will ask you to approve the three tools this MCP server registers (`telegram_notify`, `telegram_ask`, `telegram_choose`). This is standard Claude Code behaviour — you can review exactly what is being granted before accepting.
95
95
 
96
+
97
+ ## Always-on per project
98
+
99
+ To activate Telegram automatically every time you open Claude Code in a project, add to your `CLAUDE.md`:
100
+
101
+ ```markdown
102
+ ## Communication
103
+
104
+ Always use /use-telegram in this session.
105
+ ```
106
+
107
+ **Per project** — inside the repo (can be committed and shared with the team):
108
+ ```
109
+ /your-project/CLAUDE.md
110
+ ```
111
+
112
+ **Global** — applies to every project on your machine:
113
+ ```
114
+ ~/.claude/CLAUDE.md
115
+ ```
116
+
96
117
  ## Security
97
118
 
98
119
  - The MCP server only accepts responses from your configured Telegram user ID
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thxmxx/telegram-mcp",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
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,21 +17,17 @@ 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) => {
31
- console.error(`\x1b[31m✘${RESET} ${msg}`);
32
- rl.close();
33
- exit(1);
34
- };
29
+ const ok = (msg) => console.log(`${GREEN}✔${RESET} ${msg}`);
30
+ const die = (msg) => { console.error(`\x1b[31m✘${RESET} ${msg}`); rl.close(); exit(1); };
35
31
 
36
32
  // ── Pre-flight ────────────────────────────────────────────────────────────────
37
33
 
@@ -42,9 +38,7 @@ if (major < 18) die(`Node.js 18+ required (you have ${process.versions.node})`);
42
38
  ok(`Node.js ${process.versions.node}`);
43
39
 
44
40
  try {
45
- const ver = execFileSync("claude", ["--version"], {
46
- encoding: "utf8",
47
- }).trim();
41
+ const ver = execFileSync("claude", ["--version"], { encoding: "utf8" }).trim();
48
42
  ok(`Claude Code: ${ver}`);
49
43
  } catch {
50
44
  die("`claude` not found. Install: https://docs.claude.ai/claude-code");
@@ -76,52 +70,43 @@ console.log(`\n${BOLD}Registering MCP server globally…${RESET}`);
76
70
 
77
71
  const serverPath = new URL("./index.js", import.meta.url).pathname;
78
72
 
73
+ // Remove existing registration first so token updates take effect
79
74
  try {
80
- execFileSync(
81
- "claude",
82
- [
83
- "mcp",
84
- "add",
85
- "--scope",
86
- "user", // global, persists across all projects
87
- "telegram-mcp",
88
- "-e",
89
- `TELEGRAM_BOT_TOKEN=${token}`,
90
- "-e",
91
- `TELEGRAM_CHAT_ID=${chatId}`,
92
- "--",
93
- "node",
94
- serverPath,
95
- ],
96
- { stdio: "inherit" },
97
- );
75
+ execFileSync("claude", ["mcp", "remove", "telegram-mcp", "--scope", "user"], { stdio: "ignore" });
76
+ } catch {
77
+ try {
78
+ execFileSync("claude", ["mcp", "remove", "telegram-mcp"], { stdio: "ignore" });
79
+ } catch {
80
+ // Not registered yet — that's fine
81
+ }
82
+ }
83
+
84
+ 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" });
98
92
  } catch {
99
93
  // Fallback: older Claude Code versions without --scope flag
100
94
  try {
101
- execFileSync(
102
- "claude",
103
- [
104
- "mcp",
105
- "add",
106
- "telegram-mcp",
107
- "-e",
108
- `TELEGRAM_BOT_TOKEN=${token}`,
109
- "-e",
110
- `TELEGRAM_CHAT_ID=${chatId}`,
111
- "--",
112
- "node",
113
- serverPath,
114
- ],
115
- { stdio: "inherit" },
116
- );
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" });
117
102
  } catch {
118
103
  die(
119
104
  "`claude mcp add` failed.\n" +
120
- " Update Claude Code: https://docs.claude.ai/claude-code\n\n" +
121
- " Manual config:\n" +
122
- ` TELEGRAM_BOT_TOKEN=${token}\n` +
123
- ` TELEGRAM_CHAT_ID=${chatId}\n` +
124
- ` command: node ${serverPath}`,
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}`
125
110
  );
126
111
  }
127
112
  }
@@ -134,9 +119,7 @@ const commandsDir = join(homedir(), ".claude", "commands");
134
119
  mkdirSync(commandsDir, { recursive: true });
135
120
 
136
121
  const commandPath = join(commandsDir, "use-telegram.md");
137
- writeFileSync(
138
- commandPath,
139
- `# use-telegram
122
+ writeFileSync(commandPath, `# use-telegram
140
123
 
141
124
  Activate Telegram integration for this Claude Code session.
142
125
 
@@ -182,8 +165,7 @@ After completing any task, ALWAYS call telegram_listen (no arguments).
182
165
  - This keeps the session alive indefinitely until timeout (1 hour of inactivity)
183
166
 
184
167
  Never exit or stop after a task — always loop back to telegram_listen.
185
- `,
186
- );
168
+ `);
187
169
 
188
170
  ok(`Slash command installed → ${commandPath}`);
189
171
 
@@ -207,4 +189,4 @@ ${GREEN}${BOLD}All done!${RESET}
207
189
 
208
190
  Each session auto-identifies itself as ${BOLD}[folder#id]${RESET} in Telegram.
209
191
  ${DIM}No need to run init again unless you change your bot token.${RESET}
210
- `);
192
+ `);