feat: add DM and file attachment MCP tools #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "7-add-dm-and-file-attachment-tools-to-grou"
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
Add four new MCP tools wrapping the groupme-sdk DirectMessagesMixin and FilesMixin, bringing the total tool count from 8 to 12. Depends on groupme-sdk#8 merging first (SDK already installed from feature branch for development).
Changes
src/groupme_mcp/tools/direct_messages.py-- new module withsend_dmandlist_dm_chatstoolssrc/groupme_mcp/tools/files.py-- new module withupload_fileandget_upload_statustools (group resolved by name)src/groupme_mcp/tools/__init__.py-- register new tool modules inregister_all_tools()tests/conftest.py-- patchget_clientand_resolve_groupin new modulestests/test_direct_messages.py-- 8 tests covering send_dm and list_dm_chatstests/test_files.py-- 8 tests covering upload_file and get_upload_statusReview Checklist
Test Plan
ruff formatandruff checkcleanRelated Notes
Related
Closes #7
QA Review -- PR #8
Pattern Compliance
..servermatch existing pattern (_error_response,_ok,get_client,mcp,_resolve_group)@mcp.tool()decorator on all four functionsAnnotated[..., Field(description=...)]on all parameterstry/except Exceptionwith_error_response(exc)for all toolsstr(JSON) on all tools_resolve_groupused for group-scoped tools (files.py), not used for user-scoped tools (direct_messages.py) -- correctTool Registration
__init__.pyregisters both new modules in alphabetical orderTest Coverage
get_clientin both new modules_resolve_groupinfiles_mod(the only new module that uses it)SDK Alignment
send_dm(recipient_id, text)matches SDKDirectMessagesMixin.send_dmsignaturelist_chats(page, per_page)matches SDKDirectMessagesMixin.list_chatssignatureupload_file(group_id, file_path, content_type)matches SDKFilesMixin.upload_filesignatureget_upload_status(group_id, job_id)matches SDKFilesMixin.get_upload_statussignatureNits
Dependency Note
groupme-sdk#8is documented in PR body and review checklist. Merge order: SDK first, then this PR.VERDICT: APPROVED
PR #8 Review
DOMAIN REVIEW
Tech stack: Python 3.12+ / FastMCP / groupme-sdk / pytest / Pydantic Field annotations
Pattern compliance: Both new tool modules (
direct_messages.py,files.py) follow the established pattern fromgroups.py,members.py, andmessages.pyexactly:from ..server import _error_response, _ok, get_client, mcp(plus_resolve_groupwhere needed)@mcp.tool()decorator withAnnotated[..., Field(description=...)]parameter styletry/except Exception -> _error_response(exc)error handling_ok(...)response wrappingdirect_messages.pycorrectly imports onlyget_client(no_resolve_group) since DMs are user-scoped, not group-scopedfiles.pycorrectly imports_resolve_groupsince file operations are group-scopedRegistration:
__init__.pyregisters both new modules alphabetically in the existing import list.noqa: F401comments present.conftest patching:
get_clientpatched in both new modules._resolve_grouppatched infiles_modonly (notdm_mod), which is correct sincedirect_messages.pydoes not use_resolve_group.Test coverage: 16 new tests across 2 files (8 each):
test_direct_messages.py: happy path, HTTP error, generic error forsend_dm; formatted output, pagination params, empty list, HTTP error, generic error forlist_dm_chatstest_files.py: happy path, content type passthrough, file not found, HTTP error, generic error forupload_file; happy path, HTTP error, generic error forget_upload_statusCoverage is thorough -- happy path, edge cases, and error handling all represented.
PEP compliance:
from __future__ import annotationspresent in all modules. Type hints on all parameters viaAnnotated[...]. Docstrings on all public functions (PEP 257).str | Noneunion syntax (PEP 604). Clean.Security: No hardcoded credentials.
file_pathinupload_fileis an MCP tool parameter consumed by agents with local filesystem access -- path traversal is not a concern in this context. The SDK handles file I/O and raisesFileNotFoundErrorwhich is properly caught.BLOCKERS
None.
NITS
No pagination clamping on
list_dm_chats:list_messagesclampslimitto[1, 100]viamax(1, min(limit, 100)), butlist_dm_chatspassespage/per_pagedirectly to the SDK without bounds checking. Not a blocker since the GroupMe API handles invalid values server-side, but it is a pattern inconsistency. Consider addingper_page = max(1, min(per_page, 100))for consistency.Branch name truncated: Branch
7-add-dm-and-file-attachment-tools-to-grouis cut off (should begroupme-mcpor similar). Cosmetic only -- does not affect functionality.SDK dependency ordering: PR body notes "Merge groupme-sdk#8 first" as a dependency with an unchecked box. Confirm the SDK PR is merged and the package published to Forgejo PyPI before merging this PR.
SOP COMPLIANCE
7-add-dm-and-file-attachment-tools-to-grou-> issue #7)Closes #7)PROCESS OBSERVATIONS
groupme-sdk#8) must be resolved before merge. Cross-repo dependency is documented in the PR body -- good practice.VERDICT: APPROVED