Skip to content

Conversation

@idosal
Copy link
Collaborator

@idosal idosal commented Oct 10, 2025

Initial adapters infra with AppsSDK as a first use case.

Based on the work of @yannj-fr.

@idosal idosal requested review from Copilot and liady October 10, 2025 00:13
Copy link
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 introduces an adapters infrastructure for MCP-UI with Apps SDK as the first implementation. The adapters enable MCP-UI widgets to work in platform-specific environments (like ChatGPT) by translating the standard MCP-UI postMessage protocol to platform-specific APIs.

Key changes include:

  • Added comprehensive adapter configuration types and infrastructure
  • Implemented Apps SDK adapter with runtime bundling system
  • Added adapter integration to the createUIResource function
  • Created extensive test coverage and example applications

Reviewed Changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sdks/typescript/server/src/utils.ts Added wrapHtmlWithAdapters function and adapter imports
sdks/typescript/server/src/types.ts Added AdaptersConfig and AppsSdkAdapterOptions type definitions
sdks/typescript/server/src/index.ts Integrated adapter wrapping into createUIResource and exported adapter types
sdks/typescript/server/src/adapters/index.ts Main adapters module export
sdks/typescript/server/src/adapters/appssdk/types.ts Comprehensive type definitions for Apps SDK adapter
sdks/typescript/server/src/adapters/appssdk/index.ts Apps SDK adapter public exports
sdks/typescript/server/src/adapters/appssdk/adapter.ts Adapter script generation and configuration injection
sdks/typescript/server/src/adapters/appssdk/adapter-runtime.ts Complete Apps SDK adapter implementation with message handling
sdks/typescript/server/src/adapters/appssdk/adapter-runtime.bundled.ts Auto-generated bundled runtime script
sdks/typescript/server/src/adapters/appssdk/README.md Comprehensive documentation for the adapter architecture
sdks/typescript/server/src/tests/adapters/appssdk-adapter.test.ts Extensive test suite for adapter functionality
sdks/typescript/server/src/tests/adapters/adapter-integration.test.ts Integration tests for adapter with createUIResource
sdks/typescript/server/scripts/bundle-adapter.js Build script for bundling TypeScript adapter to injectable JavaScript
sdks/typescript/server/package.json Added esbuild dependency and bundle scripts
sdks/typescript/server/README.md Documentation for platform adapters usage
examples/appssdk-adapter-demo/example.ts Complete example implementations showing adapter usage
examples/appssdk-adapter-demo/README.md Example documentation and usage guide
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

sdks/typescript/server/src/adapters/appssdk/adapter-runtime.ts:1

  • The event listener callback function is unnecessarily cast to EventListener. The arrow function should be typed properly or the cast should be removed if the types match.
/**

@@ -0,0 +1,375 @@
// This file is auto-generated by scripts/bundle-adapter.js
// Do not edit directly - modify adapter-runtime.ts instead
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding a build timestamp or hash to the auto-generated file header to help track when it was last built and detect stale builds.

Suggested change
// Do not edit directly - modify adapter-runtime.ts instead
// Do not edit directly - modify adapter-runtime.ts instead
// Build timestamp: 2024-06-10T00:00:00Z
// Build hash: <BUILD_HASH_PLACEHOLDER>

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 10, 2025

Deploying mcp-ui with  Cloudflare Pages  Cloudflare Pages

Latest commit: 85af176
Status: ✅  Deploy successful!
Preview URL: https://91e038c9.mcp-ui.pages.dev
Branch Preview URL: https://feat-adapters.mcp-ui.pages.dev

View logs

idosal and others added 4 commits October 10, 2025 01:23
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@idosal idosal requested a review from Copilot October 10, 2025 07:57
Copy link
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

Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

examples/appssdk-adapter-demo/example.ts:1

  • Using innerHTML with template literals containing user data can lead to XSS vulnerabilities. Consider using textContent or properly sanitizing the data before inserting it into the DOM.
/**

return htmlContent;
}

const wrappedHtml = htmlContent;
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

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

The variable wrappedHtml is assigned but never modified. Consider removing this variable and using htmlContent directly in the return statements to improve code clarity.

Copilot uses AI. Check for mistakes.
if (this.originalPostMessage) {
try {
const originalPostMessage = this.originalPostMessage;
(window.parent as Window & { postMessage: typeof originalPostMessage }).postMessage = originalPostMessage;
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

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

The type assertion is complex and duplicated. Consider extracting this to a variable or helper function for better readability and maintainability.

Copilot uses AI. Check for mistakes.

try {
// Replace parent.postMessage with our interceptor
(window.parent as Window & { postMessage: typeof postMessageInterceptor }).postMessage = postMessageInterceptor;
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

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

This type assertion is similar to the one in the uninstall method. Consider creating a helper function to handle these postMessage assignments safely.

Copilot uses AI. Check for mistakes.
idosal and others added 3 commits October 10, 2025 09:01
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@idosal
Copy link
Collaborator Author

idosal commented Oct 13, 2025

Replaced by #127

@idosal idosal closed this Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant