@gonzih/cc-tg 0.2.19 → 0.2.20
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.
- package/dist/bot.d.ts +1 -0
- package/dist/bot.js +26 -2
- package/package.json +1 -1
package/dist/bot.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export declare class CcTgBot {
|
|
|
38
38
|
/** Kill cc-agent PIDs with SIGTERM. Returns the list of killed PIDs. */
|
|
39
39
|
private killCcAgent;
|
|
40
40
|
private handleReloadMcp;
|
|
41
|
+
private handleMcpStatus;
|
|
41
42
|
private handleMcpVersion;
|
|
42
43
|
private handleClearNpxCache;
|
|
43
44
|
private handleRestart;
|
package/dist/bot.js
CHANGED
|
@@ -20,6 +20,7 @@ const BOT_COMMANDS = [
|
|
|
20
20
|
{ command: "help", description: "Show all available commands" },
|
|
21
21
|
{ command: "cron", description: "Manage cron jobs — add/list/edit/remove/clear" },
|
|
22
22
|
{ command: "reload_mcp", description: "Restart the cc-agent MCP server process" },
|
|
23
|
+
{ command: "mcp_status", description: "Check MCP server connection status" },
|
|
23
24
|
{ command: "mcp_version", description: "Show cc-agent npm version and npx cache info" },
|
|
24
25
|
{ command: "clear_npx_cache", description: "Clear npx cache and restart MCP to pick up latest version" },
|
|
25
26
|
{ command: "restart", description: "Restart the bot process in-place" },
|
|
@@ -236,6 +237,11 @@ export class CcTgBot {
|
|
|
236
237
|
await this.handleReloadMcp(chatId);
|
|
237
238
|
return;
|
|
238
239
|
}
|
|
240
|
+
// /mcp_status — run `claude mcp list` and show connection status
|
|
241
|
+
if (text === "/mcp_status") {
|
|
242
|
+
await this.handleMcpStatus(chatId);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
239
245
|
// /mcp_version — show published npm version and cached npx entries
|
|
240
246
|
if (text === "/mcp_version") {
|
|
241
247
|
await this.handleMcpVersion(chatId);
|
|
@@ -841,12 +847,30 @@ export class CcTgBot {
|
|
|
841
847
|
return pids;
|
|
842
848
|
}
|
|
843
849
|
async handleReloadMcp(chatId) {
|
|
850
|
+
await this.bot.sendMessage(chatId, "Clearing npx cache and reloading MCP...");
|
|
851
|
+
try {
|
|
852
|
+
const home = process.env.HOME ?? "~";
|
|
853
|
+
execSync(`rm -rf "${home}/.npm/_npx/"`, { encoding: "utf8", shell: "/bin/sh" });
|
|
854
|
+
console.log("[mcp] cleared ~/.npm/_npx/");
|
|
855
|
+
}
|
|
856
|
+
catch (err) {
|
|
857
|
+
await this.bot.sendMessage(chatId, `Warning: failed to clear npx cache: ${err.message}`);
|
|
858
|
+
}
|
|
844
859
|
const pids = this.killCcAgent();
|
|
845
860
|
if (pids.length === 0) {
|
|
846
|
-
await this.bot.sendMessage(chatId, "No cc-agent process found
|
|
861
|
+
await this.bot.sendMessage(chatId, "NPX cache cleared. No cc-agent process found — MCP will start fresh on the next agent call.");
|
|
847
862
|
return;
|
|
848
863
|
}
|
|
849
|
-
await this.bot.sendMessage(chatId, `Sent SIGTERM to cc-agent (pid${pids.length > 1 ? "s" : ""}: ${pids.join(", ")}).\nMCP restarted. New process will load on next agent call.`);
|
|
864
|
+
await this.bot.sendMessage(chatId, `NPX cache cleared. Sent SIGTERM to cc-agent (pid${pids.length > 1 ? "s" : ""}: ${pids.join(", ")}).\nMCP restarted. New process will load on next agent call.`);
|
|
865
|
+
}
|
|
866
|
+
async handleMcpStatus(chatId) {
|
|
867
|
+
try {
|
|
868
|
+
const output = execSync("claude mcp list", { encoding: "utf8", shell: "/bin/sh" }).trim();
|
|
869
|
+
await this.bot.sendMessage(chatId, `MCP server status:\n\n${output || "(no output)"}`);
|
|
870
|
+
}
|
|
871
|
+
catch (err) {
|
|
872
|
+
await this.bot.sendMessage(chatId, `Failed to run claude mcp list: ${err.message}`);
|
|
873
|
+
}
|
|
850
874
|
}
|
|
851
875
|
async handleMcpVersion(chatId) {
|
|
852
876
|
let npmVersion = "unknown";
|