Description
MCPToolResolver._resolve_native() silently returns an empty tool list when:
The MCP server returns no tools, or
The tool_filter removes all tools.
The empty tools_list can trigger the error at tool_resolver.py", line 412:
for tool_def in tools_list:
^^^^^^^^^^
UnboundLocalError: cannot access local variable 'tools_list' where it is not associated with a value
There is no warning logged, making it very hard for users to understand why their MCP server (Stdio / HTTP / SSE) is not providing any tools.
In contrast, _resolve_external() (for HTTPS URLs) does log a clear warning:
No tools discovered from MCP server: {server_url}
Affected Code
File: crewai/mcp/tool_resolver.py
Method: MCPToolResolver._resolve_native() (around line 412, right after tool filtering)
Steps to Reproduce
- Configure an agent with a native MCP server via MCPServerStdio, MCPServerHTTP, or MCPServerSSE that either has no tools or uses a tool_filter that returns nothing.
- Add it to the agent’s mcps list.
- Run the agent/task → zero tools are available and no warning appears in the logs.
Expected behavior
A clear warning should be logged when no tools are discovered after listing + filtering, exactly like the external resolver path. Instead of the current 500 Error.
Screenshots/Code snippets
tools = []
for tool_def in tools_list:
tool_name = tool_def.get("name", "")
original_tool_name = tool_def.get("original_name", tool_name)
if not tool_name:
continue
Operating System
Ubuntu 20.04
Python Version
3.12
crewAI Version
latest
crewAI Tools Version
latest
Virtual Environment
Venv
Evidence
Traceback (most recent call last):
File ".../python3.12/site-packages/crewai/mcp/tool_resolver.py", line 412, in _resolve_native
for tool_def in tools_list:
^^^^^^^^^^
UnboundLocalError: cannot access local variable 'tools_list' where it is not associated with a value
Possible Solution
if not tools_list:
self._logger.log(
"warning",
f"No tools discovered from MCP server: {server_name}",
)
return cast(list[BaseTool], []), []
Additional context
It's an apparent bug.
Description
MCPToolResolver._resolve_native()silently returns an empty tool list when:The MCP server returns no tools, or
The
tool_filterremoves all tools.The empty
tools_listcan trigger the error attool_resolver.py", line 412:There is no warning logged, making it very hard for users to understand why their MCP server (Stdio / HTTP / SSE) is not providing any tools.
In contrast,
_resolve_external()(for HTTPS URLs) does log a clear warning:Affected Code
File:
crewai/mcp/tool_resolver.pyMethod:
MCPToolResolver._resolve_native()(around line 412, right after tool filtering)Steps to Reproduce
Expected behavior
A clear warning should be logged when no tools are discovered after listing + filtering, exactly like the external resolver path. Instead of the current 500 Error.
Screenshots/Code snippets
Operating System
Ubuntu 20.04
Python Version
3.12
crewAI Version
latest
crewAI Tools Version
latest
Virtual Environment
Venv
Evidence
Possible Solution
Additional context
It's an apparent bug.