Fix: Format thread_ts parameter for proper Slack API thread replies#7
Open
antonber wants to merge 1 commit intozencoderai:mainfrom
Open
Fix: Format thread_ts parameter for proper Slack API thread replies#7antonber wants to merge 1 commit intozencoderai:mainfrom
antonber wants to merge 1 commit intozencoderai:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
slack_reply_to_threadtool was posting messages as new top-level messages instead of actual thread replies, particularly in DM channels. The root cause was that thethread_tsparameter wasn't being properly formatted before being sent to Slack'schat.postMessageAPI.Root Cause
The tool description in the original codebase mentioned that timestamps could be provided without a decimal point and "can be converted by adding the period such that 6 numbers come after it," but the code never actually implemented this conversion. Slack expects timestamps in the format
1234567890.123456(with exactly 6 digits after the decimal point), but unformatted timestamps like1234567890123456were being passed directly to the API, causing Slack to ignore thethread_tsparameter and post as top-level messages instead.Solution
This PR adds proper
thread_tsformatting:formatThreadTs()- validates and formats timestamps to ensure they have the decimal point in the correct positionpostReply()andgetThreadReplies()to use the formatterTesting
While we cannot run live tests without a Slack workspace in CI, the fix addresses the documented behavior and aligns with Slack's API requirements. Testing confirmed that raw
curlcalls with properly formattedthread_tswork perfectly, validating that the issue was in the parameter formatting, not the API call structure.Changes
formatThreadTs()private method toSlackClientclasspostReply()to formatthread_tsbefore sending to Slack APIgetThreadReplies()to formatthread_tsbefore querying threadsImpact
This fix ensures that existing users can reliably use thread replies in all channel types, including DMs, which was previously broken when timestamps were provided without proper formatting.