base.py•1.06 kB
"""MCP 도구 베이스 클래스"""
from abc import ABC, abstractmethod
from typing import Any, Dict, List
from pydantic import BaseModel
class ToolSchema(BaseModel):
"""도구 스키마 정의"""
name: str
description: str
inputSchema: Dict[str, Any]
class TextContent(BaseModel):
"""텍스트 콘텐츠"""
type: str = "text"
text: str
class BaseTool(ABC):
"""MCP 도구 베이스 클래스"""
def __init__(self, db_manager, cache_manager):
self.db_manager = db_manager
self.cache_manager = cache_manager
@property
@abstractmethod
def name(self) -> str:
"""도구 이름"""
pass
@property
@abstractmethod
def description(self) -> str:
"""도구 설명"""
pass
@abstractmethod
def get_tool_definition(self) -> ToolSchema:
"""도구 정의 반환"""
pass
@abstractmethod
async def execute(self, arguments: Dict[str, Any]) -> List[TextContent]:
"""도구 실행"""
pass