Skip to content

feat: handle MCP notifications/message from servers#19928

Closed
hazyhaar wants to merge 2 commits into
anomalyco:devfrom
hazyhaar:feat/mcp-notification-message-handler
Closed

feat: handle MCP notifications/message from servers#19928
hazyhaar wants to merge 2 commits into
anomalyco:devfrom
hazyhaar:feat/mcp-notification-message-handler

Conversation

@hazyhaar
Copy link
Copy Markdown

@hazyhaar hazyhaar commented Mar 29, 2026

Issue for this PR

Closes # N/A - small enhancement, not tied to a specific issue.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Registers a setNotificationHandler for LoggingMessageNotificationSchema in the MCP client watch() function. When an MCP server sends a notifications/message, the handler extracts level and data from the notification params and publishes them as a mcp.message.received bus event.

This matters because MCP servers often need to push events to clients (e.g. a memory vault pushing mission assignments, checkpoint answers, or lifecycle events). Without this, the only option is client-side polling via tool calls. With this handler, servers can push via the standard MCP logging notification and clients receive it in real time.

The change is ~20 lines: one new import, one bus event definition, one notification handler registration alongside the existing ToolListChangedNotificationSchema handler.

How did you verify your code works?

  • Tested with a custom MCP server (context-vault) that sends notifications/message via stdio transport
  • Verified the bus event fires and the log entry appears
  • Verified existing ToolListChangedNotification handling is unaffected

Screenshots / recordings

N/A - no UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

rekram1-node and others added 2 commits March 29, 2026 17:59
Add a setNotificationHandler for LoggingMessageNotificationSchema that
publishes received messages as mcp.message.received bus events. This
enables MCP servers (e.g. context-vault) to push notifications to
OpenCode agents without requiring polling.

The handler extracts level and data from the notification params and
publishes them via the existing Bus infrastructure, making them
available to any subscriber (TUI, agent context, etc.).
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Mar 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@rekram1-node
Copy link
Copy Markdown
Collaborator

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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.

2 participants