fix(eve): resolve MCP connection url from re-imported module at runtime#522
Open
amotarao wants to merge 1 commit into
Open
fix(eve): resolve MCP connection url from re-imported module at runtime#522amotarao wants to merge 1 commit into
amotarao wants to merge 1 commit into
Conversation
The manifest snapshots the URL at build time, so env-driven endpoints (most notably Vercel Services bindings, whose target host is only injected at request time) baked a stale value into the deployed agent. Runtime resolution now prefers the URL produced by the re-imported authored module and falls back to the manifest snapshot when the module omits it. Closes vercel#521. Signed-off-by: Amon Sawamura <amotarao@gmail.com>
Contributor
|
@amotarao is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
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.
Closes #521.
Summary
defineMcpClientConnectionconnections now honor the URL produced by the re-imported authored module at runtime instead of the manifest snapshot captured at build time. Env-driven endpoints — most notably Vercel Services bindings, whose target host is only injected at request time — resolve to the correct URL on cold start.resolveConnectionDefinitionprefersresolvedRecord.urlwhen the re-imported module exports a non-empty string. When it omits or blanksurl, it falls back to the compiled manifest value, so existing static-URL connections are unaffected.connection:<url>secondary source key now uses the runtime URL, matching the key stamped bydefineMcpClientConnectionon the same re-imported module.Authoring stays unchanged — the current shape is enough:
At build the placeholder URL is baked into the manifest; at runtime the module is re-imported with the real binding env in place and its computed URL wins. No new API surface, no new marker on the compiled manifest.
I intentionally did not add the
url: (ctx) => …resolver form proposed in the issue — the reproducer (Vercel Services bindings) is a module-scoped env problem, not a per-caller one, and this fix closes it without expanding the API. Happy to layer the function form on top separately if a per-caller URL use case shows up.Test plan
pnpm typecheckpnpm oxlint --fix/pnpm oxfmtpnpm guard:invariantspnpm test:unit(4381 passed)resolve-connection.test.tscases: runtime URL preferred, manifest fallback when the module blanksurl.