Skip to content

fix(resources): forward request context to ui:// resource reads - #141

Merged
jussi-sa merged 3 commits into
mainfrom
fix/ui-resources-forward-request-context
Oct 16, 2026
Merged

jussi-sa merged 3 commits into
mainfrom
fix/ui-resources-forward-request-context

Conversation

@jussi-sa

Copy link
Copy Markdown
Contributor

What

Register all MCP resources through BaseResource.installTo() using a new installResources() in resourceRegistry.ts. This removes the registerAppResource wrapper in src/index.ts, which called readCallback(new URL(uri), {}) and dropped the request's extra.

Why

With {} as extra, MapPreviewUIResource never received authInfo.token. It always fell back to MAPBOX_ACCESS_TOKEN to mint its preview token, even when a caller token was present. installTo() passes extra through unchanged. UI resources already declare RESOURCE_MIME_TYPE, which was the only thing the wrapper added.

How to test

npx vitest run test/resources/resourceRegistry.test.ts. The tests read every resource through a client that sends authInfo. Two of them fail on main's wrapper behaviour: the authInfo forwarding test and the preview-token account test.

🤖 Generated with Claude Code

The ui:// registration wrapper in src/index.ts called readCallback with
{} instead of the request's extra, so MapPreviewUIResource never saw the
caller's authInfo and always minted from MAPBOX_ACCESS_TOKEN. Register
all resources through BaseResource.installTo() instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jussi-sa
jussi-sa requested a review from a team as a code owner October 13, 2026 17:18
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jussi-sa
jussi-sa marked this pull request as draft October 13, 2026 17:24
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jussi-sa
jussi-sa marked this pull request as ready for review October 13, 2026 18:24
@jussi-sa jussi-sa closed this Oct 14, 2026
@jussi-sa jussi-sa reopened this Oct 16, 2026
@jussi-sa
jussi-sa merged commit 0d707c9 into main Oct 16, 2026
3 checks passed
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