From 460899c54db67a4cbceb18e5041bc98df44b2a31 Mon Sep 17 00:00:00 2001 From: jbishop_ai Date: Fri, 13 Feb 2026 16:09:36 -0600 Subject: [PATCH] Fix: Format thread_ts parameter to ensure Slack API compatibility The slack_reply_to_thread tool was not properly formatting thread_ts parameters that lacked decimal points. Slack expects timestamps in the format '1234567890.123456' (with 6 digits after the period), but the tool was passing through unformatted timestamps, causing messages to appear as new top-level messages instead of thread replies. This fix: - Adds a formatThreadTs() helper method to ensure proper formatting - Applies formatting to both postReply() and getThreadReplies() methods - Handles timestamps with or without decimal points - Maintains backward compatibility with properly formatted timestamps The bug was particularly evident in DM channels where raw curl calls with properly formatted thread_ts worked, but the MCP tool failed. --- index.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index 4687151..cdf201f 100644 --- a/index.ts +++ b/index.ts @@ -60,6 +60,21 @@ export class SlackClient { }; } + /** + * Format thread_ts to ensure it has the decimal point in the correct position + * Slack expects format like "1234567890.123456" (timestamp with period before last 6 digits) + */ + private formatThreadTs(thread_ts: string): string { + if (!thread_ts.includes('.')) { + // If no period, add it so that 6 digits come after it + if (thread_ts.length >= 7) { + const insertPosition = thread_ts.length - 6; + return thread_ts.slice(0, insertPosition) + '.' + thread_ts.slice(insertPosition); + } + } + return thread_ts; + } + async getChannels(limit: number = 100, cursor?: string): Promise { const predefinedChannelIds = process.env.SLACK_CHANNEL_IDS; if (!predefinedChannelIds) { @@ -131,7 +146,7 @@ export class SlackClient { headers: this.botHeaders, body: JSON.stringify({ channel: channel_id, - thread_ts: thread_ts, + thread_ts: this.formatThreadTs(thread_ts), text: text, }), }); @@ -177,7 +192,7 @@ export class SlackClient { async getThreadReplies(channel_id: string, thread_ts: string): Promise { const params = new URLSearchParams({ channel: channel_id, - ts: thread_ts, + ts: this.formatThreadTs(thread_ts), }); const response = await fetch(