fix(server): keep upstream resource annotations and _meta when proxying - #2469
Open
ayaangazali wants to merge 1 commit into
Open
fix(server): keep upstream resource annotations and _meta when proxying#2469ayaangazali wants to merge 1 commit into
ayaangazali wants to merge 1 commit into
Conversation
ResourceDefinition carries annotations and _meta, and both survive local registration. The proxy mount copies only title, description and mimeType, and ProxyResource does not even declare the other two, so an upstream resource loses its client hints and its extension metadata the moment the server is composed with use(). Both are documented on the resource descriptor and neither has a framework-derived counterpart, unlike a tool's _meta.ui.* keys, which the server computes from view and visibility. There is nothing to collide with here, so forwarding is a straight passthrough. Prompts need no equivalent change: PromptDefinition has no _meta.
@mcp-use/agent
@mcp-use/cli
@mcp-use/client
create-mcp-use-app
@mcp-use/inspector
mcp-use
@mcp-use/tunnel
commit: |
Contributor
TypeScript Conformance (current head)Runner: Score: 2006/2012 passed (6 expected failures, 0 unexpected failures, 4 expected warnings, 0 unexpected warnings)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
ResourceDefinitioncarriesannotationsand_meta(resources.ts:28and:36), and both survive local registration. The proxy mount copies only three fields (mcp-proxy.ts:405):ProxyResourcedoes not even declare the other two, so they are dropped at the introspection boundary. The moment a server is composed withuse(), its upstream resources lose their client hints and their extension metadata fromresources/list, with nothing reported.Driving
mountProxyConnectionwith an upstream resource that has both, the mounted definition comes back as{ name: 'docs_guide', uri }and nothing else.Why this one is a straight passthrough
Both fields are documented on the resource descriptor and neither has a framework-derived counterpart. That is not true of a tool's
_meta, where the server computes_meta.ui.*fromviewandvisibilityand those derived values take precedence over colliding entries. There is no such derivation for resources, so there is nothing to collide with and no precedence question to answer.Prompts need no equivalent change:
PromptDefinitionhas no_meta.The tool case, deliberately not in this PR
Proxied tools drop
_metathe same way, andProxyTooldoes not declare it either. I left that out because it is a policy question rather than a bug fix: forwarding upstream_metaverbatim would let an upstream set framework-owned_meta.ui.*keys, includingvisibility, on a tool this server re-exposes. That wants your call on whether to pass it through, or to forward everything except the framework-owned namespace. Happy to send that separately once you say which.Test
Added to
tests/proxy.test.ts, which already exercisesmountProxyConnectionwith a fake host. On the unfixed source it fails withexpected { name: 'docs_guide', …(1) } to match object { annotations: { …(2) }, …(1) }.Validation
From
libraries/typescript/packages/server:vitest run— 476 passed, 44 files.tsc --noEmit,eslint,prettier --check— clean.Monorepo preflight — 0 failing packages.
Summary by cubic
Fixes proxied resources losing their
annotationsand_metafields when composed throughuse().ProxyResourcenow declares and forwards these fields from upstream resources._metais intentionally left unchanged; forwarding upstream_meta.ui.*would conflict with server-computed values.Written for commit 94131b9. Summary will update on new commits.