Skip to content

Avoid stuck MCP state after stream replacement#31

Open
Fr4nzz wants to merge 1 commit into
toloco:mainfrom
Fr4nzz:fix-mcp-stream-replacement
Open

Avoid stuck MCP state after stream replacement#31
Fr4nzz wants to merge 1 commit into
toloco:mainfrom
Fr4nzz:fix-mcp-stream-replacement

Conversation

@Fr4nzz
Copy link
Copy Markdown

@Fr4nzz Fr4nzz commented May 6, 2026

Summary

  • retry the WhatsApp connection after Disconnected and StreamReplaced events instead of leaving the MCP server permanently not-ready
  • add a serve.lock guard so two whasapo serve processes do not connect with the same WhatsApp session and replace each other's active stream
  • remove stale lock files when the recorded process is no longer running

Why

When Whasapo is used as a stdio MCP server from desktop AI apps, it is possible for multiple serve processes to be launched or left behind. WhatsApp/whatsmeow can then emit StreamReplaced for one process. In practice that server keeps running, but tool calls only return WhatsApp connection lost / WhatsApp is reconnecting until the whole client app is restarted.

This keeps the single WhatsApp Web stream protected and gives the active MCP server a bounded reconnect path for transient disconnect/replacement events.

Test

  • go test ./...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant