Repository navigation
fix(mcp): enforce SystemUtils enabled_tools allow-list - #597
Open
rohanbuilds-ai wants to merge 1 commit into
Open
rohanbuilds-ai wants to merge 1 commit into
rohanbuilds-ai wants to merge 1 commit into
Conversation
SystemUtils MCP server accepted an enabled_tools configuration setting defined in DEFAULT_CONFIG, but create_systemutils_server statically decorated all 8 tool functions with @mcp.tool. Consequently, all tools (including administrative and arbitrary script execution tools) were exposed and callable even when administrators or challenge setups restricted enabled_tools. - Conditionally register tools with FastMCP only when their name appears in enabled_tools. - Gracefully fall back to defaults when enabled_tools is None or non-iterable. - Ensure disabled tools are excluded from list_tools() and reject calls with ToolError. - Add comprehensive test suite in tests/unit/mcp/test_systemutils_server.py.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enforces the configured
enabled_toolsallow-list on the SystemUtils MCP server so that only explicitly permitted tools are registered with FastMCP and exposed to agents.Problem & Reproduction
In
finbot/mcp/servers/systemutils/server.py,DEFAULT_CONFIGdefines an"enabled_tools"allow-list containing 8 tools:When
create_systemutils_serveris invoked, it merges the server configuration:However, every tool function was statically and unconditionally decorated with
@mcp.tool. Theenabled_toolsconfiguration was never referenced or checked.Reproduction
Security Impact
/api/v1/admin/mcp/servers/systemutils) and challenge configs to restrict server capabilities. Becauseenabled_toolswas ignored, administrative tools (manage_users) and arbitrary script execution tools (execute_script) remained active and exposed to LLM agents even when restricted.Solution
finbot/mcp/servers/systemutils/server.py:enabled_setfromconfig.get("enabled_tools")._tooldecorator that only registers a function with@mcp.toolif its__name__is present inenabled_set.enabled_toolsisNoneor non-iterable, fall back toDEFAULT_CONFIG["enabled_tools"]; bare strings are coerced to single-item lists.tests/unit/mcp/test_systemutils_server.py:{}enabling all 8 tools.enabled_toolsisNoneor non-iterable.enabled_tools=[]exposing 0 tools.fastmcp.exceptions.ToolError: Unknown tool._apply_tool_overrides).Verification Results
uv run pytest tests/unit/mcp/test_systemutils_server.py -v: 14 passed in 0.80s.uv run pytest tests/unit/mcp/ tests/unit/labs/ -q: 89 passed in 10.36s.uv run isort --check-only finbot/mcp/servers/systemutils/server.py tests/unit/mcp/test_systemutils_server.py: Clean.uv run black --check finbot/mcp/servers/systemutils/server.py tests/unit/mcp/test_systemutils_server.py: Clean.git diff --check: Clean (0 whitespace errors).