"""MCP tool: read_transcript -- read transcript entries for a turn range.""" from __future__ import annotations from debatemind.models.observation import TranscriptEntry def read_transcript( start_turn: int, end_turn: int, transcript: list[TranscriptEntry], ) -> dict: """Return transcript entries for the specified turn range. The range is clamped to valid bounds so out-of-range values are handled gracefully rather than raising errors. Args: start_turn: First turn to include (inclusive). end_turn: Last turn to include (inclusive). transcript: Full list of transcript entries. Returns: A dict with an "entries" key containing a list of dicts, each with turn, actor, action_type, and content fields. """ # Clamp to valid bounds start_turn = max(0, start_turn) end_turn = max(start_turn, end_turn) entries = [ { "turn": e.turn, "actor": e.actor, "action_type": e.action_type, "content": e.content, } for e in transcript if start_turn <= e.turn <= end_turn ] return {"entries": entries}