fix(mcp): Apply parameters override in _apply_tool_overrides - #549
prince-shakyaa wants to merge 2 commits into
Conversation
parameters override in _apply_tool_overrides
parameters override in _apply_tool_overridesparameters override in _apply_tool_overrides
parameters override in _apply_tool_overridesparameters override in _apply_tool_overrides
|
This PR resolves #547 where parameter schema overrides stored via the Dark Lab supply-chain API were being silently discarded by the agent runtime. I updated Let me know if you need any changes. Thank You. |
96cd2a8 to
78c38d1
Compare
This adds isinstance guards to prevent tool loop crashes from malformed overrides and allows explicit falsy values (like {}) to clear parameters. Also enhances tests to assert both inputSchema and parameters.
5685c87 to
f47cea4
Compare
|
Update: Added defensive guards and edge-case fixes (Note for Maintainers: As discussed over in my comment on PR #577 (here), @Deez-Automations and I both independently caught this vulnerability! I took a defensive approach here in the factory, while they added API-level validation. Happy to combine approaches or defer to whatever fits best!) I just pushed a new commit to make the tool override application much more robust against edge cases and malformed payloads. Here is a breakdown of what this commit changes:
Before: If a user deliberately tried to clear a tool's parameters by passing an empty dictionary ({}), it was treated as a falsy value by if not (new_description or new_parameters): and silently ignored. Before: If an attacker passed a string or list instead of a dictionary for the override (e.g. {"send_email": "poison string"}), it would throw an uncaught AttributeError on .get() and completely crash the _apply_tool_overrides loop, breaking server initialization. Before: The unit tests only verified that the inputSchema alias was updated, leaving the actual internal parameters attribute unverified. |
fix (mcp): Apply
parametersoverride in_apply_tool_overridesFixes #547
What changed
finbot/mcp/factory.py-_apply_tool_overridesPreviously the function only read
descriptionfrom each tool override entry and silently discarded anyparameters/inputSchemablock the caller had stored.This PR widens the implementation to also apply the parameter schema when one is present in the override dict.
Why
The
PUT /darklab/api/v1/supply-chain/servers/{server_type}/toolsendpoint accepts and persists arbitrary JSON per tool (includingparameters), the Dark Lab UI displays the full stored object, and the supply-chain stats endpoint counted parameter-bearing overrides as "poisoned tools" -- but the agent runtime never saw the changed schema. This created a silent mismatch between what was stored and what was actually active.Changes
finbot/mcp/factory.pyBehaviour preserved
if not (new_description or new_parameters): continueguard means entries with neither key are skipped, same as before.parameters(Dark Lab UI key) andinputSchema(FastMCP native key) interchangeably.Testing
Run the existing dark lab route security tests to confirm nothing regresses:
Manual verification:
descriptionandparametersforfinmail/send_emailsend_emailbccfield is now known to the LLM)