feat: add hostInfo and hostCapabilities props to AppRenderer#179
feat: add hostInfo and hostCapabilities props to AppRenderer#179
Conversation
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>
There was a problem hiding this comment.
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
hostInfoandhostCapabilitiesprops toAppRendererwith defaults matching the previous behavior. - Re-exported
ImplementationandMcpUiHostCapabilitiestypes from@mcp-ui/clientfor 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. |
| createBridge(); | ||
|
|
||
| return () => { | ||
| mounted = false; | ||
| }; | ||
| }, [client]); | ||
| }, [client, hostInfo, hostCapabilities]); |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
| <AppRenderer | ||
| client={client} | ||
| toolName={toolName} | ||
| sandbox={{ url: sandboxUrl }} | ||
| hostInfo={hostInfo} | ||
| hostCapabilities={hostCapabilities} | ||
| onOpenLink={async ({ url }) => window.open(url)} | ||
| /> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
|
@idosal can we get this up in 7.1? TYSM! |
Sure, I'll do it today. Thanks for the reminder! |
|
hey @idosal, sry to bother again! It looks like the merge commit to |
|
🎉 This PR is included in version 7.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Implementation Complete ✅
hostInfoandhostCapabilitiesoptional props toAppRendererPropsinterfacehostInfoprop instead of hardcoded valueshostCapabilitiesprop instead of hardcoded valueshostInfoprophostCapabilitiespropMcpUiHostCapabilitiestype from index.ts for convenienceSummary
Successfully implemented
hostInfoandhostCapabilitiesprops for theAppRenderercomponent with proper cleanup handling.Latest Changes:
Testing:
✅ 35 AppRenderer tests passing
✅ Linting clean
✅ Build successful
Original prompt
💡 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.