Repository navigation
Deduplicate routed and delegated tool handler dispatch - #17011
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE ( No write leaked on any surface. Parts A and C (reads) both passed cleanly.)
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the handler-dispatch consolidation.
No open issues 🎉
What changed in this PR
Centralizes handler dispatch for routed and delegated filtered tool views in MCP Gateway, addressing the duplication identified in #16980 while preserving existing behavior.
Changes:
- Extracts
unifiedHandlerForand uses it in both filtered-view builders. - Preserves log messages, missing-handler handling, argument forwarding, and returned results and errors.
- Adds regression tests for both dispatch labels, success/error forwarding, missing and nil handlers, and backend isolation.
| File | Description |
|---|---|
| internal/server/tool_registry_helpers.go | Adds the shared handler resolver and wrapper. |
| internal/server/tool_registry_helpers_test.go | Tests dispatch behavior, logging, and handler lookup edge cases. |
| internal/server/routed.go | Replaces the routed dispatch closure with the shared helper. |
| internal/server/agent_policy_enforce.go | Replaces the delegated dispatch closure with the shared helper. |
Review effort: Balanced (adaptive)
Routed and delegated filtered tool views duplicated handler lookup and wrapping, differing only in dispatch log text.
unifiedHandlerFor, centralizing missing-handler handling and call-through behavior.