Tool (tools/base.py)

claude-quickstarts · agents/tools/base.py · python · MIT
ai, tag:embed-classified

Base tool definitions for the agent framework.

# Source: https://github.com/anthropics/claude-quickstarts | License: MIT | Copyright 2023 Anthropic
# Provided via justclaw.it.com; keep this notice with the code.
"""Base tool definitions for the agent framework."""

from dataclasses import dataclass
from typing import Any


@dataclass
class Tool:
    """Base class for all agent tools."""

    name: str
    description: str
    input_schema: dict[str, Any]

    def to_dict(self) -> dict[str, Any]:
        """Convert tool to Claude API format."""
        return {
            "name": self.name,
            "description": self.description,
            "input_schema": self.input_schema,
        }

    async def execute(self, **kwargs) -> str:
        """Execute the tool with provided parameters."""
        raise NotImplementedError(
        

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key