MemFlow is designed as a persistent, portable memory layer. One of its most powerful use cases is acting as a Headless Communication Bus between mobile applications and local AI agents.
This document outlines the standard pattern for building a mobile bridge on top of MemFlow.
Connecting a mobile phone to a local IDE agent (like Cursor or Claude Code) traditionally requires:
- Reverse-engineering Chrome DevTools Protocol (CDP) ports.
- Granting broad Accessibility permissions to inject keystrokes (AppleScript/UIAutomation).
- Leaving the IDE window open and in focus.
By using MemFlow as the intermediary, you can completely decouple the mobile UI from the IDE. The agent and the mobile app simply read and write to the same local SQLite database (~/.memflow/memflow.sqlite).
-
Mobile App to MemFlow (Inbox)
- The mobile bridge server receives a message from the phone via HTTP/WebSocket.
- The bridge writes the message to MemFlow using the
ag_bridge/inbox(or custom) namespace. - The entry is tagged with
pendingandmobile.
-
Agent Reads the Inbox
- The local AI agent is equipped with a custom MCP tool (e.g.,
memflow_inbox) or uses the standardmemory_searchtool. - The agent queries MemFlow for entries in the inbox namespace with the
pendingtag. - The agent executes the user's request.
- The local AI agent is equipped with a custom MCP tool (e.g.,
-
Agent Responds (Outbox)
- The agent formulates a response and uses
memory_store(or a custommemflow_replytool) to write to theag_bridge/outboxnamespace. - The response is tagged
unread. - The agent updates the original inbox message, changing its tag from
pendingtoread.
- The agent formulates a response and uses
-
MemFlow to Mobile App
- The mobile bridge server runs a background polling loop (e.g., every 5 seconds).
- It queries the MemFlow database directly for
unreadentries in the outbox. - When found, it broadcasts them to the mobile app via WebSocket and updates their tags to
read.
If you are building a custom MCP server for your agent, it is highly recommended to expose dedicated bridge tools to simplify the LLM's prompt surface:
memflow_inbox: Retrievespendingmessages from the inbox namespace.memflow_ack: Marks specified messages asread.memflow_reply: Writes a new entry to the outbox namespace with theunreadtag.
These tools abstract the raw memory_store and memory_search queries, ensuring the tags and namespaces are always correct.
- Zero IDE Dependency: The agent can run entirely in the background (headless terminal, background service, etc.).
- Reliability: If the mobile app disconnects or the agent crashes, no messages are lost. The MemFlow database retains the exact state.
- Security: No open CDP ports or keystroke injection required. The system is sandboxed to database reads and writes.