Enable sending DM to user I have not chatted before#253
Open
jhutar wants to merge 7 commits intokorotovsky:masterfrom
Open
Enable sending DM to user I have not chatted before#253jhutar wants to merge 7 commits intokorotovsky:masterfrom
jhutar wants to merge 7 commits intokorotovsky:masterfrom
Conversation
On large workspaces (41K+ users), the server blocks for ~90 seconds during startup while fetching all users/channels from the Slack API, exceeding MCP client connection timeouts. Changes: - Load expired cache files immediately, mark server ready, then refresh in background via goroutine (stale-while-revalidate pattern) - Convert usersReady/channelsReady to atomic.Bool for race-free reads - Add refreshingUsers/refreshingChannels atomic.Bool to coalesce concurrent background refreshes via CompareAndSwap - Remove stdio IsReady() polling loop (no longer needed) - Increase default cache TTL from 1h to 24h - Document SLACK_MCP_CACHE_TTL and SLACK_MCP_MIN_REFRESH_INTERVAL env vars in docs/03-configuration-and-usage.md Fixes startup timeout on large workspaces. Server now starts in under 1 second regardless of workspace size when a cache file exists. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Restore IsReady() polling loop before ServeStdio() to fix cold-start regression where tool calls fail for 60-90s on first run (no cache) - Add fetchUsersMu/fetchChannelsMu mutexes to serialize fetchAndStore* calls, preventing race between ForceRefresh and background refresh - Use atomic file writes (temp + os.Rename) to prevent corrupt cache files on crash - Guard against empty API results overwriting valid cache - Guard against empty cache files being treated as valid data - Fix typo: TestRefreshingFlagPreventsConucrrentRefreshes → Concurrent Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix infinite loop on cold start when API returns zero results: return error instead of nil when no existing cache is available, so the watcher calls Fatal rather than spinning IsReady() forever - Secure temp file handling: use os.CreateTemp for unpredictable names (prevents symlink attacks) and clean up temp files on any failure - Restrict cache file permissions from 0644 to 0600 and cache directory from 0755 to 0700 (cache contains user PII) - Extract atomicWriteFile helper to deduplicate temp+rename pattern - Fix stale docstring: getCacheTTL default is 24h not 1h Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The stdio transport blocks on IsReady() which requires both the users and channels caches to be fully populated before serving. On large workspaces (200k+ members like Kubernetes Slack), the user cache takes several seconds to load, causing MCP clients with tight startup timeouts to fail the connection. This brings stdio in line with the SSE and HTTP transports, which already serve immediately while caches warm in the background. Tools that depend on the user cache gracefully degrade (showing user IDs instead of display names) until the cache is ready. Signed-off-by: Mark Liu <mark@prove.com.au>
# Conflicts: # pkg/provider/api.go
# Conflicts: # cmd/slack-mcp-server/main.go
Generated-by: Gemini
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.
For my use-case, I created this fork with 2 applied PRs and one new commit by Gemini.
This PR includes rebased changes from PRs #225 and #249 to improve cache warm-up if server is configured with
stdiotransport. Then because I needed to be able to send DM to user I have not chatted before (as discussed in issue #221), added implementation ofconversations_opentool.Mine config:
And Gemini CLI is configured with:
With all the fixes, when I rebuild the container with
podman build -f Dockerfile . -t ghcr.io/korotovsky/slack-mcp-server:latestI was able to send a DM to a user I nave not talked to before.