Skip to content

feat(mcp): publish resource list change events#32478

Open
Nomadcxx wants to merge 1 commit into
anomalyco:devfrom
Nomadcxx:rama/mcp-resource-notifications
Open

feat(mcp): publish resource list change events#32478
Nomadcxx wants to merge 1 commit into
anomalyco:devfrom
Nomadcxx:rama/mcp-resource-notifications

Conversation

@Nomadcxx

Copy link
Copy Markdown
Contributor

Issue for this PR

Refs #28567

Type of change

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

What does this PR do?

Adds the first small slice of MCP resource notification support.

When an MCP server advertises resources, opencode now registers a handler for notifications/resources/list_changed and publishes a typed mcp.resources.changed event with the server name.

This gives clients/UI/plugin code a clean signal to refresh resource lists without polling or treating MCP-originated updates as user messages.

I intentionally kept this to list-change notifications only. notifications/resources/updated should come in a follow-up with explicit subscribe/unsubscribe behaviour, otherwise opencode would be handling resource updates it never chose to watch.

How did you verify your code works?

Added an MCP lifecycle test for a resource-only MCP server. The test triggers the mocked ResourceListChangedNotificationSchema handler and verifies a mcp.resources.changed event is emitted.

Ran:

bun test --timeout 30000 test/mcp/lifecycle.test.ts --only-failures
bun run typecheck
bun test --timeout 30000 test/mcp --only-failures

Checklist

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

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found two potentially related PRs that address similar MCP resource functionality:

  1. PR feat(mcp): support resource list change notifications #31396 - feat(mcp): support resource list change notifications

  2. PR feat(mcp): support resource update notifications #31398 - feat(mcp): support resource update notifications

These PRs appear to be addressing the same feature area around MCP resource notifications. PR #31396 in particular seems most likely to be a duplicate since it covers the exact same "resource list change notifications" functionality that PR #32478 is implementing.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant