crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

Flow: dead code pattern — unreachable variable and orphaned utility functions remain after MCP removal

Open akrhin opened this issue 4 months ago • 1 comments

Description

When migrating from MCP-based tools to @tool-based tools, the Flow project retains:

  1. Orphaned MCP server variables — MCPServerStdio instances that no agent references in mcps=[]
  2. Helper functions that were only used during MCP setup and are now dead code
  3. Unused tool definition arrays — e.g. GBRAIN_TOOLS_DEFAULT defined but never imported/used

While not a runtime bug, it signals to maintainers that the codebase has incomplete cleanup. Consider adding:

  • A lint rule or convention that unused Flow/MCP variables trigger a warning
  • A cleanup pattern for MCP → @tool migration

Example patterns found in the wild (1.15.5)

# Defined but never used by any agent
mcp_gbrain = MCPServerStdio(command=..., args=[], ...)

# MCP cleanup list with the unused server
_all_mcp_servers = [
    mcp_gbrain,  # no agent references this
    mcp_context7,
    mcp_siyuan, 
    mcp_portainer,
]

# Defined but never imported or used
GBRAIN_TOOLS_DEFAULT = [gbrain_query, gbrain_get_page]

Expected

Unused MCP servers and tool arrays should generate at least a warnings.warn() during Flow initialization.

Environment

  • CrewAI: 1.15.5
  • Python: 3.11

akrhin avatar Jul 25 '26 00:07 akrhin

Closed — not a framework issue, user-side cleanup.

akrhin avatar Jul 25 '26 00:07 akrhin