Skip to content

MCP Apps: Open created issue/PR link via host open-link capability#2593

Merged
mattdholloway merged 2 commits into
mainfrom
feature/open-created-link-in-browser
Jun 2, 2026
Merged

MCP Apps: Open created issue/PR link via host open-link capability#2593
mattdholloway merged 2 commits into
mainfrom
feature/open-created-link-in-browser

Conversation

@mattdholloway
Copy link
Copy Markdown
Contributor

What

When a user creates or updates an issue/PR via the MCP App form, the success view shows a link to the result. Clicking it now opens the URL in the user's browser via the host's ui/open-link capability, instead of relying on a plain target="_blank" anchor.

Why

MCP Apps render inside a sandboxed iframe, where ordinary target="_blank" navigation can be blocked by the host. In those hosts, clicking the success link did nothing. The MCP Apps spec provides ui/open-link precisely so an app can ask the host to open an external URL.

How

  • The success-view links in issue-write and pr-write now call openLink(url) on click (preventDefault + host request). openLink was already exposed by useMcpApp (sends ui/open-link).
  • useMcpApp.openLink now also falls back to window.open when the host denies the request (result.isError), in addition to the existing fallback when no app connection is present.
  • The href is retained so right-click / copy-link and native fallback still work, and the handler no-ops when the URL is unavailable ("#").

Notes

  • No server-side changes; UI-only.
  • Type-checks and builds clean (tsc --noEmit, npm run build). No UI test suite exists in this package.
  • Host must advertise the openLinks capability for the in-browser open; otherwise the window.open fallback applies.

The success views for issue-write and pr-write rendered a plain anchor
to the created/updated issue or PR. MCP Apps run in a sandboxed iframe
where target="_blank" navigation may be blocked, so clicking the link
did nothing in some hosts.

Route the click through the host's ui/open-link capability (already
exposed by useMcpApp as openLink), which asks the host to open the URL
in the user's browser. The hook now also falls back to window.open when
the host denies the request, in addition to the existing no-app
fallback. The href is retained so right-click/copy and native fallback
still work.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mattdholloway mattdholloway marked this pull request as ready for review June 2, 2026 11:40
@mattdholloway mattdholloway requested a review from a team as a code owner June 2, 2026 11:40
Copilot AI review requested due to automatic review settings June 2, 2026 11:40
@mattdholloway mattdholloway changed the title Open created issue/PR link via host open-link capability Apps: Open created issue/PR link via host open-link capability Jun 2, 2026
@mattdholloway mattdholloway changed the title Apps: Open created issue/PR link via host open-link capability MCP Apps: Open created issue/PR link via host open-link capability Jun 2, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the MCP App success-view links (issue-write / pr-write) to open the created/updated Issue/PR URL via the host’s ui/open-link capability (with a browser fallback), which is important for MCP Apps rendered in sandboxed iframes where plain anchor navigation can be blocked.

Changes:

  • Route success-view link clicks through useMcpApp().openLink(url) (preventing default anchor navigation).
  • Extend useMcpApp.openLink to fall back to window.open when the host denies the open-link request (result.isError).
  • Keep href attributes for copy-link / right-click behavior.
Show a summary per file
File Description
ui/src/hooks/useMcpApp.ts Adds a fallback to window.open when app.openLink returns an error result.
ui/src/apps/pr-write/App.tsx Wires openLink into the PR success link click handler to use host open-link capability.
ui/src/apps/issue-write/App.tsx Wires openLink into the issue success link click handler to use host open-link capability.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Comment thread ui/src/apps/pr-write/App.tsx
Comment thread ui/src/apps/issue-write/App.tsx
When the success-view link URL was unavailable ("#"), the click handler
returned before calling e.preventDefault(), so the anchor's default
target="_blank" navigation still ran and could open a stray blank tab.
Call preventDefault() first, then no-op when the URL is unavailable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment thread ui/src/hooks/useMcpApp.ts
Comment on lines +109 to 115
const result = await app.openLink({ url });
// The host may deny the request (e.g. blocked domain or user cancelled).
// Fall back to a direct window.open so the link still works.
if (result?.isError) {
window.open(url, "_blank", "noopener,noreferrer");
}
},
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if this is needed Copilot

@mattdholloway mattdholloway merged commit 2a5d38a into main Jun 2, 2026
22 checks passed
@mattdholloway mattdholloway deleted the feature/open-created-link-in-browser branch June 2, 2026 13:36
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.

3 participants