Skip to content

feat(tools): attach MCP tools only when the run has MCP configured - #1390

Open
tntrenjin wants to merge 2 commits into
usestrix:mainfrom
tntrenjin:feat/mcp-tools-gating
Open

tntrenjin wants to merge 2 commits into
usestrix:mainfrom
tntrenjin:feat/mcp-tools-gating

Conversation

@tntrenjin

@tntrenjin tntrenjin commented Sep 30, 2026 •

Copy link
Copy Markdown

Follow-up to #1175.

Summary

The five MCP tools (list_mcps, search_mcp_tools, get_mcp_tool_schema, describe_mcp, call_mcp) are now attached only when the run has MCP configured (mcp_available on the prompt context). A run with MCP configured gets the same tool list as before; a run without it gets none.

Why

#1175 made the MCP toolset a fixed set of generic tools, so it no longer grows with the number of connected servers. The set lives in _BASE_TOOLS, so every agent carries it even when no MCP server is configured: five tool schemas on every request that the model cannot use, while the prompt's MCP section in scope.jinja is already gated on mcp_available. docs/integrations/mcp.mdx also already says "Without it, a run simply gets no MCP tools."

Changes

  • strix/agents/factory.py: move the MCP tools out of _BASE_TOOLS into _MCP_TOOLS, which build_strix_agent adds only when mcp_available is set, the same flag the prompt uses.
  • tests/test_mcp_client.py: test_agent_carries_exactly_the_generic_mcp_tools_regardless_of_connections now builds its agents with mcp_available=True.
  • tests/test_agent_factory_shell.py: root and child agents get none of the five tools without MCP configured and all five with it, with no carry-over into a later agent.
  • tests/test_runner_root_prompt.py: the runner passes mcp_available to the child agent factory as well as the root agent.

Testing

  • pre-commit on the changed files is clean (ruff check, ruff format --check, mypy, bandit, pyupgrade).
  • uv run pytest: 2162 passed, 1 failed (tests/test_pricing.py::test_resolves_common_bare_model_names: grok-4.5 resolves to openrouter/x-ai/grok-4.5). It is pre-existing on main, so it is not caused by this change.

list_mcps, search_mcp_tools, get_mcp_tool_schema, describe_mcp and call_mcp
are now attached only when mcp_available is set on the prompt context, the
same flag scope.jinja already gates its MCP guidance on. A run with no MCP
configured no longer carries five tool schemas it cannot use; with MCP
configured, the tool list stays the same regardless of how many connections
exist.
@tntrenjin
tntrenjin marked this pull request as ready for review September 30, 2026 16:47
@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Conditionally includes MCP tools based on run configuration.

The PR appears safe to merge, though the tool-registration name check should also cover MCP tools.

Findings

  1. P2 Duplicate MCP names pass registration ▶
Fix with agent prompt
### Issue 1
strix/agents/factory.py:609-615
Moving the MCP tools out of `_BASE_TOOLS` also removes their names from the check in `register_agent_tools`. An extension can register a tool named `call_mcp` without an error. A later scan with MCP configured then fails when `build_strix_agent` checks names again. Include `_MCP_TOOLS` in the registration check so the extension gets the error when it registers.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Root and child agents now receive the five generic MCP tools only when the run context says MCP is available. This keeps the model’s tool list in step with the run’s MCP configuration.

  • The agent factory adds the MCP tools only for runs with MCP configured.
  • Tests cover the flag reaching child-agent setup and the tool lists for both agent types.

Reviews (1) · Last reviewed commit: "feat(tools): attach MCP tools only when ..."

Comment thread strix/agents/factory.py
register_agent_tools now checks _MCP_TOOLS too, so a name clash fails at registration instead of when a run with MCP configured builds its agents.

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