Coverage for src/ecnl/adapters/inbound/tools/events.py: 100%
16 statements
« prev ^ index » next coverage.py v7.14.2, created at 2026-06-28 08:19 +0000
« prev ^ index » next coverage.py v7.14.2, created at 2026-06-28 08:19 +0000
1"""Event discovery and overview tools."""
3import logging
5from mcp.server.fastmcp import FastMCP
7from ....application.service import ECNLService
8from ....ports.inbound import Authorizer
9from ..formatters import _fmt_event_overview, _fmt_events
10from ._base import _READ_ANNOTATIONS, _safe_call_authorized
12logger = logging.getLogger(__name__)
15def register_event_tools(mcp: FastMCP, service: ECNLService, authorizer: Authorizer) -> None:
16 """Register the event discovery/overview tools on ``mcp``."""
18 @mcp.tool(annotations=_READ_ANNOTATIONS)
19 async def find_events(league: str | None = None, gender: str | None = None, season: str | None = None) -> str:
20 """Find ECNL or ECRL events (conferences) and their event IDs.
22 This is the starting point: it maps a human description to the numeric
23 event IDs every other tool needs. Filter by any combination of league,
24 gender, and season. With no arguments it returns all current events.
26 Args:
27 league: "ECNL" or "ECRL" (the ECNL Regional League). Omit for both.
28 gender: "girls" or "boys". Omit for both.
29 season: Season label like "2025-26". Omit for all seasons present.
30 """
31 logger.info("tool=find_events league=%r gender=%r season=%r", league, gender, season)
32 return await _safe_call_authorized(
33 authorizer, "find_events", service.find_events(league, gender, season), _fmt_events
34 )
36 @mcp.tool(annotations=_READ_ANNOTATIONS)
37 async def get_event_overview(event_id: int) -> str:
38 """Get the divisions and flights for an event.
40 Returns each age-group division and its flights, with the flight ID,
41 flight tier (ECNL/ECRL), and team count. Use the flight ID with
42 get_standings, get_schedule, get_teams, and the RPI tools.
44 Args:
45 event_id: Numeric event ID from find_events (e.g. 3933).
46 """
47 logger.info("tool=get_event_overview event_id=%r", event_id)
48 return await _safe_call_authorized(
49 authorizer, "get_event_overview", service.get_event_overview(event_id), _fmt_event_overview
50 )