Repository navigation
Conversation
The MCP bridge (Claude CLI subprocess) was not propagating local_key or session_key to tool calls. When agents running on Claude CLI created team tasks from forum topics, the routing metadata was empty — causing announce messages to land in #general instead of the originating topic. Root cause: BridgeContext only carried channel, chatID, and peerKind. The local_key (composite key with topic suffix) and session_key were available in RunRequest but never wired through the CLI provider → MCP config headers → bridge middleware → tool context chain. Changes: - Add OptLocalKey constant and pass req.LocalKey through provider opts - Add LocalKey field to BridgeContext struct - Send X-Local-Key and X-Session-Key as bridge headers - Extract both in bridgeContextMiddleware, inject via WithToolLocalKey and WithToolSessionKey - Include localKey and sessionKey in HMAC signature (variadic extra fields) with backward-compatible fallback for pre-existing sessions - Use reg.ExecuteWithContext in bridge_server.go to pass routing context from the HTTP request context to tool execution Fixes forum topic routing for all tools called through the MCP bridge.
6 tasks done
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.
Fixes #798
Problem
MCP bridge (Claude CLI subprocess) did not propagate
local_keyorsession_keyto tool calls. Tasks created from forum topics had empty routing metadata — announce messages landed in #general instead of the originating topic.Root Cause
BridgeContextonly carried channel, chatID, and peerKind. Thelocal_key(composite key with topic suffix) andsession_keywere available inRunRequestbut never wired through the propagation chain:RunRequest.LocalKey → opts → BridgeContext → headers → middleware → ctx → toolChanges
OptLocalKeyconstant, passreq.LocalKeythrough provider optsLocalKeytoBridgeContext, send asX-Local-KeyheaderX-Session-Keyheader from existing session keybridgeContextMiddleware, inject viaWithToolLocalKey/WithToolSessionKeyextra ...string) with backward-compat fallbackreg.ExecuteWithContextinbridge_server.goto pass routing context to toolsFiles Changed
internal/providers/claude_cli.go—OptLocalKeyconstantinternal/agent/loop_pipeline_callbacks.go— pass local_key to optsinternal/providers/claude_cli_mcp.go— BridgeContext, headers, HMACinternal/providers/claude_cli_session.go— extract from optsinternal/gateway/server.go— middleware extraction + context injectioninternal/mcp/bridge_server.go— ExecuteWithContext