Skip to main content
Glama
base_tool.py1.36 kB
""" Base Tool Class All security tools inherit from this base class """ from typing import Dict, Any, List from abc import ABC, abstractmethod class BaseTool(ABC): """Base class for all security tools""" def __init__(self): self.name = "" self.description = "" @abstractmethod def get_tool_definition(self) -> Dict[str, Any]: """ Return tool definition in MCP format Returns: Dict with name, description, and inputSchema """ pass @abstractmethod async def execute(self, arguments: Dict[str, Any]) -> List[Dict[str, Any]]: """ Execute the tool with given arguments Args: arguments: Tool arguments from MCP client Returns: List of content dictionaries in MCP format """ pass def format_success(self, output: str) -> List[Dict[str, Any]]: """Format successful tool output""" return [ { "type": "text", "text": output } ] def format_error(self, error: str) -> List[Dict[str, Any]]: """Format error output""" return [ { "type": "text", "text": f"❌ Error: {error}" } ]

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kannanprabu/MCPPentestBOT'

If you have feedback or need assistance with the MCP directory API, please join our Discord server