Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion mcp_client_for_ollama/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,19 @@ async def process_query(self, query: str) -> str:
# Call the tool on the specified server
result = None
with self.console.status(f"[cyan]⏳ Running {tool_name}...[/cyan]"):
result = await self.sessions[server_name]["session"].call_tool(actual_tool_name, tool_args)
try:
result = await self.sessions[server_name]["session"].call_tool(actual_tool_name, tool_args)
except Exception as e:
error_msg = f"Error calling tool {tool_name}: {str(e)}"
self.console.print(f"[red]{error_msg}[/red]")
# Send error message to LLM
messages.append({
"role": "tool",
"content": error_msg,
"tool_name": tool_name
})
# Continue with next tool call if any
continue

tool_response = f"{result.content[0].text}"

Expand Down