summaryrefslogtreecommitdiff
path: root/external_plugins
diff options
context:
space:
mode:
authorKenneth Lien <kenneth@anthropic.com>2026-03-20 11:45:46 -0700
committerKenneth Lien <kenneth@anthropic.com>2026-03-20 11:45:46 -0700
commita7cb39c269de4c32436c02a0b46cec3dae7df79f (patch)
tree10d16881abce868c647b35c6c102565a77554930 /external_plugins
parent90accf6fd2008fe0ee9578ebc088740c3a754d58 (diff)
telegram: add MarkdownV2 parse_mode to reply/edit_messagekenneth/telegram-bot-commands
Diffstat (limited to 'external_plugins')
-rw-r--r--external_plugins/telegram/server.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/external_plugins/telegram/server.ts b/external_plugins/telegram/server.ts
index 8acd52a2..44d79456 100644
--- a/external_plugins/telegram/server.ts
+++ b/external_plugins/telegram/server.ts
@@ -372,6 +372,11 @@ mcp.setRequestHandler(ListToolsRequestSchema, async () => ({
items: { type: 'string' },
description: 'Absolute file paths to attach. Images send as photos (inline preview); other types as documents. Max 50MB each.',
},
+ format: {
+ type: 'string',
+ enum: ['text', 'markdownv2'],
+ description: "Rendering mode. 'markdownv2' enables Telegram formatting (bold, italic, code, links). Caller must escape special chars per MarkdownV2 rules. Default: 'text' (plain, no escaping needed).",
+ },
},
required: ['chat_id', 'text'],
},
@@ -398,6 +403,11 @@ mcp.setRequestHandler(ListToolsRequestSchema, async () => ({
chat_id: { type: 'string' },
message_id: { type: 'string' },
text: { type: 'string' },
+ format: {
+ type: 'string',
+ enum: ['text', 'markdownv2'],
+ description: "Rendering mode. 'markdownv2' enables Telegram formatting (bold, italic, code, links). Caller must escape special chars per MarkdownV2 rules. Default: 'text' (plain, no escaping needed).",
+ },
},
required: ['chat_id', 'message_id', 'text'],
},
@@ -414,6 +424,8 @@ mcp.setRequestHandler(CallToolRequestSchema, async req => {
const text = args.text as string
const reply_to = args.reply_to != null ? Number(args.reply_to) : undefined
const files = (args.files as string[] | undefined) ?? []
+ const format = (args.format as string | undefined) ?? 'text'
+ const parseMode = format === 'markdownv2' ? 'MarkdownV2' as const : undefined
assertAllowedChat(chat_id)
@@ -440,6 +452,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async req => {
(replyMode === 'all' || i === 0)
const sent = await bot.api.sendMessage(chat_id, chunks[i], {
...(shouldReplyTo ? { reply_parameters: { message_id: reply_to } } : {}),
+ ...(parseMode ? { parse_mode: parseMode } : {}),
})
sentIds.push(sent.message_id)
}
@@ -482,10 +495,13 @@ mcp.setRequestHandler(CallToolRequestSchema, async req => {
}
case 'edit_message': {
assertAllowedChat(args.chat_id as string)
+ const editFormat = (args.format as string | undefined) ?? 'text'
+ const editParseMode = editFormat === 'markdownv2' ? 'MarkdownV2' as const : undefined
const edited = await bot.api.editMessageText(
args.chat_id as string,
Number(args.message_id),
args.text as string,
+ ...(editParseMode ? [{ parse_mode: editParseMode }] : []),
)
const id = typeof edited === 'object' ? edited.message_id : args.message_id
return { content: [{ type: 'text', text: `edited (id: ${id})` }] }