Skip to content

fix(eve): resolve MCP connection url from re-imported module at runtime#522

Open
amotarao wants to merge 1 commit into
vercel:mainfrom
amotarao:feat/mcp-runtime-url
Open

fix(eve): resolve MCP connection url from re-imported module at runtime#522
amotarao wants to merge 1 commit into
vercel:mainfrom
amotarao:feat/mcp-runtime-url

Conversation

@amotarao

@amotarao amotarao commented Jul 3, 2026

Copy link
Copy Markdown

Closes #521.

Summary

defineMcpClientConnection connections 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.

  • resolveConnectionDefinition prefers resolvedRecord.url when the re-imported module exports a non-empty string. When it omits or blanks url, it falls back to the compiled manifest value, so existing static-URL connections are unaffected.
  • The connection:<url> secondary source key now uses the runtime URL, matching the key stamped by defineMcpClientConnection on the same re-imported module.

Authoring stays unchanged — the current shape is enough:

const base = process.env.BACKLOG_MCP_BASE ?? "http://backlog-mcp.invalid";
export default defineMcpClientConnection({
  url: `${base}/mcp`,
  description: "...",
});

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 typecheck
  • pnpm oxlint --fix / pnpm oxfmt
  • pnpm guard:invariants
  • pnpm test:unit (4381 passed)
  • Added two resolve-connection.test.ts cases: runtime URL preferred, manifest fallback when the module blanks url.

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>
@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

@amotarao is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

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.

feat(connections): allow MCP connection url to resolve at runtime (unblock Vercel Services bindings)

1 participant