crewAI
crewAI copied to clipboard
Flow: dead code pattern — unreachable variable and orphaned utility functions remain after MCP removal
Description
When migrating from MCP-based tools to @tool-based tools, the Flow project retains:
- Orphaned MCP server variables —
MCPServerStdioinstances that no agent references inmcps=[] - Helper functions that were only used during MCP setup and are now dead code
- Unused tool definition arrays — e.g.
GBRAIN_TOOLS_DEFAULTdefined 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 →
@toolmigration
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
Closed — not a framework issue, user-side cleanup.