Repository navigation
Centralize tool-name prefix handling - #16949
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 writes leaked. No reaction/star/issue/comment/branch/file/PR was created.
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the refactor centralizing backend-prefixed name handling in shared helpers.
No open issues 🎉
What changed in this PR
Centralizes backend-prefixed name handling in shared utility helpers, addressing the duplication described in #16904 across server registration, lookup, policy checks, and middleware.
Changes:
- Exports
ToolNameSeparatorand adds helpers to build names and strip one exact server prefix. - Replaces duplicated prefix handling while preserving embedded separators, unmatched names, and middleware’s
sys___recognition. - Adds regression coverage for prefix edge cases and handler lookup.
| File | Description |
|---|---|
internal/util/format_tool.go |
Defines shared separator and prefix helpers. |
internal/util/format_test.go |
Tests prefix construction, stripping, and edge cases. |
internal/server/unified_test.go |
Tests embedded prefixes and unmatched names. |
internal/server/unified_lifecycle.go |
Uses helpers for backend tool listing and handler lookup. |
internal/server/tool_registry.go |
Uses helpers for tool, prompt, and system-tool registration. |
internal/server/tool_name_test.go |
Extends name-preservation and handler tests. |
internal/server/routed.go |
Uses the shared builder in missing-handler logs. |
internal/server/agent_policy_enforce.go |
Uses helpers for policy identity and logging. |
internal/middleware/jqschema.go |
Uses the shared builder to recognize system tools. |
internal/middleware/jqschema_test.go |
Covers system-prefix recognition edge cases. |
Review effort: Balanced (adaptive)
Server and middleware code duplicate the
___separator for building, stripping, and recognizing prefixed names.util.ToolNameSeparator; addPrefixToolNameandStripToolPrefix.sys___recognition.