Skip to content

Expose live resource subscriptions via a hook #1325

@cliffhall

Description

@cliffhall

Background

ResourcesScreen renders a subscriptions: InspectorResourceSubscription[] prop showing which resources the user has subscribed to and when each was last updated. InspectorClient tracks subscriptions internally and dispatches notifications/resources/updated notifications, but there's no hook that surfaces the live list to React.

#1244's App.tsx passes subscriptions={[]} because no such hook exists yet. The result: onSubscribeResource / onUnsubscribeResource callbacks fire correctly, but the UI never reflects the subscription state — buttons feel no-op from the user's perspective even though the server-side subscriptions are real.

Scope

  • Add a state manager — core/mcp/state/resourceSubscriptionsState.ts — that subscribes to the InspectorClient's resource-subscription events and maintains an InspectorResourceSubscription[]. Updates the lastUpdated field when notifications/resources/updated arrives for a subscribed URI.
  • Add a useResourceSubscriptions(client, state) hook in core/react/.
  • Wire App.tsx to pass the real list through.

Acceptance criteria

  • Subscribing to a resource adds an entry visible in the Resources screen.
  • Unsubscribing removes the entry.
  • notifications/resources/updated updates the lastUpdated timestamp of the matching subscription.

Related

Metadata

Metadata

Assignees

Labels

v2Issues and PRs for v2

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions