22 lines
632 B
Python
22 lines
632 B
Python
from types import MappingProxyType
|
|
from typing import Mapping
|
|
|
|
from mini_db_mcp.domain.domain_handler import ToolHandler
|
|
from mini_db_mcp.domain.runtime.query_runtime import QueryRuntime
|
|
|
|
|
|
class QueryHandler:
|
|
domain_name = "query"
|
|
|
|
def __init__(self, runtime: QueryRuntime) -> None:
|
|
self._handlers: Mapping[str, ToolHandler] = MappingProxyType(
|
|
{"execute_query": runtime.execute_query}
|
|
)
|
|
|
|
@property
|
|
def handler_names(self) -> frozenset[str]:
|
|
return frozenset(self._handlers)
|
|
|
|
def resolve_handler(self, name: str) -> ToolHandler | None:
|
|
return self._handlers.get(name)
|