Added try catch for mcp tool call
This commit is contained in:
parent
aee072b4a0
commit
7a9b08b78f
1 changed files with 7 additions and 3 deletions
|
|
@ -52,9 +52,13 @@ class MCPRouter:
|
|||
if method_name:
|
||||
method = getattr(self, method_name, None)
|
||||
if method:
|
||||
result = await method(arguments)
|
||||
logger.info('MCP tool call completed: tool=%s result=%s', name, result)
|
||||
return result
|
||||
try:
|
||||
result = await method(arguments)
|
||||
logger.info('MCP tool call completed: tool=%s result=%s', name, result)
|
||||
return result
|
||||
except Exception as exc:
|
||||
logger.exception('MCP tool call failed: tool=%s error=%s', name, exc)
|
||||
return {'error': f'Tool {name} failed: {exc}'}
|
||||
|
||||
logger.warning('MCP tool call rejected: unknown tool=%s', name)
|
||||
return {'error': f'Tool {name} not found'}
|
||||
|
|
|
|||
Loading…
Reference in a new issue