| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- """
- -----------------------------------------------------------------------------------------
- INTERSEL - 4 cité d'Hauteville - 75010 PARIS
- RCS PARIS 488 379 660 - NAF 721Z
- File : tools/tool_class.py
- Object : Class for MCP server tools
- -----------------------------------------------------------------------------------------
- Modifications :
- - 2026/01/16 - Damien Lugagne-Delpon - V1.0.0- Creation
- -----------------------------------------------------------------------------------------
- @copyright : Intersel 2026
- @author : Damien Lugagne-Delpon - damien.lugagne-delpon@livinweb.fr
- @version : 1.0.0 (to be updated to the current_version of the developed software if file is touched)
- -----------------------------------------------------------------------------------------
- """
- class Tool:
- """Base class for MCP server tools."""
-
- def __init__(self, name: str, description: str = "", remarks: str = "", parameters: dict = {}, handler=None):
- """Initialize the tool."""
- self.name = name
- self.description = description
- self.remarks = remarks
- self.parameters = parameters
- self.handler = handler
-
- def translate_to_mcp(self):
- """Translate the tool to MCP format."""
- tool_dict = {
- "name": self.name,
- "description": self.description,
- "remarks": self.remarks,
- "parameters": self.parameters,
- }
- return tool_dict
-
- async def execute(self, **kwargs):
- """Execute the tool's handler."""
- if self.handler is None:
- raise NotImplementedError("Tool handler is not implemented.")
- return await self.handler(**kwargs)
-
-
|