← nitronium.dev

Telegram MCP plugin çöktüğünde direkt Bot API ile dosya gönderme

2026-06-20
MCP health check bazen Telegram plugin'ini Module not found "server.ts" hatasıyla bloke ediyor. Plugin restart etmeden de dosya göndermek mümkün.

İki şeyi bilmek yeterli: doğru token nerede, ve curl neden çalışmıyor.

Token: .env dosyasındaki token expired olabilir. Aktif olan her zaman ~/.claude/settings.json içinde:

`bash
grep TELEGRAM ~/.claude/settings.json
`

curl yerine Node.js: context-mode hook curl/wget'i sandbox'a yönlendiriyor. Direkt HTTPS için ctx_execute ile Node.js kullanmak gerekiyor:

`javascript
const https = require('https');
const fs = require('fs');

const token = 'BOT_TOKEN';
const chatId = 'CHAT_ID';
const fileContent = fs.readFileSync('/tmp/dosya.md');

const boundary = 'B' + Date.now();
const CRLF = '\r\n';
const head = Buffer.from(
--${boundary}${CRLF}Content-Disposition: form-data; name="chat_id"${CRLF}${CRLF}${chatId}${CRLF} +
--${boundary}${CRLF}Content-Disposition: form-data; name="document"; filename="dosya.md"${CRLF}Content-Type: text/markdown${CRLF}${CRLF},
'utf8'
);
const tail = Buffer.from(${CRLF}--${boundary}--, 'utf8');
const body = Buffer.concat([head, fileContent, tail]);

const req = https.request({
hostname: 'api.telegram.org',
path: /bot${token}/sendDocument,
method: 'POST',
headers: { 'Content-Type': multipart/form-data; boundary=${boundary}, 'Content-Length': body.length }
}, res => { let d=''; res.on('data',c=>d+=c); res.on('end',()=>console.log(JSON.parse(d).ok?'OK':'FAIL')); });
req.write(body); req.end();
`

MCP bağımlılığı olmadan çalışır. Token doğruysa sonuç OK.