Coverage for src/epl/adapters/inbound/tools/pulselive.py: 83%

12 statements  

« prev     ^ index     » next       coverage.py v7.15.3, created at 2026-08-05 10:11 +0000

1"""Pulselive-backed MCP tools — richer per-player registry data.""" 

2 

3import logging 

4 

5from mcp.server.fastmcp import FastMCP 

6 

7from ....application.service import EPLService 

8from ....ports.inbound import Authorizer 

9from ..formatters import _fmt_pulselive_players 

10from ._base import _READ_ANNOTATIONS, _safe_call_authorized 

11 

12logger = logging.getLogger(__name__) 

13 

14 

15def register_pulselive_tools(mcp: FastMCP, service: EPLService, authorizer: Authorizer) -> None: 

16 """Register the Pulselive-backed tool set on ``mcp``.""" 

17 

18 @mcp.tool(annotations=_READ_ANNOTATIONS) 

19 async def get_players(season_year: int | None = None, limit: int = 50) -> str: 

20 """Get Premier League player registrations from the Pulselive/Opta feed. 

21 

22 Richer than ESPN's roster: carries the Opta player id, shirt number, 

23 detailed positional label (e.g. "Centre-back" vs "Right-back"), 

24 current-club affiliation, nationality, date of birth, and loan flag. 

25 Defaults to the most recent completed season — the current season may 

26 not have full registrations until the transfer window closes. 

27 

28 Args: 

29 season_year: Currently ignored (see roadmap). Reserved for a future 

30 per-year season lookup. 

31 limit: Maximum number of players to return (default 50, max 500). 

32 """ 

33 logger.info("tool=get_players season_year=%r limit=%r", season_year, limit) 

34 return await _safe_call_authorized( 

35 authorizer, 

36 "get_players", 

37 service.get_players(season_year, limit), 

38 _fmt_pulselive_players, 

39 )