Skip to content

refactor(ai): delete the outbound MCP toolset code with no caller #3762

Closed

Description

@dan-petty

Problem or Motivation

Part of #1330. The 2026-10-07 text asks for one decision: give outbound MCP a seam, or delete it (Q22). Outbound MCP means devops-cli as a client of another MCP server, by URL or script. A seam is built only if a caller exists. The caller search below finds none. This item deletes the code.

Caller search, at origin/main 29309f0. I searched src, tests, docs, the knowledge base, pyproject.toml and the entry points.

Code Callers in src Callers elsewhere
create_mcp_toolset (ai/mcp/toolset.py:111) MCPToolset.to_native_toolset only (ai/agents/tools.py:249, :257) tests
to_native_toolset, MCPToolset.from_config (ai/agents/tools.py) none tests
load_devops_mcp_toolsets, create_devops_mcp_toolset (ai/mcp/toolset.py) create_devops_mcp_toolset from get_devops_mcp_toolset only tests
get_devops_mcp_toolset (ai/tools/mcp_bridge.py:35) none. It is only re-exported in ai/tools/__init__.py:50, :301 tests
ai.agents.tools.MCPToolset none two KB pages and tests
Agent.set_mcp_sampling_model (ai/agents/agent.py:473) none one KB example (libraries/pydantic_ai.md:118)
  • No command, setting, environment variable, tool or [project.scripts] entry reads an MCP server address or script. The only MCP setting is the bearer token of devops mcp serve.
  • The class MCPToolset in ai/agents/tools.py does not connect. close does nothing, get_tools returns the list passed in, and get_instructions returns a fixed sentence. It reports a connection that it never makes.
  • docs/TESTING.md:68 lists "outbound MCP servers" among the faked edges. No such edge exists in src.
  • Not deleted, because it has callers: get_mcp_agent_tools in ai/tools/mcp_bridge.py. get_default_tools in ai/tools/registry.py:61 calls it, and it exposes the devops-cli server's own tools to the agents.
  • Related open items. refactor: Delete unused functions after manual caller check #1910 lists set_mcp_sampling_model among names to check for callers. Whichever item lands first deletes it. feat(roadmap): let a job call the tools of the MCP server #3221 plans a job-side MCP client. It uses pydantic-ai's own MCPToolset and the pattern in the KB page libraries/pydantic_ai.md. It needs none of the code deleted here.

Proposed Solution & Architectural Design

Delete the code and its tests. Add no seam, no Protocol and no fake. If a real caller appears later, the item that adds it uses pydantic-ai's MCPToolset directly, with FastMCP's in-memory transport for its test. That item may then add a seam, with a caller to justify it.

The KB pages stay as the pattern for pydantic-ai's own client, which #3221 cites. Their examples must call that class and not the deleted wrapper. The installed class takes the client as its first argument (MCPToolset("http://localhost:8000/sse")) and has sampling_model, http_client and client_info parameters. The implementer checks each example against the installed package.

Acceptance criteria

  • src/devops_cli/ai/mcp/toolset.py does not exist.
  • ai/agents/tools.py has no class MCPToolset, no from_config, no to_native_toolset, and no import that only they used. AgentSpec stays.
  • Agent.set_mcp_sampling_model is deleted from ai/agents/agent.py.
  • ai/tools/mcp_bridge.py has no get_devops_mcp_toolset and no TYPE_CHECKING import that only it used. ai/tools/__init__.py does not import or export it. get_mcp_agent_tools stays.
  • git grep -nE 'devops_cli\.ai\.agents\.tools import .*MCPToolset|ai\.mcp\.toolset|create_mcp_toolset|create_devops_mcp_toolset|load_devops_mcp_toolsets|get_devops_mcp_toolset|set_mcp_sampling_model' -- src docs tests ':!docs/agent/archive' ':!tests/fixtures' returns no line. A grep for the bare name MCPToolset is not used: pydantic-ai's own class has that name and stays in the KB.
  • The three KB examples (libraries/pydantic_ai.md lines 52-56 and 102-118, and python_packages.md lines 123-133) import MCPToolset from pydantic_ai.mcp. The line about devops_cli.ai.agents.tools.MCPToolset in python_packages.md is gone. The set_mcp_sampling_model line is gone.
  • docs/TESTING.md no longer lists "outbound MCP servers" among the faked edges.
  • tests/ai/mcp/test_pydantic_ai_mcp.py is deleted. Its two tests of live code, test_mcp_bridge_dynamic_discovery (without the get_devops_mcp_toolset lines) and test_mcp_derived_default_tools_match_published_fastmcp_schemas, move to tests/ai/tools/test_default_tools_follow_the_mcp_server.py. test_mcp_toolset is deleted from tests/ai/agents/test_ai_agent_capabilities.py.
  • The two kept tests pass with no patch and no private import.
  • uv run devops docs check and uv run devops ci pass. The pull request body repeats the caller search with the commands used.
  • If a caller turns up that this search missed, stop. Return this item to New with the call site as evidence.

Children A and D both edit test_mcp_toolset and test_pydantic_ai_mcp.py. Children B and D both edit the list of faked edges in docs/TESTING.md:68. The second to land rebases. If this child lands first, child A has two fewer files to change.

Target Subsystem

src/devops_cli/ai/mcp/toolset.py, src/devops_cli/ai/agents/tools.py, src/devops_cli/ai/agents/agent.py, src/devops_cli/ai/tools/ (mcp_bridge.py, __init__.py), src/devops_cli/ai/knowledge_base/devops_cli/ (python_packages.md, libraries/pydantic_ai.md), docs/TESTING.md, tests/ai/mcp/, tests/ai/tools/, tests/ai/agents/test_ai_agent_capabilities.py.

Existing Tool Considered

The open tool for outbound MCP is pydantic-ai's MCPToolset, which the deleted wrapper only re-exported. Nothing needs a wrapper today.

Cost to build a seam for a code path with no caller: about 60,000 tokens to build and 20,000 tokens a year to keep. It also takes one day of elapsed time. Cost of this deletion: no new code. The 155 lines of toolset.py, the class MCPToolset of about 130 lines and about 250 lines of tests leave the repository.

Activity

  1. added
    source/agent
    type/refactor
    scope/ai
    status/new
    value/medium
    effort/low
    on Nov 6, 2026
  2. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/refactor. The refactor prefix of the title gives the type.
    • Scope: scope/ai. The (ai) scope of the title gives the scope.
    • Priority: P2-Medium. Dead code removal reduces confusion but does not block users or fix a defect.
    • Value: Medium. It removes misleading wrappers and shrinks the codebase, but no user-visible behaviour changes.
    • Effort: Low. The work is bounded deletion across a few files plus small KB edits, with clear acceptance criteria.
    • Related: feat(roadmap): let a job call the tools of the MCP server #3221, which asks for a different change. Both concern the MCP client area, but #3221 adds a new job-side client while this item deletes dead code with no caller.
  3. added
    priority/p2-medium
    on Nov 6, 2026
  4. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 6, 2026
  5. removed
    status/in-review
    on Nov 6, 2026
  6. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-06 19:47 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/aisource/agenttype/refactorvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions