Skip to main content
Glama
base.py1.17 kB
"""Base tool implementation.""" from abc import ABC, abstractmethod from typing import Any import mcp.types as types class BaseTool(ABC): """Base class for MCP tools.""" def __init__(self, name: str, description: str = "", schema: dict[str, Any] | None = None) -> None: """Initialize the tool. Args: name: Tool name description: Tool description schema: JSON schema for tool arguments """ self.name = name self.description = description self.schema = schema or {"type": "object", "properties": {}} @abstractmethod async def execute(self, arguments: dict[str, Any]) -> list[types.ContentBlock]: """Execute the tool with given arguments. Args: arguments: Tool arguments Returns: List of content blocks """ pass def to_mcp_tool(self) -> types.Tool: """Convert to MCP Tool type. Returns: MCP Tool instance """ return types.Tool( name=self.name, description=self.description, inputSchema=self.schema, )

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/namnd00/mcp-server-hero'

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