Refactor agent-filtered tool registration - #12237
Conversation
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The refactor preserves mode-specific behavior while removing duplication and adding focused regression coverage.
Pull request overview
Centralizes agent-policy filtering and SDK tool registration shared by routed and unified MCP modes.
Changes:
- Adds
registerFilteredToolsfor consistent filtering, handler resolution, and metadata mapping. - Replaces duplicated registration loops with mode-specific adapters.
- Adds regression coverage for allowed, denied, and missing-handler tools.
File summaries
| File | Description |
|---|---|
internal/server/tool_registry_helpers.go |
Adds shared filtered registration helper. |
internal/server/routed.go |
Adapts routed tool identities and handlers. |
internal/server/agent_policy_enforce.go |
Adapts unified prefixed tools to the helper. |
internal/server/agent_policy_visibility_test.go |
Tests filtering and missing-handler behavior. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
🔒 mcpg Read-Only Stress — default AWFSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No writes leaked. Independent evidence for gateway DIFC write checks is covered by References:
|
🔒 mcpg Read-Only Stress — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No writes leaked. The INCONCLUSIVE result reflects methodology gaps, not enforcement failures. References: §33409351296
|
Routed and unified MCP servers independently implemented near-identical agent-policy filtering and SDK tool registration. This centralizes the shared behavior while retaining each mode’s tool naming and handler wiring.
Shared registration
registerFilteredToolsto apply policy checks, skip unresolved handlers, and mapToolInfometadata tosdk.Toolconsistently.Mode-specific adapters