Skip to content

[Repo Assist] feat: enforce ServerConfig.Tools as an allow-list at registration time#2234

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/enforce-tools-allowlist-registration-87036b41559389cb
Draft

[Repo Assist] feat: enforce ServerConfig.Tools as an allow-list at registration time#2234
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/enforce-tools-allowlist-registration-87036b41559389cb

Conversation

@github-actions
Copy link
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

The tools field in server configuration was parsed and stored but never applied — all backend tools were always exposed regardless of configuration. This has been documented as a known limitation in docs/CONFIGURATION.md.

This PR implements the allow-list enforcement so the tools field works as documented.

Root cause

registerToolsFromBackend fetched tools from the backend and registered all of them without consulting serverCfg.Tools.

Fix

After unmarshalling the tools/list response, check whether the server config has a non-empty Tools allow-list. If so, filter the tool slice in-place before the registration loop, keeping only the listed tools.

if serverCfg, ok := us.cfg.Servers[serverID]; ok && serverCfg != nil && len(serverCfg.Tools) > 0 {
    allowedTools := make(map[string]struct{}, len(serverCfg.Tools))
    for _, name := range serverCfg.Tools {
        allowedTools[name] = struct{}{}
    }
    originalCount := len(listResult.Tools)
    filtered := listResult.Tools[:0]
    for _, tool := range listResult.Tools {
        if _, allowed := allowedTools[tool.Name]; allowed {
            filtered = append(filtered, tool)
        }
    }
    listResult.Tools = filtered
    // log skipped count...
}

When Tools is empty/nil (the default), all backend tools are exposed — existing behaviour is preserved.

Changes

  • internal/server/unified.go — allow-list filtering added to registerToolsFromBackend
  • internal/server/register_tools_from_backend_test.go — two new tests: ToolsAllowList (non-empty allow-list filters correctly) and EmptyToolsAllowList (empty list exposes all tools)
  • docs/CONFIGURATION.md — updated tools field description to reflect enforcement

Trade-offs

  • The filter is applied at registration time (startup), so changes to the config require a gateway restart.
  • Tools not in the allow-list are silently skipped; a log message records how many were filtered.

Test Status

Build and tests require Go 1.25.0, which is unavailable in the sandbox environment (Go 1.24.13 is present but the go.mod requires ≥ 1.25.0 and the Go toolchain download is blocked by the network firewall). This is an infrastructure limitation — the CI pipeline (which has Go 1.25) should run the tests normally.

The logic change is minimal and localised to a single conditional block inserted before the existing registration loop.

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@851905c06e905bf362a9f6cc54f912e3df747d55

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

…mBackend

When a server config specifies a non-empty Tools list, only those named
tools are registered with the MCP SDK; all other backend tools are
silently filtered at registration time.

Previously the Tools field was parsed and stored but never applied —
all backend tools were always exposed regardless of configuration (noted
in docs/CONFIGURATION.md as a known limitation).

Changes:
- internal/server/unified.go: apply allow-list filter after parsing
  tools/list response; log how many tools were filtered out
- internal/server/register_tools_from_backend_test.go: add two new
  tests (ToolsAllowList and EmptyToolsAllowList) covering the new
  behaviour and the default pass-through case
- docs/CONFIGURATION.md: update tools field description to reflect
  that it is now enforced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants