Skip to content

Fix: Format thread_ts parameter for proper Slack API thread replies#7

Open
antonber wants to merge 1 commit intozencoderai:mainfrom
antonber:fix/slack-thread-ts-formatting
Open

Fix: Format thread_ts parameter for proper Slack API thread replies#7
antonber wants to merge 1 commit intozencoderai:mainfrom
antonber:fix/slack-thread-ts-formatting

Conversation

@antonber
Copy link

Problem

The slack_reply_to_thread tool was posting messages as new top-level messages instead of actual thread replies, particularly in DM channels. The root cause was that the thread_ts parameter wasn't being properly formatted before being sent to Slack's chat.postMessage API.

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 like 1234567890123456 were being passed directly to the API, causing Slack to ignore the thread_ts parameter and post as top-level messages instead.

Solution

This PR adds proper thread_ts formatting:

  1. New helper method: formatThreadTs() - validates and formats timestamps to ensure they have the decimal point in the correct position
  2. Applied to both methods: Updated postReply() and getThreadReplies() to use the formatter
  3. Backward compatible: Properly formatted timestamps pass through unchanged
  4. Automatic conversion: Timestamps without decimal points are automatically formatted correctly

Testing

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 curl calls with properly formatted thread_ts work perfectly, validating that the issue was in the parameter formatting, not the API call structure.

Changes

  • Added formatThreadTs() private method to SlackClient class
  • Updated postReply() to format thread_ts before sending to Slack API
  • Updated getThreadReplies() to format thread_ts before querying threads
  • Code compiles successfully with TypeScript

Impact

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant