Repository navigation
Extract shared allowlist filtering for tools and prompts - #17012
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 through either surface. Part B is INCONCLUSIVE because the backend GitHub MCP server runs with
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the shared allowlist-filtering change.
No open issues 🎉
What changed in this PR
This PR removes duplicated allowlist filtering from MCP Gateway’s tool and prompt registration, addressing #16981 and aligning empty-set behavior.
Changes:
- Adds a generic in-place filter that preserves order, reuses the backing array, and returns the removal count.
- Uses the shared helper for tools and prompts while retaining caller-specific logging and treating empty per-server sets as unrestricted.
- Adds regression coverage for filtering semantics, ordering, duplicates, and pointer preservation.
| File | Description |
|---|---|
| internal/util/collections.go | Adds the shared FilterByAllowlist helper. |
| internal/util/collections_test.go | Tests filter edge cases and backing-array reuse. |
| internal/server/tool_registry.go | Integrates the helper and aligns empty-set handling. |
| internal/server/register_tools_from_backend_test.go | Adds tool-registration allowlist coverage. |
| internal/server/register_prompts_test.go | Expands prompt-registration allowlist coverage. |
Review effort: Balanced (adaptive)
Tool and prompt registration duplicated the same in-place allowlist filter but handled empty sets differently.
util.FilterByAllowlist, preserving item order and backing-array reuse while returning the removal count.