feat: add list_messages tool for reading group message history #6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "5-add-list-messages-tool"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
list_messagesMCP tool for retrieving GroupMe message history by group namebefore_idand configurablelimit(1-100, default 20)list_messagesSDK method)Changes
pyproject.toml-- bump groupme-sdk dependency from >=0.1.0 to >=0.2.0uv.lock-- updated lockfile reflecting groupme-sdk 0.2.0src/groupme_mcp/tools/messages.py-- addlist_messagestool with name resolution, limit clamping, attachment formattingtests/test_messages.py-- 10 new tests covering default behavior, limit clamping, pagination, attachments, name resolution, and error handlingTest Plan
_resolve_group)Review Checklist
Related
Review: LGTM
Reviewed all 4 changed files (pyproject.toml, uv.lock, messages.py, test_messages.py).
Ready for merge.
PR #6 Review
DOMAIN REVIEW
Tech stack: Python 3.12 / FastMCP / Pydantic / groupme-sdk / pytest
This PR adds a
list_messagesMCP tool tosrc/groupme_mcp/tools/messages.pyand bumpsgroupme-sdkfrom>=0.1.0to>=0.2.0. It also adds auv.lockfile for reproducible builds.Code quality assessment:
Follows existing patterns precisely. The new
list_messagesfunction mirrors the structure ofsend_message(same module),get_group(groups module), and all other tools:_resolve_groupfor name resolution,get_client()for SDK access,_ok()/_error_response()for response formatting. Consistent and clean.Type hints and docstrings. Full PEP 484 type hints via
Annotated[..., Field(...)]on all parameters. Docstring follows PEP 257 and clearly describes behavior, return format, and pagination.Input validation.
limitis clamped to[1, 100]viamax(1, min(limit, 100)). This is correct and tested.before_idisstr | Nonewith a sensible default.group_nameis validated by_resolve_groupwhich raisesValueErroron no-match or ambiguity.Error handling. Broad
except Exceptioncatches everything and delegates to_error_response(), which distinguishesGroupMeHTTPError(with status code) from generic errors. This matches the existing pattern across all tools.Attachment handling. Clean conditional inclusion --
attachmentskey is omitted from output when the list is empty, included when present. This is a good UX choice for MCP consumers.Module docstring updated. Changed from "send messages" to "send and read messages" -- accurate.
No DRY violations. The tool uses shared helpers (
_resolve_group,get_client,_ok,_error_response) consistently. No duplicated auth/security logic.No hardcoded values. Default limit of 20 and max of 100 match the issue acceptance criteria and are reasonable API defaults, not magic numbers.
Test coverage assessment:
10 new tests in
TestListMessagescovering:group_id,limit, andbefore_idare passed correctlybefore_idpass-throughGroupMeHTTPError(HTTP 429) and genericRuntimeErrorThis is thorough. All acceptance criteria from issue #5 are covered by tests.
Dependency change:
groupme-sdk>=0.2.0is required for thelist_messagesSDK method. Theuv.lockaddition ensures reproducible installs. Both are appropriate.BLOCKERS
None.
group_nameresolves through_resolve_group,limitis clamped,before_idis optional string.GroupMeClient()constructor.NITS
Negative limit values: The clamping
max(1, min(limit, 100))handles zero and negatives correctly (they all clamp to 1), but there is no test for a negative value likelimit=-5. Consider adding one for completeness. Non-blocking since the logic is mathematically sound.PR body says "ten new test cases" but the issue acceptance criteria listed specific test requirements. The mapping is clear on inspection but explicitly stating which acceptance criterion each test satisfies would strengthen traceability. Non-blocking.
SOP COMPLIANCE
5-add-list-messages-toolmaps to issue #5)pyproject.toml,uv.lock,messages.py,test_messages.pymodifiedlist_messagesadded, no unrelated changesPROCESS OBSERVATIONS
list_messagesmethod. The dependency chain is clean.VERDICT: APPROVED