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

Method __init__

ms_agent/tools/tool_manager.py:40–136  ·  view source on GitHub ↗
(self,
                 config,
                 mcp_config: Optional[Dict[str, Any]] = None,
                 mcp_client: Optional[MCPClient] = None,
                 **kwargs)

Source from the content-addressed store, hash-verified

38 TOOL_SPLITER = '---'
39
40 def __init__(self,
41 config,
42 mcp_config: Optional[Dict[str, Any]] = None,
43 mcp_client: Optional[MCPClient] = None,
44 **kwargs):
45 self.config = config
46 self.trust_remote_code = kwargs.get('trust_remote_code', False)
47
48 self.extra_tools: List[ToolBase] = []
49 self.has_split_task_tool = False
50 if hasattr(config, 'tools') and hasattr(config.tools, 'split_task'):
51 self.extra_tools.append(SplitTask(config))
52 if hasattr(config, 'tools') and hasattr(config.tools,
53 'image_generator'):
54 self.extra_tools.append(ImageGenerator(config))
55 if hasattr(config, 'tools') and hasattr(config.tools,
56 'video_generator'):
57 self.extra_tools.append(VideoGenerator(config))
58 if hasattr(config, 'tools') and hasattr(config.tools, 'file_system'):
59 self.extra_tools.append(
60 FileSystemTool(
61 config, trust_remote_code=self.trust_remote_code))
62 if hasattr(config, 'tools') and hasattr(config.tools, 'code_executor'):
63 code_exec_cfg = getattr(config.tools, 'code_executor')
64 implementation = getattr(code_exec_cfg, 'implementation',
65 'sandbox')
66 if isinstance(implementation,
67 str) and implementation.lower() == 'python_env':
68 self.extra_tools.append(LocalCodeExecutionTool(config))
69 elif isinstance(implementation,
70 str) and implementation.lower() == 'sandbox':
71 self.extra_tools.append(CodeExecutionTool(config))
72 else:
73 logger.warning(
74 f'Unknown code execution implementation: {implementation},'
75 f'using sandbox instead.')
76 self.extra_tools.append(CodeExecutionTool(config))
77 if hasattr(config, 'tools') and hasattr(config.tools,
78 'financial_data_fetcher'):
79 from ms_agent.tools.findata.findata_fetcher import FinancialDataFetcher
80 self.extra_tools.append(FinancialDataFetcher(config))
81 if hasattr(config, 'tools') and getattr(config.tools, 'agent_tools',
82 None):
83 agent_tool = AgentTool(
84 config, trust_remote_code=self.trust_remote_code)
85 if agent_tool.enabled:
86 self.extra_tools.append(agent_tool)
87 if hasattr(config, 'tools') and hasattr(config.tools, 'todo_list'):
88 self.extra_tools.append(TodoListTool(config))
89 if hasattr(config, 'tools') and hasattr(config.tools, 'web_search'):
90 self.extra_tools.append(WebSearchTool(config))
91 self.tool_call_timeout = getattr(config, 'tool_call_timeout',
92 TOOL_CALL_TIMEOUT)
93 local_dir = self.config.local_dir if hasattr(self.config,
94 'local_dir') else None
95 if hasattr(config, 'tools') and hasattr(config.tools,
96 TOOL_PLUGIN_NAME):
97 plugins = getattr(config.tools, TOOL_PLUGIN_NAME)

Callers

nothing calls this directly

Calls 12

register_toolMethod · 0.95
SplitTaskClass · 0.90
ImageGeneratorClass · 0.90
VideoGeneratorClass · 0.90
FileSystemToolClass · 0.90
CodeExecutionToolClass · 0.90
AgentToolClass · 0.90
TodoListToolClass · 0.90
WebSearchToolClass · 0.90
getMethod · 0.80

Tested by

no test coverage detected