microsoft/autogen · error · ValueError
Tool '{tool_name}' not found, available tools: {', '.join([t
Error message
Tool '{tool_name}' not found, available tools: {', '.join([t.name for t in tools_response.tools])} What it means
McpToolAdapter.from_server_params opens a session, calls session.list_tools(), and searches for the requested tool_name; if no advertised tool matches exactly, ValueError is raised listing all available tool names. This is a discovery mismatch: the name you asked for is not what the server exposes.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/tools/mcp/_base.py:153
Args:
server_params (TServerParams): Parameters for the MCP server connection.
tool_name (str): The name of the tool to wrap.
Returns:
McpToolAdapter[TServerParams]: An instance of McpToolAdapter.
Raises:
ValueError: If the tool with the specified name is not found.
"""
async with create_mcp_server_session(server_params) as session:
await session.initialize()
tools_response = await session.list_tools()
matching_tool = next((t for t in tools_response.tools if t.name == tool_name), None)
if matching_tool is None:
raise ValueError(
f"Tool '{tool_name}' not found, available tools: {', '.join([t.name for t in tools_response.tools])}"
)
return cls(server_params=server_params, tool=matching_tool)
def return_value_as_string(self, value: list[Any]) -> str:
"""Return a string representation of the result."""
def serialize_item(item: Any) -> dict[str, Any]:
if isinstance(item, (TextContent, ImageContent, AudioContent)):
dumped = item.model_dump()
# Remove the 'meta' field if it exists and is None (for backward compatibility)
if dumped.get("meta") is None:
dumped.pop("meta", None)
return dumped
elif isinstance(item, EmbeddedResource):
type = item.type
resource = {}View on GitHub (pinned to 027ecf0a37)
Solutions
- Log the error message — it enumerates available tools; use the exact name it lists.
- Before creating the adapter, call session.list_tools() yourself and match names programmatically (strip/casefold) to find the right one.
- Verify server_params (command, args, url) point to the server that actually exposes the tool.
- Pin the MCP server version whose tool names your code expects.
Example fix
# before
adapter = await McpToolAdapter.from_server_params(params, "search")
# after
async with create_mcp_server_session(params) as session:
await session.initialize()
names = [t.name for t in (await session.list_tools()).tools]
target = next(n for n in names if n.casefold() == "search")
adapter = await McpToolAdapter.from_server_params(params, target) Defensive patterns
Strategy: validation
Validate before calling
async with create_mcp_server_session(server_params) as session:
await session.initialize()
names = [t.name for t in (await session.list_tools()).tools]
if tool_name not in names:
close = [n for n in names if n.casefold() == tool_name.casefold()]
raise ValueError(f"{tool_name!r} not in {names}; closest: {close}") Try / catch
try:
adapter = await McpToolAdapter.from_server_params(params, name)
except ValueError as e:
if "not found" in str(e):
# message lists available tools; pick the right one and retry once
available = parse_available_tools(str(e))
name = next(n for n in available if n.casefold() == name.casefold())
adapter = await McpToolAdapter.from_server_params(params, name)
else:
raise Prevention
- Discover tool names via list_tools at startup and bind adapters by resolved name.
- Pin MCP server versions whose tool names your prompts/agents reference.
- Log available tools once at connection so mismatches are debuggable.
When it happens
Trigger: Calling from_server_params(server_params, tool_name='search') when the server registers the tool as 'web_search'; trailing whitespace or different casing in tool_name; the server exposing tools conditionally (disabled feature flags, env-gated tools); connecting to the wrong server entirely.
Common situations: Server upgraded and tool renamed; connecting to a different MCP server (wrong command/URL) than the one hosting the tool; case-sensitivity mistakes ('GitHub' vs 'github'); a fork of the server with renamed tools; the server returning an empty list because initialization failed partially.
Related errors
- Failed to list MCP tools
- Failed to call MCP tool
- MCP health check failed
- HTTP ${response.status}: ${errorText || "Failed to create We
- Invalid JSON response from server. Check if the MCP route is
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/6dae7abc3536ad55.
Report an issue: GitHub.