Skip to content

Conversation

@cameronehrlich
Copy link

Summary

This PR adds a new conversations_unread tool that lets users quickly check which channels and DMs have unread messages.

The Problem

I wanted to use Claude Code to check if I had any unread Slack messages before diving into work. The existing MCP server has great tools for reading conversations and sending messages, but no way to see which conversations need attention.

What I Tried

My first attempt used the conversations.info API to get unread counts for each channel individually. This worked but was way too slow - it made N API calls (one per channel), which caused timeouts when you have hundreds of channels.

The Solution

I discovered the client.counts edge API that's already used elsewhere in this codebase. It returns unread status for all channels in a single API call. Much faster!

Trade-off: The client.counts API only returns HasUnreads: true/false, not the actual unread count. So the tool reports UnreadCount: 1 for any channel with unreads. If exact counts are needed, that would require the slower per-channel approach.

Changes

  • pkg/provider/api.go: Added ClientCounts method to the SlackAPI interface and MCPSlackClient
  • pkg/handler/conversations.go: Added ConversationsUnreadHandler and UnreadChannel struct
  • pkg/server/server.go: Registered the new conversations_unread tool

Usage

conversations_unread(channel_types: "im,mpim,public_channel,private_channel")

Returns CSV with columns: ChannelID, ChannelName, UnreadCount, Purpose

The channel_types parameter is optional and defaults to all types.

Testing

  • ✅ Tested locally with a user OAuth token (xoxp)
  • ✅ Verified it returns results quickly (single API call)
  • ✅ Verified empty response when no unreads (just CSV headers)
  • ✅ Verified channel type filtering works correctly

Screenshots

Example response when no unreads:

ChannelID,ChannelName,UnreadCount,Purpose

Example response with unreads:

ChannelID,ChannelName,UnreadCount,Purpose
D1234567890,@john.doe,1,DM with John Doe
C9876543210,#general,1,Company-wide announcements

Adds a new MCP tool `conversations_unread` that returns a list of channels
and DMs with unread messages. Uses the efficient `client.counts` edge API
to fetch all unread status in a single API call.

Changes:
- Add ClientCounts method to SlackAPI interface and MCPSlackClient
- Add ConversationsUnreadHandler in conversations.go
- Register conversations_unread tool in server.go
- Add UnreadChannel struct for response formatting

The tool accepts an optional `channel_types` parameter to filter by
im, mpim, public_channel, or private_channel (defaults to all).

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@cameronehrlich cameronehrlich marked this pull request as ready for review January 26, 2026 21:21
@korotovsky
Copy link
Owner

Hi @cameronehrlich, thank you for the PR, however it collides with almost finalized PR by @saoudrizwan. His PR covers much more cases and was nearly done on the review. I'd appreciate if you could join the conversation there, then we could move things a little faster.

@korotovsky korotovsky added the duplicate This issue or pull request already exists label Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants