feat: MCP channel notifications + image path/URL support#15
Open
xzneozx96 wants to merge 3 commits into199-biotechnologies:mainfrom
Open
feat: MCP channel notifications + image path/URL support#15xzneozx96 wants to merge 3 commits into199-biotechnologies:mainfrom
xzneozx96 wants to merge 3 commits into199-biotechnologies:mainfrom
Conversation
… as channel notifications Implements the MCP channel contract so incoming WhatsApp messages are pushed into the Claude Code session automatically via notifications/claude/channel. Changes: - Declare claude/channel experimental capability in initialize response - Add server instructions telling Claude how to handle inbound messages - Spawn a writer thread that owns stdout for immediate async writes - Spawn SSE forwarder thread that connects to /api/events on the daemon, parses inbound events, and pushes notifications/claude/channel with chat_jid, sender, message_id, timestamp, is_from_me, chat_type as meta - Auto-reconnects with exponential backoff on daemon restart README: add Claude Code ~/.claude.json config snippet and systemd user service setup for persistent daemon auto-start on boot.
- mcp.rs: whatsrust_image now accepts 'path' (file or URL) in addition to inline base64 'data'; resolves to base64 before forwarding to API - api.rs: /api/image (and all media endpoints) handle https:// paths by fetching the URL via ureq; local-path mode unchanged (loopback-only) - Cargo.toml: add ureq = '3' as direct dependency
- clamp() instead of .max().min() chains (api.rs) - next_back() for DoubleEndedIterator::last (api.rs) - Default impl for BridgeMetrics (bridge.rs) - Entry API instead of contains_key + insert (bridge.rs) - #[allow] for borrowed_box on BoundedMsgCache::get (bridge.rs) - #[allow(clippy::too_many_arguments)] on send_message_with_preview and handle_outbound (bridge.rs) - Remove needless borrows on get_client_handle calls (bridge.rs) - Remove needless borrow on serde_json::to_value(status) (bridge.rs) - is_empty() companion for AtomicDedupCache::len (dedup.rs) - strip_prefix() instead of manual index slicing (mcp.rs) - #[allow(dead_code)] on extract_image_dimensions (media_utils.rs) - #[allow(clippy::should_implement_trait)] on from_str (outbound.rs) - Collapsible str::replace with char array (outbound.rs) - div_ceil() instead of manual ceil formula (qr.rs) - is_some_and() instead of map_or(false, ...) (storage.rs) - .copied() instead of .map(|s| *s) (main.rs) New tests (mcp.rs): 15 unit tests covering extract_display_text for all content kinds, build_channel_notification metadata and chat_type, and mcp_connect_host wildcard/specific address handling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /api/events) and forwards every inbound WhatsApp message to Claude Code as anotifications/claude/channelnotification — incoming messages arrive in the session automatically without polling. Includes auto-reconnect with exponential backoff.whatsrust_imageMCP tool now accepts apathparameter (local file path orhttps://URL) in addition to inline base64data. The daemon'shandle_mediaendpoint was also updated to support URL fetching directly.Changes
src/mcp.rspath/URL support inwhatsrust_imagehandlersrc/api.rshandle_mediaacceptshttps://URLs — fetches withureq, detects MIME fromContent-TypeCargo.tomlureq = "3"as explicit dependencyREADME.mdpathparameterTest plan
whatsrust_imagewith a local filepath— verify image sendswhatsrust_imagewith anhttps://URL — verify image fetches and sendswhatsrust_imagewith inlinedata(existing behaviour) — verify no regression