Skip to content

Conversation

@niebloomj
Copy link

Summary

Adds fallback implementation for conversations_unreads tool that works with xoxp and xoxb tokens.

⚠️ Stacked PR

This PR is stacked on top of #171 and includes those commits. It should be reviewed after #171 is merged, or reviewed with the understanding that it builds upon that PR's functionality.

Problem

The current implementation of conversations_unreads (from #171) uses the ClientCounts API, which only works with browser session tokens (xoxc/xoxd). When used with OAuth tokens (xoxp/xoxb), it executes without error but returns empty results.

Solution

This PR adds an automatic fallback that:

  1. Attempts to use ClientCounts first (fast path for xoxc/xoxd)
  2. Detects when ClientCounts returns empty results
  3. Falls back to iterating through channels using conversations.info to check unread_count on each channel

This approach was validated in a Python implementation before porting to Go.

Implementation Details

  • New method: getUnreadsUsingConversationsInfo implements the per-channel approach
  • Auto-detection: Checks if ClientCounts returns zero channels and switches to fallback
  • API addition: Added GetConversationInfoContext to SlackAPI interface
  • Logging: Info message logged when using fallback method
  • Compatibility: Maintains same output format and filtering options as original

Limitations with xoxp/xoxb tokens

  • The mentions_only filter is not supported (no access to mention counts via conversations.info)
    • A warning is logged if mentions_only is requested
  • lastRead and latest timestamps are not available via conversations.info (returned as empty strings)
  • Slower than ClientCounts approach as it requires one API call per channel

Testing

  • ✅ Code compiles successfully
  • ✅ Based on working Python implementation using the same approach

Related

🤖 Generated with Claude Code

saoudrizwan and others added 8 commits February 10, 2026 18:58
…rieval

- Uses ClientUserBoot to get all channels with LastRead/Latest in one API call
- Filters channels where Latest > LastRead to find unreads
- Prioritizes: DMs > group DMs > partner channels (ext-*) > internal
- Only fetches message history for channels with actual unreads
- Supports filtering by channel type and configurable limits

Addresses issue korotovsky#114
- Switch from ClientUserBoot to ClientCounts API
- ClientCounts returns HasUnreads boolean for all channels
- Add ClientCounts to SlackAPI interface
- Process Channels, MPIMs, and IMs separately
- Strip existing # prefix before adding to avoid ##name
- Use stripped name for ext-/shared- prefix checks for partner type
- Add mentions_only parameter to conversations_unreads to filter
  channels to only those with @mentions (priority inbox)
- Add conversations_mark tool to mark channels/DMs as read
  - Supports channel IDs, #channel names, and @username
  - If no timestamp provided, marks all messages as read
…nels

- Add IsExtShared field to Channel struct in cache
- Pass IsExtShared through mapChannel function
- Use cached.IsExtShared to identify external/partner channels
  instead of checking for ext-/shared- name prefixes

Note: Users may need to delete their channels cache file to repopulate
with the new IsExtShared field.
- Extract handler params to structs with parsing functions
  (unreadsParams, markParams) following existing patterns
- Add SLACK_MCP_MARK_TOOL env var guard for conversations_mark
  (disabled by default, requires explicit opt-in)
- Remove unused categorizeChannel and getChannelDisplayName functions
- Update README with conversations_mark safety note and env var docs
Adds fallback implementation for conversations_unreads tool that works
with xoxp and xoxb tokens by iterating through channels and using
conversations.info to check unread_count.

The ClientCounts API (used in the original implementation) only works
with browser session tokens (xoxc/xoxd) and returns empty results for
OAuth tokens (xoxp/xoxb). This change detects when ClientCounts returns
empty results and automatically falls back to the per-channel approach.

Implementation details:
- Added GetConversationInfoContext to SlackAPI interface
- New helper method getUnreadsUsingConversationsInfo implements xoxp approach
- Automatically detects empty ClientCounts response and switches to fallback
- Logs info message when using fallback method
- Maintains same output format and filtering options as original
- Note: mentions_only filter not supported with xoxp (logged as warning)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@niebloomj
Copy link
Author

Approach was merged into #171 so I am closing this

@niebloomj niebloomj closed this Feb 11, 2026
@niebloomj niebloomj deleted the feat-xoxp-unread-support branch February 11, 2026 01:58
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.

2 participants