Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.8k
MCP Apps: Open created issue/PR link via host open-link capability#2593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -36,11 +36,13 @@ function SuccessView({ | ||
| owner, | ||
| repo, | ||
| submittedTitle, | ||
| openLink, | ||
| }: { | ||
| pr: PRResult; | ||
| owner: string; | ||
| repo: string; | ||
| submittedTitle: string; | ||
| openLink: (url: string) => Promise<void>; | ||
| }) { | ||
| const prUrl = pr.html_url || pr.url || pr.URL || "#"; | ||
| @@ -89,6 +91,14 @@ function SuccessView({ | ||
| href={prUrl} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| onClick={(e) => { | ||
| // MCP Apps run in a sandboxed iframe where a plain anchor may be | ||
| // blocked, so route the click through the host's open-link | ||
| // capability (falls back to window.open). | ||
| e.preventDefault(); | ||
| if (prUrl === "#") return; | ||
| void openLink(prUrl); | ||
| }} | ||
mattdholloway marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| style={{ | ||
| fontWeight: 600, | ||
| fontSize: "14px", | ||
| @@ -126,7 +136,7 @@ function CreatePRApp() { | ||
| const [isDraft, setIsDraft] = useState(false); | ||
| const [maintainerCanModify, setMaintainerCanModify] = useState(true); | ||
| const { app, error: appError, toolInput, callTool, hostContext, setModelContext } = useMcpApp({ | ||
| const { app, error: appError, toolInput, callTool, hostContext, setModelContext, openLink } = useMcpApp({ | ||
| appName: "github-mcp-server-create-pull-request", | ||
| }); | ||
| @@ -199,7 +209,7 @@ function CreatePRApp() { | ||
| if (successPR) { | ||
| return ( | ||
| <AppProvider hostContext={hostContext}> | ||
| <SuccessView pr={successPR} owner={owner} repo={repo} submittedTitle={submittedTitle} /> | ||
| <SuccessView pr={successPR} owner={owner} repo={repo} submittedTitle={submittedTitle} openLink={openLink} /> | ||
| </AppProvider> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -106,7 +106,12 @@ export function useMcpApp({ | ||
| window.open(url, "_blank", "noopener,noreferrer"); | ||
| return; | ||
| } | ||
| await app.openLink({ url }); | ||
| 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"); | ||
| } | ||
| }, | ||
Comment on lines
+109
to
115
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if this is needed Copilot | ||
| [app] | ||
| ); | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.