Skip to content

Support wildcard ["*"] in allowed-tools filtering#3445

Merged
lpcox merged 3 commits intomainfrom
copilot/support-wildcard-in-allowed-tools
Apr 9, 2026
Merged

Support wildcard ["*"] in allowed-tools filtering#3445
lpcox merged 3 commits intomainfrom
copilot/support-wildcard-in-allowed-tools

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

buildAllowedToolSets() treats every entry in the Tools list as a literal tool name. When the gh-aw compiler emits tools: ["*"], no tool matches the literal string "*", so all tools get filtered out.

Changes

  • internal/server/unified.go: buildAllowedToolSets now detects "*" anywhere in the tools list via a hasWildcard() helper. Wildcard servers are skipped (not added to the filter map), same as servers with no Tools config. Logs [allowed-tools] Wildcard "*" configured for <serverID>: allowing all tools when triggered.

  • Tests: Wildcard cases added to TestIsToolAllowed table, plus new TestBuildAllowedToolSets_WildcardStar, TestBuildAllowedToolSets_WildcardMixed, TestIsToolAllowed_Wildcard, and TestRegisterToolsFromBackend_WildcardAllowsAll.

// Before: ["*"] builds a set with literal "*" key — nothing matches
// After:
if hasWildcard(serverCfg.Tools) {
    logger.LogInfo("backend", "[allowed-tools] Wildcard \"*\" configured for %s: allowing all tools", serverID)
    continue
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: /tmp/go-build1981761529/b514/launcher.test /tmp/go-build1981761529/b514/launcher.test -test.testlogfile=/tmp/go-build1981761529/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s 9420�� 9420830/b336/_pkg_.a pkg/mod/github.com/tetratelabs/wazero@v1.11.0/in-ifaceassert x_amd64/vet --gdwarf-5 .io/otel/sdk/res-V=full -o x_amd64/vet (dns block)
  • invalid-host-that-does-not-exist-12345.com
    • Triggering command: /tmp/go-build1981761529/b496/config.test /tmp/go-build1981761529/b496/config.test -test.testlogfile=/tmp/go-build1981761529/b496/testlog.txt -test.paniconexit0 -test.timeout=10m0s -w PXs3z5Xin .cfg 64/pkg/tool/linux_amd64/vet -c .io/otel/attribu/tmp/go-build2334098856/b305/vet.cfg /tmp/go-build3709420830/b148/ 64/pkg/tool/linux_amd64/vet ache�� olang.org/grpc@v1.80.0/channelz/channelz.go .cfg 64/pkg/tool/linux_amd64/vet --gdwarf-5 --64 -o 64/pkg/tool/linux_amd64/vet (dns block)
  • nonexistent.local
    • Triggering command: /tmp/go-build1981761529/b514/launcher.test /tmp/go-build1981761529/b514/launcher.test -test.testlogfile=/tmp/go-build1981761529/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s 9420�� 9420830/b336/_pkg_.a pkg/mod/github.com/tetratelabs/wazero@v1.11.0/in-ifaceassert x_amd64/vet --gdwarf-5 .io/otel/sdk/res-V=full -o x_amd64/vet (dns block)
  • slow.example.com
    • Triggering command: /tmp/go-build1981761529/b514/launcher.test /tmp/go-build1981761529/b514/launcher.test -test.testlogfile=/tmp/go-build1981761529/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s 9420�� 9420830/b336/_pkg_.a pkg/mod/github.com/tetratelabs/wazero@v1.11.0/in-ifaceassert x_amd64/vet --gdwarf-5 .io/otel/sdk/res-V=full -o x_amd64/vet (dns block)
  • this-host-does-not-exist-12345.com
    • Triggering command: /tmp/go-build1981761529/b523/mcp.test /tmp/go-build1981761529/b523/mcp.test -test.testlogfile=/tmp/go-build1981761529/b523/testlog.txt -test.paniconexit0 -test.timeout=10m0s (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI linked an issue Apr 9, 2026 that may be closed by this pull request
5 tasks
Add wildcard detection in buildAllowedToolSets() so that if the Tools
list contains "*", the server is treated as having no restriction
(same as when Tools is empty/nil). This fixes the issue where the
compiler passes tools: ["*"] and the gateway filters out all tools.

- Add hasWildcard() helper to detect "*" anywhere in the tools list
- Log when wildcard is detected for a server
- Add unit tests for wildcard in buildAllowedToolSets, isToolAllowed
- Add integration test for registerToolsFromBackend with wildcard

Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/3811320c-55c9-44e8-bdf0-2af76abb5fc2

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix wildcard '*' handling in allowed-tools filtering Support wildcard ["*"] in allowed-tools filtering Apr 9, 2026
Copilot finished work on behalf of lpcox April 9, 2026 17:17
Copilot AI requested a review from lpcox April 9, 2026 17:17
@lpcox lpcox marked this pull request as ready for review April 9, 2026 17:17
Copilot AI review requested due to automatic review settings April 9, 2026 17:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for wildcard "*" in per-server allowed-tools filtering so configs emitted as tools: ["*"] correctly allow all tools instead of filtering everything out.

Changes:

  • Update buildAllowedToolSets() to detect "*" (anywhere in the list) and treat it as “allow all” by skipping filter-set creation (with an info log).
  • Add unit/integration test coverage for wildcard-only and mixed wildcard configurations.
Show a summary per file
File Description
internal/server/unified.go Implements wildcard detection for allowed-tools set building and logs when wildcard enables allow-all.
internal/server/call_backend_tool_test.go Extends TestIsToolAllowed table with wildcard cases.
internal/server/allowed_tools_integration_test.go Adds targeted tests ensuring wildcard configs allow all tools and don’t filter tool registration.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment on lines 379 to +392
// buildAllowedToolSets converts the per-server Tools lists from the config into pre-computed
// map[string]bool sets for O(1) lookup. Servers with no Tools list are not added to the map,
// which signals that all tools are permitted.
// which signals that all tools are permitted. A wildcard entry ["*"] is treated the same as
// an empty list (all tools allowed).
func buildAllowedToolSets(cfg *config.Config) map[string]map[string]bool {
sets := make(map[string]map[string]bool)
if cfg == nil {
return sets
}
for serverID, serverCfg := range cfg.Servers {
if len(serverCfg.Tools) > 0 {
// Treat ["*"] as "allow all" — skip adding to the filter map
if hasWildcard(serverCfg.Tools) {
logger.LogInfo("backend", "[allowed-tools] Wildcard \"*\" configured for %s: allowing all tools", serverID)
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc/comment text says only a wildcard entry ["*"] is treated as allow-all, but the implementation treats "*" anywhere in the Tools list as allow-all (see hasWildcard(serverCfg.Tools) and the mixed-list tests). Please update the docstring and inline comment to reflect the actual semantics (e.g., "if the Tools list contains '*' anywhere").

Copilot uses AI. Check for mistakes.
Update docstring and inline comment to reflect that "*" anywhere in
the Tools list (not just as the sole entry) triggers allow-all behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox lpcox merged commit 24416ef into main Apr 9, 2026
14 checks passed
@lpcox lpcox deleted the copilot/support-wildcard-in-allowed-tools branch April 9, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support wildcard ["*"] in allowed-tools filtering

3 participants