Coverage for src/ecnl/adapters/inbound/tools/teams.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.14.2, created at 2026-06-28 08:19 +0000

1"""Team and club tools.""" 

2 

3import logging 

4 

5from mcp.server.fastmcp import FastMCP 

6 

7from ....application.service import ECNLService 

8from ....ports.inbound import Authorizer 

9from ..formatters import _fmt_clubs, _fmt_teams 

10from ._base import _READ_ANNOTATIONS, _safe_call_authorized 

11 

12logger = logging.getLogger(__name__) 

13 

14 

15def register_team_tools(mcp: FastMCP, service: ECNLService, authorizer: Authorizer) -> None: 

16 """Register the team/club tools on ``mcp``.""" 

17 

18 @mcp.tool(annotations=_READ_ANNOTATIONS) 

19 async def get_teams(flight_id: int) -> str: 

20 """Get the teams competing in a flight. 

21 

22 Returns each team's ID, name, and head coach. Use a team ID with 

23 get_team_schedule. Get the flight ID from get_event_overview. 

24 

25 Args: 

26 flight_id: Flight ID from get_event_overview. 

27 """ 

28 logger.info("tool=get_teams flight_id=%r", flight_id) 

29 return await _safe_call_authorized(authorizer, "get_teams", service.get_teams(flight_id), _fmt_teams) 

30 

31 @mcp.tool(annotations=_READ_ANNOTATIONS) 

32 async def get_clubs(event_id: int) -> str: 

33 """Get the clubs participating in an event. 

34 

35 Returns each club's ID, name, and location. 

36 

37 Args: 

38 event_id: Numeric event ID (e.g. 3933). 

39 """ 

40 logger.info("tool=get_clubs event_id=%r", event_id) 

41 return await _safe_call_authorized(authorizer, "get_clubs", service.get_clubs(event_id), _fmt_clubs)