Route tool calls to appropriate methods
(self, server_name: str, *, tool_name: str,
tool_args: dict)
| 497 | return tools |
| 498 | |
| 499 | async def call_tool(self, server_name: str, *, tool_name: str, |
| 500 | tool_args: dict) -> str: |
| 501 | """Route tool calls to appropriate methods""" |
| 502 | if not self._initialized: |
| 503 | await self.connect() |
| 504 | |
| 505 | try: |
| 506 | method = getattr(self, tool_name) |
| 507 | return await method(**tool_args) |
| 508 | except AttributeError: |
| 509 | return json.dumps( |
| 510 | { |
| 511 | 'success': False, |
| 512 | 'error': f'Unknown tool: {tool_name}' |
| 513 | }, |
| 514 | indent=2) |
| 515 | except Exception as e: |
| 516 | logger.error( |
| 517 | f'Tool execution error ({tool_name}): {e}', exc_info=True) |
| 518 | return json.dumps( |
| 519 | { |
| 520 | 'success': False, |
| 521 | 'error': f'Tool execution error: {str(e)}' |
| 522 | }, |
| 523 | indent=2) |
| 524 | |
| 525 | async def notebook_executor(self, |
| 526 | code: str, |