Skip to content

fix(client): use type-only imports for @modelcontextprotocol/sdk types#157

Merged
idosal merged 1 commit intoMCP-UI-Org:mainfrom
RazvanRotaru:fix/use-type-only-imports-for-sdk
Dec 10, 2025
Merged

fix(client): use type-only imports for @modelcontextprotocol/sdk types#157
idosal merged 1 commit intoMCP-UI-Org:mainfrom
RazvanRotaru:fix/use-type-only-imports-for-sdk

Conversation

@RazvanRotaru
Copy link
Copy Markdown
Contributor

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

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 <[email protected]>
Copy link
Copy Markdown
Collaborator

@idosal idosal left a comment

Choose a reason for hiding this comment

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

Thans @RazvanRotaru !

@idosal idosal merged commit d84cb3e into MCP-UI-Org:main Dec 10, 2025
8 checks passed
github-actions bot pushed a commit that referenced this pull request Dec 18, 2025
…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))
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 5.16.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Dec 18, 2025
…/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))
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 5.18.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Dec 20, 2025
…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))
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 5.17.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

katherinek727 added a commit to katherinek727/mcp-ui that referenced this pull request Feb 28, 2026
…ver/v5.16.2...server/v5.16.3) (2025-12-18)

### Bug Fixes

* **client:** use type-only imports for @modelcontextprotocol/sdk types ([#157](MCP-UI-Org/mcp-ui#157)) ([4ece399](MCP-UI-Org/mcp-ui@4ece399))
* trigger TS release ([fc8a053](MCP-UI-Org/mcp-ui@fc8a053))
* update adapter to latest MCP Apps spec ([#163](MCP-UI-Org/mcp-ui#163)) ([819cf59](MCP-UI-Org/mcp-ui@819cf59))
* update MCP Apps adapter mimetype ([#162](MCP-UI-Org/mcp-ui#162)) ([e99b306](MCP-UI-Org/mcp-ui@e99b306))
* update ui/message to pass an array ([#167](MCP-UI-Org/mcp-ui#167)) ([ba8afa7](MCP-UI-Org/mcp-ui@ba8afa7))
katherinek727 added a commit to katherinek727/mcp-ui that referenced this pull request Feb 28, 2026
…ent/v5.17.1...client/v5.17.2) (2025-12-20)

### Bug Fixes

* **client:** use type-only imports for @modelcontextprotocol/sdk types ([#157](MCP-UI-Org/mcp-ui#157)) ([4ece399](MCP-UI-Org/mcp-ui@4ece399))
* revert externalUrl adapter for compatibility ([#159](MCP-UI-Org/mcp-ui#159)) ([7a855e2](MCP-UI-Org/mcp-ui@7a855e2))
* trigger TS release ([fc8a053](MCP-UI-Org/mcp-ui@fc8a053))
* update adapter to latest MCP Apps spec ([#163](MCP-UI-Org/mcp-ui#163)) ([819cf59](MCP-UI-Org/mcp-ui@819cf59))
* update MCP Apps adapter mimetype ([#162](MCP-UI-Org/mcp-ui#162)) ([e99b306](MCP-UI-Org/mcp-ui@e99b306))
* update ui/message to pass an array ([#167](MCP-UI-Org/mcp-ui#167)) ([ba8afa7](MCP-UI-Org/mcp-ui@ba8afa7))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants