Skip to content

fix(app): keep a team member's MCP tools within its definition's exclusions - #2939

Merged
rdimitrov merged 2 commits into
mainfrom
fix/team-member-disallowed-mcp
Nov 21, 2026
Merged

rdimitrov merged 2 commits into
mainfrom
fix/team-member-disallowed-mcp

Conversation

@rdimitrov

@rdimitrov rdimitrov commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

A team member running a named agent definition got every MCP tool of the servers its definition names, including tools its disallowedTools excludes, and could call them. This keeps those tools out, for team members and subagents alike, by applying the exclusion in the one function both use.

The bug

  • Members skipped the filter. defMCPTools (internal/app/agentdefs.go) is the one place the subagent and team-member paths resolve a definition's MCP tools. But each caller applied disallowedTools itself, and the team-member path (internal/app/build.go) never did.
  • Nothing else caught it. A member's authority is copied from its parent (deriveDelegatedAuthority in engine/agent/teamsupervisor.go), not narrowed by its definition. So a member could call an excluded tool its parent allowed. Subagents had a second check in their authority; members had none.
  • Who's affected: any deployment with named team members whose definitions exclude MCP tools from their mcpServers.
  • When it started: the member MCP loop dates from mid-2026. The subagent filter came later, with session-scoped agent definitions (Implement session-scoped Agent Definitions #2003), and the member path wasn't updated.
  • Docs: user-docs/features/security-and-execution/permissions-and-posture.md already says a definition's disallowedTools narrows the specialist, so this restores documented behavior.

The fix

  • defMCPTools leaves out excluded tools before returning them, so both paths share the rule and can't drift again. The callers' own filters are removed.
  • MCPToolNames lists only the tools the member's catalog holds. Its only consumer is the read-only-member check, which reads catalog tools, so before this an unregistered name changed nothing. It's extra safety, not a fix for a bug anyone can reach.

API compatibility

No wire change. A member loses MCP tools its own definition excludes. No conforming client relies on calling a tool its definition excludes.

Testing

Tests:

  • TestDefMCPToolsLeavesOutDisallowedTools checks defMCPTools directly. Excluded tools from a referenced server and from an inline one are both left out, and both are kept without the exclusion.
  • TestMemberDefMCPToolHonorsDisallowedTools drives a real team supervisor and member factory against an MCP server with two tools. The excluded tool never reaches the server, while the other does.
    • It failed on main before the fix.
  • Mutation check: removing the filter from defMCPTools fails both tests.

Real use, local. I ran mecak8s with a fake MCP server that logs each call. A named definition references that server and excludes its echo tool. A team member running it calls ping, then echo.

Binary What the server received
main ping, then echo (the bug)
This PR only ping

With the fix, the member gets "tool is currently unavailable" for echo. A named subagent running the same definition also reaches only ping.

Gates:

  • task lint passes.

  • The offline demo shows a tool call, a permission ask and approval, and the result.

  • task test:race passes apart from three packages this PR doesn't touch:

    • environment/microvm and internal/adapter/microvmmanager pass when rerun alone.
    • cmd/mecatui/ui's connect-mouse goldens fail on this PR's base too.
  • task check:pr passes apart from two steps:

    • sdk:e2e didn't run because bun isn't installed locally;
    • docs:server-cli:check reports a line-wrap difference that comes from the local checkout path (no flags changed).

    The steps after sdk:e2e pass when run on their own.

Panel review (spec, standards, tests, security, duplication, reuse) found no blockers. The architecture reviewer sat out because nothing structural changed.

  • Two reviewers independently found the root cause: the rule lived next to defMCPTools instead of inside it. That's the second commit.
  • Security found no other way for a member to reach an excluded MCP tool:
    • every member is built through buildMemberSelectorEngine;
    • a defined member gets no generic MCP tool such as CallMcpWithQuery;
    • exclusions match exact tool names.

Found, not in this PR

  • A member with no filesystem access ignores its definition. The no-FS branch of buildMemberSelectorEngine skips adopting the definition on purpose. So it gets every server-wide MCP tool, including ones its disallowedTools names, as a no-FS subagent does. Spec and security both flagged it as advisory. Its authority is still its parent's, so it gains nothing its parent lacked.

🤖 Generated with Claude Code

…usions

A team member running a named definition got every MCP tool of the
servers its definition names, including those its disallowedTools
excludes, and could call them. A member's authority is its parent's, so
nothing else removed them. The subagent path already filtered them.

The member path now leaves excluded tools out of the catalog, and reports
only the tools it registered to the read-only check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
defMCPTools is the one place the subagent and team-member paths resolve a
definition's MCP tools, but each caller applied disallowedTools itself,
and the member path had drifted. It now leaves out excluded tools before
returning them, so both paths share the rule; the callers' own filters
are removed. A direct test covers a referenced and an inline server.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rdimitrov
rdimitrov merged commit ef86380 into main Nov 21, 2026
50 checks passed
@rdimitrov
rdimitrov deleted the fix/team-member-disallowed-mcp branch November 21, 2026 17:07
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