Add action interceptor for config-driven MCP routing#9
Merged
Conversation
Replace SwapTxBuilder with a generic ActionRouter that intercepts actions based on ACTION_ROUTES env var (e.g. search_token:mcp). Revert build_tx to build_swap_tx as app-only action, remove server-side swap endpoint and MCP swap adapter. Extract shared processActions/processSuggestions/storeAction helpers to deduplicate buildLoopResponse and emitLoopResponse. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Sends an mcp_status action to the app so the UI can show what MCP is doing in the background (e.g. "Processing search_token via server"). Co-Authored-By: Claude Opus 4.6 <[email protected]>
RaghavSood
approved these changes
Feb 25, 2026
Claude sometimes emits sign_tx alongside build_send_tx/build_swap_tx in the same response, bypassing the confirmation flow. Add a server-side guardrail in processActions to drop sign_tx when a build action is present. Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Add AppTool type and resolveTools/cacheToolContext for app-declared tool manifest with Redis caching - Add BuildActionsTable and BuildRespondToUserTool to generate prompt and schema from app-declared tools - Add buildAgentTools to use dynamic enum when tools are provided - Add isMCPTool helper for MCP status SSE emission - Add MCP client init retry loop (10 attempts, 3s interval) - Remove auto_execute from ToolAction, Action, prompt, and schema - Rename mcpTool variable to route in interceptor Co-Authored-By: Claude Opus 4.6 <[email protected]>
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
SwapTxBuilderwith a genericActionRouterthat intercepts actions based onACTION_ROUTESenv var (e.g.search_token:mcp)build_txtobuild_swap_txas app-only action; remove server-side swap endpoint (/conversations/:id/tx/build) and MCP swap adapterprocessActions/processSuggestions/storeActionhelpers to deduplicatebuildLoopResponseandemitLoopResponseACTION_ROUTESconfig field — comma-separatedaction_type:targetpairs (default empty = all actions to app)search_token:mcpis supported initially; adding more routes is config-onlyTest plan
go build ./...passesgo test ./...passesgo vet ./...passesACTION_ROUTES=search_token:mcp→ search_token actions intercepted by MCPfind_token, tokens in response🤖 Generated with Claude Code