Add pagination support to get_comments

- Add page parameter to get_comments (default: 1)
- Parse X-Total-Count header for total comments count
- Parse Link header for next_page indicator
- Update FastMCP tool and CLI server to return pagination metadata

Response now includes total_count and next_page fields to help
clients navigate through paginated comments.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Mammad M.
2026-01-10 00:33:00 +01:00
parent 6265026f57
commit 67d68af1da
4 changed files with 55 additions and 19 deletions

View File

@@ -500,23 +500,28 @@ async def global_search(query: str) -> Dict[str, Any]:
}
@mcp.tool()
async def get_comments(recording_id: str, project_id: str) -> Dict[str, Any]:
async def get_comments(recording_id: str, project_id: str, page: int = 1) -> Dict[str, Any]:
"""Get comments for a Basecamp item.
Args:
recording_id: The item ID
project_id: The project ID
page: Page number for pagination (default: 1). Basecamp uses geared pagination:
page 1 has 15 results, page 2 has 30, page 3 has 50, page 4+ has 100.
"""
client = _get_basecamp_client()
if not client:
return _get_auth_error_response()
try:
comments = await _run_sync(client.get_comments, project_id, recording_id)
result = await _run_sync(client.get_comments, project_id, recording_id, page)
return {
"status": "success",
"comments": comments,
"count": len(comments)
"comments": result["comments"],
"count": len(result["comments"]),
"page": page,
"total_count": result["total_count"],
"next_page": result["next_page"]
}
except Exception as e:
logger.error(f"Error getting comments: {e}")