Skip to content

Add workspace-wide Slack message search - #10

Merged
odfalik merged 3 commits into
mainfrom
oded/search-messages
Aug 25, 2026
Merged

odfalik merged 3 commits into
mainfrom
oded/search-messages

Conversation

@odfalik

@odfalik odfalik commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add a search_messages MCP tool backed by Slack's native search.messages endpoint (no recent-history scanning)
  • accept native Slack search syntax plus bounded result pages, sorting, and bounded threaded context
  • return UTC and Slack timestamps, human channel/DM labels, channel IDs, authors, message text, permalinks, and actionable get_thread arguments
  • keep bot-token writes/reactions and existing user-token read behavior unchanged; use a dedicated user-token-only search client
  • add focused search/auth/pagination/thread-context tests and make CI run the test suite on Python 3.10 and 3.12
  • replace stale Socket Mode docs with the current outbound-only architecture and exact OAuth setup

Slack API and authorization

Slack restricts search.messages to user OAuth tokens with the legacy user scope search:read. Bot xoxb tokens return not_allowed_token_type; user tokens without the scope return missing_scope. The tool surfaces actionable messages for both cases.

The currently configured SLACK_USER_TOKEN was checked against the real API and returns missing_scope with needed=search:read. No fallback or recent-history approximation is used.

One-time reauthorization

  1. Open https://api.slack.com/apps and select the Slack app.
  2. Open OAuth & Permissions.
  3. Under Scopes → User Token Scopes, add search:read.
  4. Click Reinstall to Workspace and approve the new permission.
  5. Copy the resulting User OAuth Token (xoxp-...), not the Bot User OAuth Token.
  6. Set SLACK_USER_TOKEN=xoxp-... in ~/.claude/channels/slack-channel/.env.
  7. Restart Claude Code or the MCP host so the server reloads credentials.

Validation

  • uv run --python 3.10 --extra dev python -m pytest -q — 19 passed
  • uv run --python 3.12 --extra dev python -m pytest -q — 19 passed
  • uv run --extra dev ruff check slack_channel/ tests/ — passed
  • uv build — passed
  • git diff --check — passed

@odfalik
odfalik force-pushed the oded/search-messages branch from a210f3a to 8dad872 Compare August 25, 2026 18:55
@odfalik
odfalik merged commit 328e498 into main Aug 25, 2026
4 checks passed
@odfalik
odfalik deleted the oded/search-messages branch August 25, 2026 19:05
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