8000 feat(server): add support for restricting sources and tools via env vars by AlexTalreja · Pull Request #4409 · googleapis/mcp-toolbox · GitHub
[go: up one dir, main page]

Skip to content

feat(server): add support for restricting sources and tools via env vars - #4409

Draft
AlexTalreja wants to merge 3 commits into
mainfrom
restrict-sources-and-tools
Draft

AlexTalreja wants to merge 3 commits into
mainfrom
restrict-sources-and-tools

Conversation

@AlexTalreja
Copy link
Copy Markdown
Contributor

Description

Adds two opt-in environment variables that limit which source and tool types Toolbox will load:

  • TOOLBOX_ALLOWED_SOURCES: comma-separated allowlist of source types
  • TOOLBOX_DISALLOWED_TOOLS: comma-separated denylist of tool types

The check runs in InitializeConfigs() before any source opens a connection. If the config uses a disallowed type, Toolbox fails to start with one error that lists every violation. Because the check is in InitializeConfigs(), it covers startup, --prebuilt, hot reload and invoke. When neither variable is set, nothing is restricted.

@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces configuration restrictions based on environment variables (TOOLBOX_ALLOWED_SOURCES and TOOLBOX_DISALLOWED_TOOLS) to validate source and tool types before any connections are initialized. It includes a new restrictions.go file, comprehensive unit tests in restrictions_test.go, and integrates the validation check into InitializeConfigs in server.go. The feedback recommends normalizing parsed types to lowercase to ensure case-insensitive matching, along with updating the corresponding test cases to verify this behavior.

Comment thread internal/server/restrictions.go Resolved
Comment thread internal/server/restrictions_test.go Resolved
Comment thread internal/server/restrictions_test.go Resolved
@AlexTalreja
AlexTalreja force-pushed the restrict-sources-and-tools branch from 7dca979 to 53856a2 Compare November 4, 2026 20:49
@AlexTalreja
AlexTalreja force-pushed the restrict-sources-and-tools branch 3 times, most recently from fea3dac to f512730 Compare November 5, 2026 21:29
@AlexTalreja
AlexTalreja force-pushed the restrict-sources-and-tools branch from f512730 to 1c78faa Compare November 5, 2026 22:24

This branch has not been deployed

No deployments
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.

1 participant

0