@thxmxx/telegram-mcp 1.0.0 → 1.2.0

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.
@@ -0,0 +1,68 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ types: [closed]
8
+ branches: [main]
9
+
10
+ jobs:
11
+ publish:
12
+ if: github.event_name == 'push' || github.event.pull_request.merged == true
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ contents: write # needed to push the version bump commit
16
+ id-token: write
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ with:
21
+ token: ${{ secrets.GITHUB_TOKEN }}
22
+ fetch-depth: 0
23
+
24
+ - uses: actions/setup-node@v4
25
+ with:
26
+ node-version: 20
27
+ registry-url: https://registry.npmjs.org
28
+
29
+ - name: Install dependencies
30
+ run: npm install
31
+
32
+ - name: Determine version bump
33
+ id: bump
34
+ run: |
35
+ # Get the commit message that triggered this run
36
+ if [ "${{ github.event_name }}" = "pull_request" ]; then
37
+ MSG="${{ github.event.pull_request.title }}"
38
+ else
39
+ MSG="$(git log -1 --pretty=%s)"
40
+ fi
41
+
42
+ echo "Commit message: $MSG"
43
+
44
+ # Detect breaking change
45
+ if echo "$MSG" | grep -qiE "BREAKING CHANGE|!:"; then
46
+ echo "type=major" >> $GITHUB_OUTPUT
47
+ # feat → minor
48
+ elif echo "$MSG" | grep -qiE "^feat(\(.+\))?:"; then
49
+ echo "type=minor" >> $GITHUB_OUTPUT
50
+ # everything else → patch
51
+ else
52
+ echo "type=patch" >> $GITHUB_OUTPUT
53
+ fi
54
+
55
+ - name: Bump version
56
+ run: |
57
+ git config user.name "github-actions[bot]"
58
+ git config user.email "github-actions[bot]@users.noreply.github.com"
59
+ npm version ${{ steps.bump.outputs.type }} --no-git-tag-version
60
+ VERSION=$(node -p "require('./package.json').version")
61
+ git add package.json
62
+ git commit -m "chore: bump version to $VERSION [skip ci]"
63
+ git push
64
+
65
+ - name: Publish
66
+ run: npm publish --access public --provenance
67
+ env:
68
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/README.md CHANGED
@@ -12,7 +12,15 @@ The wizard asks for your Telegram bot token and user ID, registers the MCP serve
12
12
 
13
13
  ## Usage
14
14
 
15
- In any Claude Code session, activate Telegram with the slash command:
15
+ Start Claude Code without permission prompts so it can work autonomously:
16
+
17
+ ```bash
18
+ claude --dangerously-skip-permissions
19
+ ```
20
+
21
+ > ⚠️ This flag disables all tool confirmation prompts — file writes, shell commands, everything. Use only on your own machine for personal workflows.
22
+
23
+ Then activate Telegram in any session:
16
24
 
17
25
  ```
18
26
  /use-telegram
@@ -85,4 +93,4 @@ On first use, Claude Code will ask you to approve the three tools this MCP serve
85
93
 
86
94
  ## License
87
95
 
88
- MIT
96
+ MIT
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@thxmxx/telegram-mcp",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Telegram bridge for Claude Code — notify, ask and choose via your phone",
5
5
  "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/thxmxx/telegram-mcp"
9
+ },
6
10
  "bin": {
7
11
  "telegram-mcp": "./src/cli.js"
8
12
  },
@@ -11,6 +15,8 @@
11
15
  "node-telegram-bot-api": "^0.66.0",
12
16
  "dotenv": "^16.0.0"
13
17
  },
14
- "engines": { "node": ">=18" },
18
+ "engines": {
19
+ "node": ">=18"
20
+ },
15
21
  "license": "MIT"
16
22
  }
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");
@@ -71,31 +77,51 @@ console.log(`\n${BOLD}Registering MCP server globally…${RESET}`);
71
77
  const serverPath = new URL("./index.js", import.meta.url).pathname;
72
78
 
73
79
  try {
74
- execFileSync("claude", [
75
- "mcp", "add", "--scope", "user", // global, persists across all projects
76
- "telegram-mcp",
77
- "-e", `TELEGRAM_BOT_TOKEN=${token}`,
78
- "-e", `TELEGRAM_CHAT_ID=${chatId}`,
79
- "--", "node", serverPath,
80
- ], { stdio: "inherit" });
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
+ );
81
98
  } catch {
82
99
  // Fallback: older Claude Code versions without --scope flag
83
100
  try {
84
- execFileSync("claude", [
85
- "mcp", "add",
86
- "telegram-mcp",
87
- "-e", `TELEGRAM_BOT_TOKEN=${token}`,
88
- "-e", `TELEGRAM_CHAT_ID=${chatId}`,
89
- "--", "node", serverPath,
90
- ], { stdio: "inherit" });
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
+ );
91
117
  } catch {
92
118
  die(
93
119
  "`claude mcp add` failed.\n" +
94
- " Update Claude Code: https://docs.claude.ai/claude-code\n\n" +
95
- " Manual config:\n" +
96
- ` TELEGRAM_BOT_TOKEN=${token}\n` +
97
- ` TELEGRAM_CHAT_ID=${chatId}\n` +
98
- ` command: node ${serverPath}`
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}`,
99
125
  );
100
126
  }
101
127
  }
@@ -108,17 +134,19 @@ const commandsDir = join(homedir(), ".claude", "commands");
108
134
  mkdirSync(commandsDir, { recursive: true });
109
135
 
110
136
  const commandPath = join(commandsDir, "use-telegram.md");
111
- writeFileSync(commandPath, `# use-telegram
137
+ writeFileSync(
138
+ commandPath,
139
+ `# use-telegram
112
140
 
113
141
  Activate Telegram integration for this Claude Code session.
114
142
 
115
143
  ## What this does
116
144
 
117
- Enables the telegram_notify, telegram_ask and telegram_choose tools so you
118
- can be notified and asked questions on your phone while Claude works.
145
+ Enables telegram_notify, telegram_ask and telegram_choose so the user
146
+ receives updates and can respond from their phone or terminal.
119
147
 
120
- The instance name is derived automatically from the current folder and
121
- session ID, so messages on Telegram always show which session is talking.
148
+ This session runs with --dangerously-skip-permissions so Claude never
149
+ interrupts the task to ask for tool confirmations in the terminal.
122
150
 
123
151
  ## Modes
124
152
 
@@ -127,21 +155,24 @@ session ID, so messages on Telegram always show which session is talking.
127
155
 
128
156
  ## Behaviour
129
157
 
130
- When this command is active:
131
- - Use telegram_notify for progress updates and completed tasks
132
- - Use telegram_ask when you need a free-form answer from the user
133
- - Use telegram_choose when the user must pick from known options
134
- - Always prefix messages with the auto-generated instance label
135
- - Mirror every question to the terminal too whoever answers first wins
136
- - After any long-running task, send a completion summary via telegram_notify
158
+ You MUST use the Telegram tools for this session. Specifically:
159
+
160
+ - Call telegram_notify **immediately** to confirm Telegram is active
161
+ - Call telegram_notify for every meaningful progress update
162
+ - Call telegram_notify when any task is fully complete, with a summary
163
+ - Call telegram_ask whenever you need a free-form answer from the user
164
+ - Call telegram_choose whenever the user must pick from known options
165
+ - Do NOT ask questions in the terminal — always use telegram_ask or telegram_choose
137
166
 
138
167
  ## Instance naming
139
168
 
140
- Generate the instance label as: \`{folder-name}#{short-session-id}\`
141
- Example: \`backend#a3f2\`, \`frontend#9c11\`
169
+ At the start of this session, generate a label: \`{folder-name}#{4-char-random-hex}\`
170
+ Examples: \`backend#a3f2\`, \`frontend#9c11\`
142
171
 
143
- Use the same label for the entire session.
144
- `);
172
+ Use this exact label in every Telegram message for the entire session.
173
+ Send as first message: \`[label] ✅ Telegram active — ready.\`
174
+ `,
175
+ );
145
176
 
146
177
  ok(`Slash command installed → ${commandPath}`);
147
178
 
@@ -150,7 +181,11 @@ ok(`Slash command installed → ${commandPath}`);
150
181
  console.log(`
151
182
  ${GREEN}${BOLD}All done!${RESET}
152
183
 
153
- Restart Claude Code. From now on, in any session:
184
+ Start Claude Code with:
185
+
186
+ ${BOLD}claude --dangerously-skip-permissions${RESET}
187
+
188
+ Then activate Telegram in any session:
154
189
 
155
190
  ${BOLD}/use-telegram${RESET} full mode (notify + ask + choose)
156
191
  ${BOLD}/use-telegram notify${RESET} notifications only