fix: non-blocking stdio startup and --no-cache flag#277
Open
mustafa89 wants to merge 1 commit intokorotovsky:masterfrom
Open
fix: non-blocking stdio startup and --no-cache flag#277mustafa89 wants to merge 1 commit intokorotovsky:masterfrom
mustafa89 wants to merge 1 commit intokorotovsky:masterfrom
Conversation
Remove the busy-wait loop that blocks the stdio transport from responding to MCP initialize until users/channels caches are fully loaded. On large workspaces this causes MCP clients with connection timeouts (e.g. 30-60s) to drop the server. Changes: - stdio transport now starts the MCP server immediately, matching the existing SSE/HTTP behavior. Caches continue loading in a background goroutine. Tool calls made before caches are ready return a graceful "not ready" error (already handled by the error recovery middleware). - Add --no-cache CLI flag to skip cache loading entirely for environments that only use channel/user IDs (never #name or @name lookups). This makes startup instant regardless of workspace size. - Add SkipCache() method on ApiProvider that marks both caches as ready without loading data. Fixes korotovsky#271
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.
Summary
Fixes #271 — the stdio transport blocks the MCP
initializeresponse until users/channels caches are fully loaded. On large workspaces (12k+ users, 43k+ channels) this takes 3-5 minutes, causing MCP clients with connection timeouts to drop the server.Changes
1. Non-blocking stdio startup (default behavior change)
Removed the busy-wait loop in
main.gothat blocked stdio from starting untilIsReady()returned true:This matches the existing SSE/HTTP behavior, which already starts serving before caches are ready. Tool calls made before caches load return a graceful "not ready" error via the existing
buildErrorRecoveryMiddleware, allowing the LLM to retry.2.
--no-cacheCLI flag (opt-in)For environments that only use channel/user IDs (never
#channel-nameor@usernamelookups), the--no-cacheflag skips cache loading entirely:This marks both
usersReadyandchannelsReadyas true immediately via a newSkipCache()method onApiProvider, without loading any data. Startup is instant regardless of workspace size.Files changed
cmd/slack-mcp-server/main.go--no-cacheflag, remove stdio busy-wait loop, add warm-up log messagepkg/provider/api.goSkipCache()methodTesting
Tested on a workspace with 823 users and 1,418 channels:
--no-cache