Skip to content

fix: hide inactive tools in MCP settings - #8206

Merged
wangdan-fit2cloud merged 1 commit into
v3from
pr@v3@fix_mcp_setting
Nov 27, 2026
Merged

wangdan-fit2cloud merged 1 commit into
v3from
pr@v3@fix_mcp_setting

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: hide inactive tools in MCP settings

mcpOptions.value = tools.filter((item) => item.is_active)
emit('loaded', tools)
})
.finally(() => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here's my review of the diff:

The change: Filters tools to only include active ones (item.is_active) before assigning to mcpOptions, while still emitting the full unfiltered tools.

Potential Issues

  1. Inconsistency between mcpOptions and emitted data

    • mcpOptions.value receives only active tools.
    • emit('loaded', tools) emits the full list (including inactive tools).
    • If a parent component uses the emitted tools to make assumptions matching mcpOptions, they will diverge. Confirm this divergence is intentional.
  2. Falsy filter risk on is_active

    • If is_active can be undefined or a non-boolean (e.g., 0, "false" string, null), the filter may unexpectedly drop valid entries.
    • Consider explicit check: tools.filter((item) => item.is_active === true) if strict boolean is expected.
  3. Empty result handling

    • If all tools are inactive, mcpOptions becomes []. Ensure downstream code handles an empty options list gracefully (e.g., no MCP selector shown, no crash).
  4. No null/undefined guard on tools

    • .then((tools) => ...) assumes getToolListWithShared always resolves to an array. Add a defensive check: Array.isArray(tools) ? tools.filter(...) : [].
  5. Visibility race condition (pre-existing, but relevant)

    • if (!visible.value) return correctly guards assignment. However, the finally block still runs — verify nothing in finally depends on mcpOptions being populated, since it may not be.

Optimization Suggestions

  • Compute once from the same source for clarity:
    const activeTools = tools.filter((item) => item.is_active === true)
    mcpOptions.value = activeTools
    emit('loaded', tools)
  • Emit both sets if consumers need them, e.g. emit('loaded', { all: tools, active: activeTools }), to prevent ambiguity.
  • Type safety: ensure McpOption type marks is_active as boolean (not optional) so the filter logic is self-documenting.

Summary

The change itself is syntactically fine, but watch for (a) mismatch between filtered mcpOptions and unfiltered emitted tools, (b) loose truthiness on is_active, and (c) missing array/null guards.

@wangdan-fit2cloud
wangdan-fit2cloud merged commit 47696f3 into v3 Nov 27, 2026
3 of 4 checks passed
@wangdan-fit2cloud
wangdan-fit2cloud deleted the pr@v3@fix_mcp_setting branch November 27, 2026 08:43
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.

2 participants