Skip to content

feat: add readServerResource() and listServerResources() api to App#470

Merged
ochafik merged 2 commits intomodelcontextprotocol:mainfrom
Avcharov:feat/app-resource-api
Mar 6, 2026
Merged

feat: add readServerResource() and listServerResources() api to App#470
ochafik merged 2 commits intomodelcontextprotocol:mainfrom
Avcharov:feat/app-resource-api

Conversation

@Avcharov
Copy link
Contributor

Introduced methods enable apps to read individual resources and discover available resources from the MCP server via host proxy without need to use app.request

Changes:

  • Add readServerResource() method to App class for reading resources by URI
  • Add listServerResources() method to App class for resource discovery
  • Add type-checked examples in app.examples.ts
  • Add JSDoc with @example tags linking to companion examples

Example enhancements (video-resource-server):

  • Replace data URIs with Object URLs + URL.revokeObjectURL() to prevent memory leaks
  • Implement ResourceTemplate list callback for dynamic resource enumeration
  • Add video picker UI with resource discovery and selection
  • Add 'Change Video' button to switch between videos
  • Refactor duplicate resource-fetching logic into shared fetchAndPlayVideo() helper

CSS improvements (video-resource-server):

  • Migrate to host style variables (--color-, --spacing-, --font-*)
  • Use light-dark() function for theme-aware colors
  • Add proper focus-visible outlines for accessibility

Motivation and Context

Apps had no convenient way to access MCP resources. Reading resources required calling the low-level app.request method directly with raw protocol types.

How Has This Been Tested?

basic-host, Claude desktop

Breaking Changes

None. Both methods are additive.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Demo

Screen.Recording.2026-02-18.at.09.41.20.mov

@Avcharov Avcharov marked this pull request as draft February 18, 2026 09:10
@Avcharov
Copy link
Contributor Author

@antonpk1 @ochafik can you make a quick a look at this proto please?

@ochafik ochafik added the enhancement New feature or request label Feb 20, 2026
@Avcharov Avcharov marked this pull request as ready for review February 23, 2026 07:39
Copy link
Contributor

@ochafik ochafik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Avcharov !

Could you please add tests in src/app-bridge.test.ts ? (use AppBridge.{onreadresource,onlistresources} just as is done to test callServerTool)

@Avcharov Avcharov force-pushed the feat/app-resource-api branch from ea8ddfb to 88ff060 Compare February 24, 2026 18:27
@Avcharov
Copy link
Contributor Author

Avcharov commented Feb 24, 2026

@ochafik

Noticed that we dont run examples on workspace local version of ext-apps (*), is there any reason preventing us doing it?
If no - let me know, i can take it on me :)

@ochafik
Copy link
Contributor

ochafik commented Mar 6, 2026

Hey @Avcharov , sorry for the delay + thanks again for your PR!

Noticed that we dont run examples on workspace local version of ext-apps (*), is there any reason preventing us doing it?

Should be fixed by #504

@ochafik ochafik merged commit 4f9a7eb into modelcontextprotocol:main Mar 6, 2026
6 of 13 checks passed
ochafik added a commit that referenced this pull request Mar 6, 2026
Follow-up to #470. Matches MCP SDK Client.listResources(params?) signature
so callers can omit the empty {} for the common case.

Also reflows a line in app-bridge.test.ts that prettier flagged.
ochafik added a commit that referenced this pull request Mar 6, 2026
Follow-up to #470. Matches MCP SDK Client.listResources(params?) signature
so callers can omit the empty {} for the common case.

Also reflows a line in app-bridge.test.ts that prettier flagged.
ochafik added a commit that referenced this pull request Mar 6, 2026
* chore: bump ext-apps to 1.1.3

Changes since 1.1.2:
- fix: autoResize reporting viewport height when content is taller (#525)
- fix: remove duplicate --color-text-ghost from McpUiStyleVariableKey (#523)
- fix: examples servers' npm run start:stdio (#507)
- pdf-server: ignore client roots by default (#510)
- docs: add Security documentation section and SEO improvements (#524)
- docs: add MCP client configuration examples to CONTRIBUTING.md (#508, #526)
- docs: use apps.extensions.modelcontextprotocol.io domain for docs URLs (#499)
- docs: add SECURITY.md with GitHub Security Advisories guidance (#472)

* chore: switch to minor bump 1.2.0 (new APIs in #470)
@ALLAUTOPARTSGROUP
Copy link

ALLAUTOPARTSGROUP commented Mar 8, 2026

Introduced methods enable apps to read individual resources and discover available resources from the MCP server via host proxy without need to use app.request

Changes:

  • Add readServerResource() method to App class for reading resources by URI
  • Add listServerResources() method to App class for resource discovery
  • Add type-checked examples in app.examples.ts
  • Add JSDoc with @example tags linking to companion examples

Example enhancements (video-resource-server):

  • Replace data URIs with Object URLs + URL.revokeObjectURL() to prevent memory leaks
  • Implement ResourceTemplate list callback for dynamic resource enumeration
  • Add video picker UI with resource discovery and selection
  • Add 'Change Video' button to switch between videos
  • Refactor duplicate resource-fetching logic into shared fetchAndPlayVideo() helper

CSS improvements (video-resource-server):

  • Migrate to host style variables (--color-, --spacing-, --font-*)
  • Use light-dark() function for theme-aware colors
  • Add proper focus-visible outlines for accessibility

Motivation and Context

Apps had no convenient way to access MCP resources. Reading resources required calling the low-level app.request method directly with raw protocol types.

How Has This Been Tested?

basic-host, Claude desktop

Breaking Changes

None. Both methods are additive.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Demo

Screen.Recording.2026-02-18.at.09.41.20.mov

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants