Skip to content

Conversation

@qchuchu
Copy link
Contributor

@qchuchu qchuchu commented Dec 29, 2025

  • Update CONTRIBUTING.MD for port info + copy env file
  • Update package lock version from npm install
  • Add Request display mode support from MCPApps

Solving #1130


Note

MCP Apps display mode support

  • Implements ui/request-display-mode handling in MCPAppsRenderer, setting displayMode (inline/pip/fullscreen), invoking onRequestPip/onExitPip, falling back to fullscreen on mobile when pip is requested, replying with { mode }, and sending ui/notifications/host-context-changed.
  • Introduces onRequestPip prop and wires dependencies (setDisplayMode, onRequestPip, onExitPip, pipWidgetId) in handlers.

Docs and misc

  • Updates CONTRIBUTING.md: add .env copy step and change client dev port to :5173.
  • Bumps package-lock.json version to 1.4.0.

Written by Cursor Bugbot for commit e9d8498. This will update automatically on new commits. Configure here.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Dec 29, 2025
@dosubot dosubot bot added the enhancement New feature or request label Dec 29, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 29, 2025

Walkthrough

Updates add CONTRIBUTING.md guidance to copy .env.local to .env.development and change the client dev server port reference from 3000 to 5173. In the MCP apps renderer, an optional prop onRequestPip?: (toolCallId: string) => void was added. The JSON-RPC request handler now implements ui/request-display-mode: it derives requestedMode, maps pip to fullscreen on narrow viewports, sets the display mode, invokes onRequestPip or onExitPip on transitions, responds with { mode: actualMode }, and emits ui/notifications/host-context-changed with the new displayMode.


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 40d1fa5 and e9d8498.

📒 Files selected for processing (1)
  • client/src/components/chat-v2/thread/mcp-apps-renderer.tsx
🧰 Additional context used
📓 Path-based instructions (1)
client/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Browser console.* methods are acceptable for client-side debugging in client code

Files:

  • client/src/components/chat-v2/thread/mcp-apps-renderer.tsx
🧬 Code graph analysis (1)
client/src/components/chat-v2/thread/mcp-apps-renderer.tsx (1)
client/src/stores/ui-playground-store.ts (1)
  • DisplayMode (30-30)
🔍 Remote MCP Context7

Additional context found (concise, relevant to code review)

  • Resolved repository to Context7 library ID: /modelcontextprotocol/inspector — MCP Inspector (React + Node.js dev tool). Chosen because name matches repo and it has high reputation and many code snippets, making it the authoritative docs/source for this codebase.

  • Key PR facts (from provided PR context):

    • Adds support for a JSON-RPC method "ui/request-display-mode" in client/src/components/chat-v2/thread/mcp-apps-renderer.tsx:
      • Parses requested mode (default "inline"), maps "pip" → "fullscreen" on mobile (viewportWidth < 768).
      • Calls setDisplayMode(actualMode), responds to caller with { mode: actualMode }.
      • Calls onRequestPip(toolCallId) when actualMode === "pip".
      • Calls onExitPip(toolCallId) when leaving pip to inline/fullscreen if current widget is pip.
      • Notifies host context change via ui/notifications/host-context-changed with new displayMode.
    • Public API change: adds optional prop onRequestPip?: (toolCallId: string) => void to MCPAppsRendererProps (breaking/public API surface change).
    • Commit changed response key from "displayMode" to "mode".
    • Non-code changes: CONTRIBUTING.md updated (copy .env.local → .env.development; dev server port reference changed to 5173) and package-lock updated from npm install.
    • PR references issue [FEATURE] Add Support for ui/request-display-mode messages from MCP Apps implementation #1130 and is targeted at main (feat/add-request-display-mode-support → main). (PR URL: Feat/add request display mode support #1131)

Sources used:

  • Repository resolver: Context7_resolve-library-id (result: /modelcontextprotocol/inspector)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cursor Bugbot
🔇 Additional comments (2)
client/src/components/chat-v2/thread/mcp-apps-renderer.tsx (2)

92-92: Public API addition looks good.

The new onRequestPip callback follows the established pattern for display mode lifecycle management and integrates cleanly with the existing onExitPip handler.


634-660: Display mode handler implementation is sound.

The logic correctly maps pip to fullscreen on narrow viewports, properly sequences state updates before callbacks and notifications, and uses the component's computed viewportWidth (respecting playground device simulation). Response format aligns with the protocol update noted in the commit message.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 72ed5e5 and 865337a.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • CONTRIBUTING.md
  • client/src/components/chat-v2/thread/mcp-apps-renderer.tsx
🧰 Additional context used
📓 Path-based instructions (1)
client/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Browser console.* methods are acceptable for client-side debugging in client code

Files:

  • client/src/components/chat-v2/thread/mcp-apps-renderer.tsx
🧬 Code graph analysis (1)
client/src/components/chat-v2/thread/mcp-apps-renderer.tsx (1)
client/src/stores/ui-playground-store.ts (1)
  • DisplayMode (30-30)
🔍 Remote MCP Context7

Summary of Relevant Context for PR Review

Project Context

The MCP Inspector is a developer tool for testing and debugging MCP servers, featuring a React-based web UI and a Node.js proxy for seamless browser interaction. The project is organized as a monorepo with workspaces, with the client/ directory containing the React frontend built with Vite, TypeScript, and Tailwind CSS, and the server/ directory housing the Express backend.

Development Environment Changes

The CONTRIBUTING.md updates are relevant to the development setup:

  • The development process involves using npm run prettier-check, npm run prettier-fix, npm test, and npm run test:e2e to validate changes before submission.
  • The port change from 3000 to 5173 aligns with standard Vite development server configuration (Vite defaults to port 5173).

Component Context: MCPAppsRenderer

The PR modifies mcp-apps-renderer.tsx to support a new JSON-RPC method ui/request-display-mode. This component is part of the client-side UI rendering system responsible for displaying widgets/apps from MCP servers with different display modes (inline, pip/picture-in-picture, fullscreen).

Key design considerations for the review:

  • The new onRequestPip callback prop enables parent components to respond when child widgets request PIP mode
  • Display mode adaptation logic accounts for mobile constraints (devices <768px cannot display PIP mode, forcing fullscreen instead)
  • The implementation maintains backward compatibility by making the new prop optional
  • The component communicates state changes back to the host via the existing ui/notifications/host-context-changed mechanism

Code Standards

Adhering to code style guidelines includes using TypeScript with proper type annotations, following React functional component patterns with hooks, using Prettier for code formatting, maintaining consistent naming conventions (camelCase for variables/functions, PascalCase for components, kebab-case for filenames), and utilizing Tailwind CSS for styling.,

🔇 Additional comments (2)
CONTRIBUTING.md (1)

47-61: Documentation improvements look good.

The environment file setup instruction and corrected port reference (5173 for Vite) align with standard development practices and improve clarity for contributors.

client/src/components/chat-v2/thread/mcp-apps-renderer.tsx (1)

60-60: Prop addition follows existing patterns.

The new onRequestPip callback is properly typed as optional and consistent with sibling callbacks like onExitPip.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
client/src/components/chat-v2/thread/mcp-apps-renderer.tsx (1)

724-750: Critical: Missing viewportHeight in dependency array.

The handleMessage callback uses viewportHeight (line 527 in the ui/initialize handler) but it's absent from the dependency array. This creates a stale closure where the callback may reference an outdated viewport height value if the device type or custom viewport changes.

🔎 Required fix
  },
  [
    themeMode,
    effectiveDisplayMode,
    locale,
    timeZone,
    platform,
    viewportWidth,
+   viewportHeight,
    deviceCapabilities,
    safeAreaInsets,
    toolName,
    toolMetadata,
    onCallTool,
    onSendFollowUp,
    serverId,
    toolCallId,
    toolInput,
    toolOutput,
    toolState,
    sendResponse,
    sendNotification,
    addUiLog,
    addCspViolation,
    setDisplayMode,
    onRequestPip,
    onExitPip,
    pipWidgetId,
  ],
);
🧹 Nitpick comments (1)
client/src/components/chat-v2/thread/mcp-apps-renderer.tsx (1)

634-660: Handler logic is sound; consider removing redundant notification.

The display mode request handling correctly normalizes pip to fullscreen on narrow viewports and manages state/callbacks appropriately.

However, the explicit notification on lines 656–658 is likely redundant. The useEffect at lines 772–861 already emits host-context-changed notifications whenever effectiveDisplayMode changes. Since setDisplayMode(actualMode) triggers a state update, the useEffect will fire and send a notification automatically. The immediate notification here may result in duplicate messages to the guest.

🔎 Suggested simplification

Remove the explicit notification; let the useEffect handle it:

          sendResponse(id, { displayMode: actualMode });
-
-         sendNotification("ui/notifications/host-context-changed", {
-           displayMode: actualMode,
-         });
          break;

Optionally, extract the viewport breakpoint to a named constant:

+       const MOBILE_VIEWPORT_THRESHOLD = 768;
+
        case "ui/request-display-mode": {
          const requestedMode =
            (params as { mode?: DisplayMode })?.mode || "inline";
-         const isMobile = viewportWidth < 768;
+         const isMobile = viewportWidth < MOBILE_VIEWPORT_THRESHOLD;
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 865337a and 40d1fa5.

📒 Files selected for processing (1)
  • client/src/components/chat-v2/thread/mcp-apps-renderer.tsx
🧰 Additional context used
📓 Path-based instructions (1)
client/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Browser console.* methods are acceptable for client-side debugging in client code

Files:

  • client/src/components/chat-v2/thread/mcp-apps-renderer.tsx
🧬 Code graph analysis (1)
client/src/components/chat-v2/thread/mcp-apps-renderer.tsx (1)
client/src/stores/ui-playground-store.ts (1)
  • DisplayMode (30-30)
🔍 Remote MCP Context7

Additional context found (concise)

  • Resolved repository to Context7 library ID: /modelcontextprotocol/inspector — "MCP Inspector", React + Node.js developer tool for MCP servers.
    • Source reputation: High; Benchmark Score: 79.3; Code snippets: 85. (Useful to prioritize authoritative docs/examples in review.)

No other external file-level diffs or docs were returned by the resolver; further file-level or code-search queries can be run against /modelcontextprotocol/inspector if you want specific changed files, diffs, or usage examples for mcp-apps-renderer.tsx.

🔇 Additional comments (1)
client/src/components/chat-v2/thread/mcp-apps-renderer.tsx (1)

60-60: LGTM - Clean prop addition.

The onRequestPip prop follows the established pattern for display mode callbacks. Type signature and destructuring are correct.

Also applies to: 92-92

@khandrew1
Copy link
Collaborator

khandrew1 commented Dec 29, 2025

Hey there! Thanks for your contribution. Looks good to me, pushing a quick fix to use mode instead of displayMode when sending the response per the spec.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 29, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
client/src/components/chat-v2/thread/mcp-apps-renderer.tsx (1)

724-750: Critical: Dependency array still incomplete from prior review.

While the new dependencies (setDisplayMode, onRequestPip, onExitPip, pipWidgetId) were correctly added, viewportHeight and maxHeight remain missing despite being flagged in the previous review. Both are referenced in the ui/initialize handler (lines 527-528) and their absence creates stale closures—viewport changes won't be reflected in initialization responses sent to the guest UI.

🔎 Add missing dependencies
   [
     themeMode,
     effectiveDisplayMode,
     locale,
     timeZone,
     platform,
     viewportWidth,
+    viewportHeight,
     deviceCapabilities,
     safeAreaInsets,
     toolName,
     toolMetadata,
     onCallTool,
     onSendFollowUp,
     serverId,
     toolCallId,
     toolInput,
     toolOutput,
     toolState,
     sendResponse,
     sendNotification,
     addUiLog,
     addCspViolation,
     setDisplayMode,
     onRequestPip,
     onExitPip,
     pipWidgetId,
+    maxHeight,
   ],
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 40d1fa5 and e9d8498.

📒 Files selected for processing (1)
  • client/src/components/chat-v2/thread/mcp-apps-renderer.tsx
🧰 Additional context used
📓 Path-based instructions (1)
client/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Browser console.* methods are acceptable for client-side debugging in client code

Files:

  • client/src/components/chat-v2/thread/mcp-apps-renderer.tsx
🧬 Code graph analysis (1)
client/src/components/chat-v2/thread/mcp-apps-renderer.tsx (1)
client/src/stores/ui-playground-store.ts (1)
  • DisplayMode (30-30)
🔍 Remote MCP Context7

Additional context found (concise, relevant to code review)

  • Resolved repository to Context7 library ID: /modelcontextprotocol/inspector — MCP Inspector (React + Node.js dev tool). Chosen because name matches repo and it has high reputation and many code snippets, making it the authoritative docs/source for this codebase.

  • Key PR facts (from provided PR context):

    • Adds support for a JSON-RPC method "ui/request-display-mode" in client/src/components/chat-v2/thread/mcp-apps-renderer.tsx:
      • Parses requested mode (default "inline"), maps "pip" → "fullscreen" on mobile (viewportWidth < 768).
      • Calls setDisplayMode(actualMode), responds to caller with { mode: actualMode }.
      • Calls onRequestPip(toolCallId) when actualMode === "pip".
      • Calls onExitPip(toolCallId) when leaving pip to inline/fullscreen if current widget is pip.
      • Notifies host context change via ui/notifications/host-context-changed with new displayMode.
    • Public API change: adds optional prop onRequestPip?: (toolCallId: string) => void to MCPAppsRendererProps (breaking/public API surface change).
    • Commit changed response key from "displayMode" to "mode".
    • Non-code changes: CONTRIBUTING.md updated (copy .env.local → .env.development; dev server port reference changed to 5173) and package-lock updated from npm install.
    • PR references issue #1130 and is targeted at main (feat/add-request-display-mode-support → main). (PR URL: #1131)

Sources used:

  • Repository resolver: Context7_resolve-library-id (result: /modelcontextprotocol/inspector)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cursor Bugbot
🔇 Additional comments (2)
client/src/components/chat-v2/thread/mcp-apps-renderer.tsx (2)

92-92: Public API addition looks good.

The new onRequestPip callback follows the established pattern for display mode lifecycle management and integrates cleanly with the existing onExitPip handler.


634-660: Display mode handler implementation is sound.

The logic correctly maps pip to fullscreen on narrow viewports, properly sequences state updates before callbacks and notifications, and uses the component's computed viewportWidth (respecting playground device simulation). Response format aligns with the protocol update noted in the commit message.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

case "ui/request-display-mode": {
const requestedMode =
(params as { mode?: DisplayMode })?.mode || "inline";
const isMobile = viewportWidth < 768;
Copy link

Choose a reason for hiding this comment

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

Mobile detection uses wrong viewport causing incorrect pip fallback

The mobile detection isMobile = viewportWidth < 768 uses viewportWidth, which defaults to 400 when not in playground mode. Since 400 is always less than 768, all pip mode requests outside the playground will be incorrectly converted to fullscreen. The similar handler in chatgpt-app-renderer.tsx correctly uses window.innerWidth < 768 to check the actual browser viewport instead.

Fix in Cursor Fix in Web

@khandrew1 khandrew1 merged commit 727425c into MCPJam:main Dec 29, 2025
3 checks passed
matteo8p pushed a commit that referenced this pull request Dec 30, 2025
Co-authored-by: Andrew Khadder <54488379+khandrew1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants