-
Notifications
You must be signed in to change notification settings - Fork 6.8k
MCP Server is giving "The selected tool does not have a callable 'function'" when using via autogen #6456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi! Thanks for raising the issue. From what I see, this looks more like a usage misunderstanding rather than a bug. Here’s a working example that demonstrates how to properly set up import asyncio
from autogen_ext.tools.mcp import McpWorkbench, StdioServerParams
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_agentchat.ui import Console
async def run_chat_with_topic(topic: str):
server_params = StdioServerParams(
command="python",
args=["dummy_server.py"],
read_timeout_seconds=60,
)
workbench = McpWorkbench(server_params=server_params)
all_tools = await workbench.list_tools()
selected_tool = next(
(
tool
for tool in all_tools
if isinstance(tool, dict) and tool.get("name") == "get_weather_info"
),
None,
)
if not selected_tool:
raise ValueError("Tool 'get_weather_info' not found on the MCP server.")
result = await workbench.call_tool(selected_tool["name"], {"topic": topic})
print(f"Tool result: {result}")
model_client = OpenAIChatCompletionClient(model="gpt-4.1-nano")
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.conditions import MaxMessageTermination
from autogen_agentchat.teams import RoundRobinGroupChat
assistant_1 = AssistantAgent(
name="Planner",
model_client=model_client,
system_message="You are an AI weather planner for India.",
workbench=workbench,
reflect_on_tool_use=True,
tool_call_summary_format="[Tool]{tool_name} result : {result}",
)
assistant_2 = AssistantAgent(
name="Researcher",
model_client=model_client,
system_message="You are an AI weather researcher for India.",
workbench=workbench,
reflect_on_tool_use=True,
tool_call_summary_format="[Tool]{tool_name} result : {result}",
)
agents = [assistant_1, assistant_2]
termination_condition = MaxMessageTermination(max_messages=len(agents) + 1)
team = RoundRobinGroupChat(
participants=agents,
termination_condition=termination_condition,
)
# return await team.run(
# task=f"Get weather info for '{topic}'"
# )
await Console(
team.run_stream(
task=f"Get weather info for '{topic}'",
cancellation_token=None,
)
)
if __name__ == "__main__":
topic = "rain"
asyncio.run(run_chat_with_topic(topic)) Please check if this setup matches your intention. If so, it should work as expected. Let me know if you were trying to achieve something different. Otherwise, feel free to close the issue if this resolves your problem. |
Can you share an example on how to achieve this with multiple different MCPs? anything similar to openai agents? example: agent=Agent( |
I want it too. But honestly, I also hope one Agent could support multiple MCPs. @ekzhu |
I think it makes sense to support multiple workbenches in AssistantAgent. Before that becomes the case, you can create custom agents for this. To be honest there is nothing hard about this and AssistantAgent has gotten increasingly complex as a convenience kitchen sink class |
What happened?
This is all running MCP server and I have also validated it via cloude desktop
Now, I want to use it via local client, these things I am doing
running dummy server like : uv run dummy_server.py
running this autogen client
but I am getting this error
line 36, in run_chat_with_topic
raise ValueError("The selected tool does not have a callable 'function'.")
ValueError: The selected tool does not have a callable 'function'.
{'name': 'get_weather_info', 'description': '\n A tool to fetch
weather-related information based on the topic.\n\n
Arguments:\n - topic: The weather topic (rain, temperature, wind, etc.)
\n\n Returns:\n - A dictionary containing the weather description,
measurement, and effects\n ',
'parameters': {'type': 'object', 'properties': {'topic':
{'title': 'Topic', 'type': 'string'}},
'required': ['topic'], 'additionalProperties': False}}
The text was updated successfully, but these errors were encountered: