Skip to content

feat: add hostInfo and hostCapabilities props to AppRenderer#179

Merged
idosal merged 7 commits intomainfrom
copilot/add-hostinfo-hostcapabilities-props
Apr 23, 2026
Merged

feat: add hostInfo and hostCapabilities props to AppRenderer#179
idosal merged 7 commits intomainfrom
copilot/add-hostinfo-hostcapabilities-props

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 6, 2026

Implementation Complete ✅

  • Add hostInfo and hostCapabilities optional props to AppRendererProps interface
  • Update AppRenderer to use provided hostInfo prop instead of hardcoded values
  • Update AppRenderer to use provided hostCapabilities prop instead of hardcoded values
  • Add tests for the new hostInfo prop
  • Add tests for the new hostCapabilities prop
  • Export McpUiHostCapabilities type from index.ts for convenience
  • Run linting and tests to validate changes
  • Add documentation for the new props
  • Address code review feedback (remove trailing whitespace)
  • Security scan - No vulnerabilities found
  • All tests pass (310 tests)
  • Add AppBridge cleanup in useEffect to prevent memory leaks
  • Fix documentation example to define sandboxUrl

Summary

Successfully implemented hostInfo and hostCapabilities props for the AppRenderer component with proper cleanup handling.

Latest Changes:

  • Added proper AppBridge cleanup in useEffect to prevent message listener accumulation when dependencies change
  • Added close() mock to tests for proper cleanup testing
  • Fixed documentation example to inline define sandboxUrl for copy-pastable code

Testing:
✅ 35 AppRenderer tests passing
✅ Linting clean
✅ Build successful

Original prompt

This section details on the original issue you should resolve

<issue_title>AppRenderer: Add hostInfo and hostCapabilities props</issue_title>
<issue_description>## Problem

The AppRenderer component currently hardcodes hostInfo and capabilities when creating the internal AppBridge:

const bridge = new AppBridge(
  client ?? null,
  {
    name: 'MCP-UI Host',  // Hardcoded
    version: '1.0.0',     // Hardcoded
  },
  {
    openLinks: {},
    serverTools: serverCapabilities?.tools,
    serverResources: serverCapabilities?.resources,
  },
);

This means MCP apps receive generic host information in McpUiInitializeResult instead of the actual host application's identity and capabilities.

Use Case

We're integrating @mcp-ui/client into goose and we'd like MCP apps to know they're running in goose and what capabilities are available:

  • hostInfo.name: "goose" (not "MCP-UI Host")
  • hostInfo.version: goose's actual version
  • hostCapabilities: goose-specific capabilities (e.g., sampling, logging)

Proposed Solution

Add optional hostInfo and hostCapabilities props to AppRendererProps:

interface AppRendererProps {
  // ... existing props ...
  
  /** Host application identification (name and version). Defaults to { name: 'MCP-UI Host', version: '1.0.0' } */
  hostInfo?: { name: string; version: string };
  
  /** Host capabilities to advertise to the MCP app */
  hostCapabilities?: McpUiHostCapabilities;
}

Workaround

Currently, we could use AppFrame + AppBridge directly for full control, but AppRenderer is much more convenient for common use cases.

Related

This would allow hosts to properly identify themselves per the MCP UI spec's McpUiInitializeResult type.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 6, 2026 21:21
Co-authored-by: idosal <18148989+idosal@users.noreply.github.com>
Co-authored-by: idosal <18148989+idosal@users.noreply.github.com>
Co-authored-by: idosal <18148989+idosal@users.noreply.github.com>
Copilot AI changed the title [WIP] Add hostInfo and hostCapabilities props to AppRenderer Add hostInfo and hostCapabilities props to AppRenderer Feb 6, 2026
Copilot AI requested a review from idosal February 6, 2026 21:25
@idosal idosal marked this pull request as ready for review February 6, 2026 23:46
Copilot AI review requested due to automatic review settings February 6, 2026 23:46
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 enhances the TypeScript client SDK’s AppRenderer so host applications can provide real host identity (hostInfo) and explicitly control advertised capabilities (hostCapabilities), instead of relying on hardcoded defaults and implicit derivation.

Changes:

  • Added hostInfo and hostCapabilities props to AppRenderer with defaults matching the previous behavior.
  • Re-exported Implementation and McpUiHostCapabilities types from @mcp-ui/client for consumer convenience.
  • Added tests and documentation updates covering default and custom prop behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
sdks/typescript/client/src/components/AppRenderer.tsx Adds hostInfo / hostCapabilities props and uses them when constructing AppBridge.
sdks/typescript/client/src/index.ts Re-exports Implementation and McpUiHostCapabilities types for easier consumption.
sdks/typescript/client/src/components/__tests__/AppRenderer.test.tsx Adds unit tests for default vs custom hostInfo and hostCapabilities.
docs/src/guide/mcp-apps.md Documents the new props and provides an example for customizing host identity/capabilities.

Comment on lines 384 to +389
createBridge();

return () => {
mounted = false;
};
}, [client]);
}, [client, hostInfo, hostCapabilities]);
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The AppBridge is recreated whenever client, hostInfo, or hostCapabilities change, but the effect cleanup only flips mounted to false and does not tear down the previous bridge/connection. With hostInfo/hostCapabilities commonly passed as object literals, this can lead to repeated bridge re-creation and lingering transports/event handlers. Please add a proper cleanup that disposes the previous bridge connection (and avoid unnecessary re-creates by ensuring these deps are stable or memoized).

Copilot uses AI. Check for mistakes.
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.

Fixed in commit 9e6d54e. Added proper cleanup that calls bridge.close() in the useEffect cleanup function to dispose the previous bridge connection when dependencies change. Also stored the bridge reference locally in the effect to ensure cleanup happens correctly.

Comment on lines +544 to +551
<AppRenderer
client={client}
toolName={toolName}
sandbox={{ url: sandboxUrl }}
hostInfo={hostInfo}
hostCapabilities={hostCapabilities}
onOpenLink={async ({ url }) => window.open(url)}
/>
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The example uses sandbox={{ url: sandboxUrl }} but sandboxUrl is not defined in the snippet, which makes the docs example non-copy-pastable. Consider defining sandboxUrl (e.g., new URL(...)) in the example or inlining it, consistent with the earlier AppRenderer example in this guide.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

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.

Fixed in commit 9e6d54e. Changed the example to inline define the sandbox URL: sandbox={{ url: new URL('http://localhost:8765/sandbox_proxy.html') }} to match the earlier example in the guide.

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

@aharvard aharvard left a comment

Choose a reason for hiding this comment

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

thanks LGTM

@aharvard
Copy link
Copy Markdown
Contributor

@idosal can we get this up in 7.1? TYSM!

@idosal
Copy link
Copy Markdown
Collaborator

idosal commented Apr 21, 2026

@idosal can we get this up in 7.1? TYSM!

Sure, I'll do it today. Thanks for the reminder!

@idosal idosal changed the title Add hostInfo and hostCapabilities props to AppRenderer feat: add hostInfo and hostCapabilities props to AppRenderer Apr 23, 2026
@idosal idosal merged commit 87e2436 into main Apr 23, 2026
13 checks passed
@idosal idosal deleted the copilot/add-hostinfo-hostcapabilities-props branch April 23, 2026 07:57
@aharvard
Copy link
Copy Markdown
Contributor

hey @idosal, sry to bother again! It looks like the merge commit to main failed the release step: https://github.com/MCP-UI-Org/mcp-ui/actions/runs/24823858027/job/72654919151

github-actions Bot pushed a commit that referenced this pull request May 1, 2026
…7.1.0) (2026-05-01)

### Features

* add hostInfo and hostCapabilities props to AppRenderer ([#179](#179)) ([87e2436](87e2436))
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

🎉 This PR is included in version 7.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AppRenderer: Add hostInfo and hostCapabilities props

5 participants