-
Notifications
You must be signed in to change notification settings - Fork 279
fix(client): use type-only imports for @modelcontextprotocol/sdk types #157
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
fix(client): use type-only imports for @modelcontextprotocol/sdk types #157
Conversation
Change value imports to `import type` syntax for SDK types to prevent bundlers from including Node.js server code in browser builds. When bundling @mcp-ui/client for pure browser environments, the @modelcontextprotocol/sdk's server-side code (which imports Express) was being included due to the import chain, causing "require is not defined" errors at runtime. Since the SDK is only used for TypeScript types (not runtime values), using `import type` ensures these imports are stripped at compile time and don't trigger bundling of the SDK's server-side modules. Files changed: - UIResourceRendererWC.tsx: EmbeddedResource type - metadataUtils.ts: Resource type - processResource.ts: EmbeddedResource, Resource types - UIResourceRenderer.unmocked.test.tsx: EmbeddedResource type 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
idosal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thans @RazvanRotaru !
…er/v5.16.3) (2025-12-18) ### Bug Fixes * **client:** use type-only imports for @modelcontextprotocol/sdk types ([#157](#157)) ([d84cb3e](d84cb3e)) * trigger TS release ([e28d1f6](e28d1f6)) * update adapter to latest MCP Apps spec ([#163](#163)) ([e342034](e342034)) * update MCP Apps adapter mimetype ([#162](#162)) ([c91e533](c91e533)) * update ui/message to pass an array ([#167](#167)) ([80cf222](80cf222))
|
🎉 This PR is included in version 5.16.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
…/v5.17.1...client/v5.18.0-alpha.1) (2025-12-18) ### Bug Fixes * **client:** use type-only imports for @modelcontextprotocol/sdk types ([#157](#157)) ([d84cb3e](d84cb3e)) * revert externalUrl adapter for compatibility ([#159](#159)) ([3c5289a](3c5289a)) * trigger TS release ([e28d1f6](e28d1f6)) * update adapter to latest MCP Apps spec ([#163](#163)) ([e342034](e342034)) * update MCP Apps adapter mimetype ([#162](#162)) ([c91e533](c91e533)) * update ui/message to pass an array ([#167](#167)) ([80cf222](80cf222)) ### Features * **client:** expose MCP request handlers and AppBridge ref ([3cf3c37](3cf3c37)) * **client:** make Client optional with onReadResource alternative ([fece80e](fece80e)) * use ext-apps branch with setter-based MCP forwarding handlers ([a312e52](a312e52))
|
🎉 This PR is included in version 5.18.0-alpha.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
…nt/v5.17.2) (2025-12-20) ### Bug Fixes * **client:** use type-only imports for @modelcontextprotocol/sdk types ([#157](#157)) ([d84cb3e](d84cb3e)) * revert externalUrl adapter for compatibility ([#159](#159)) ([3c5289a](3c5289a)) * trigger TS release ([e28d1f6](e28d1f6)) * update adapter to latest MCP Apps spec ([#163](#163)) ([e342034](e342034)) * update MCP Apps adapter mimetype ([#162](#162)) ([c91e533](c91e533)) * update ui/message to pass an array ([#167](#167)) ([80cf222](80cf222))
|
🎉 This PR is included in version 5.17.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Change value imports to
import typesyntax for SDK types to prevent bundlers from including Node.js server code in browser builds.When bundling @mcp-ui/client for pure browser environments, the @modelcontextprotocol/sdk's server-side code (which imports Express) was being included due to the import chain, causing "require is not defined" errors at runtime.
Since the SDK is only used for TypeScript types (not runtime values), using
import typeensures these imports are stripped at compile time and don't trigger bundling of the SDK's server-side modules.Files changed:
🤖 Generated with Claude Code