MCPcopy Create free account
hub / github.com/modelscope/ms-agent / call_tool

Method call_tool

ms_agent/tools/code/code_executor.py:499–523  ·  view source on GitHub ↗

Route tool calls to appropriate methods

(self, server_name: str, *, tool_name: str,
                        tool_args: dict)

Source from the content-addressed store, hash-verified

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,

Callers

nothing calls this directly

Calls 1

connectMethod · 0.95

Tested by

no test coverage detected