MCPcopy Index your code
hub / github.com/SkyworkAI/DeepResearchAgent / build

Method build

src/tool/context.py:383–420  ·  view source on GitHub ↗

Create a tool instance and store it. Args: tool_config: Tool configuration Returns: ToolConfig: Tool configuration with instance

(self, tool_config: ToolConfig)

Source from the content-addressed store, hash-verified

381 logger.warning(f"| ⚠️ Failed to add tool {tool_config.name} to FAISS index: {e}")
382
383 async def build(self, tool_config: ToolConfig) -> ToolConfig:
384 """Create a tool instance and store it.
385
386 Args:
387 tool_config: Tool configuration
388
389 Returns:
390 ToolConfig: Tool configuration with instance
391 """
392 if tool_config.name in self._tool_configs:
393 existing_config = self._tool_configs[tool_config.name]
394 if existing_config.instance is not None:
395 return existing_config
396
397 # Create new tool instance
398 try:
399 # cls should already be loaded (either from registry or from code in _load_from_code)
400 if tool_config.cls is None:
401 raise ValueError(f"Cannot create tool {tool_config.name}: no class provided. Class should be loaded during initialization.")
402
403 # Instantiate tool instance
404 tool_instance = tool_config.cls(**tool_config.config) if tool_config.config else tool_config.cls()
405
406 # Initialize tool if it has an initialize method
407 if hasattr(tool_instance, "initialize"):
408 await tool_instance.initialize()
409
410 tool_config.instance = tool_instance
411
412 # Store tool metadata
413 self._tool_configs[tool_config.name] = tool_config
414
415 logger.info(f"| 🔧 Tool {tool_config.name} created and stored")
416
417 return tool_config
418 except Exception as e:
419 logger.error(f"| ❌ Failed to create tool {tool_config.name}: {e}")
420 raise
421
422 async def register(self,
423 tool_cls: Type[Tool],

Callers 10

initializeMethod · 0.95
load_from_jsonMethod · 0.95
restoreMethod · 0.95
_init_assets_dataMethod · 0.45
_init_asset_dataMethod · 0.45
initializeMethod · 0.45
__init__Method · 0.45
mainFunction · 0.45
mainFunction · 0.45

Calls 3

initializeMethod · 0.45
infoMethod · 0.45
errorMethod · 0.45

Tested by 1

__init__Method · 0.36