|
75 | 75 |
|
76 | 76 | logger = logging.getLogger(__name__) |
77 | 77 |
|
| 78 | + |
| 79 | +def _warn_if_mcp_apps_dropped( |
| 80 | + requested: bool, |
| 81 | + capabilities: dict | None, |
| 82 | + session_id: str, |
| 83 | +) -> None: |
| 84 | + """Log a warning when ``enable_mcp_apps=True`` was requested but the runtime |
| 85 | + did not advertise ``capabilities.ui.mcpApps`` in the response. |
| 86 | +
|
| 87 | + The runtime silently drops the opt-in when its ``MCP_APPS`` feature flag |
| 88 | + (or ``COPILOT_MCP_APPS=true`` env override) is unset, so without this |
| 89 | + warning a consumer trying to use MCP Apps would see no error -- just tools |
| 90 | + that never expose ``_meta.ui.resourceUri``. |
| 91 | + """ |
| 92 | + if not requested: |
| 93 | + return |
| 94 | + ui = (capabilities or {}).get("ui") or {} |
| 95 | + if not ui.get("mcpApps"): |
| 96 | + logger.warning( |
| 97 | + "Session %s: enable_mcp_apps was requested but the runtime did " |
| 98 | + "not advertise capabilities.ui.mcpApps. The runtime's MCP_APPS " |
| 99 | + "feature flag or COPILOT_MCP_APPS=true environment override is " |
| 100 | + "likely unset; the MCP Apps surface is unavailable for this session.", |
| 101 | + session_id, |
| 102 | + ) |
| 103 | + |
78 | 104 | # ============================================================================ |
79 | 105 | # Connection Types |
80 | 106 | # ============================================================================ |
@@ -1684,6 +1710,7 @@ async def create_session( |
1684 | 1710 | session._workspace_path = response.get("workspacePath") |
1685 | 1711 | capabilities = response.get("capabilities") |
1686 | 1712 | session._set_capabilities(capabilities) |
| 1713 | + _warn_if_mcp_apps_dropped(enable_mcp_apps, capabilities, actual_session_id) |
1687 | 1714 | except BaseException as exc: |
1688 | 1715 | with self._sessions_lock: |
1689 | 1716 | self._sessions.pop(actual_session_id, None) |
@@ -2039,6 +2066,7 @@ async def resume_session( |
2039 | 2066 | session._workspace_path = response.get("workspacePath") |
2040 | 2067 | capabilities = response.get("capabilities") |
2041 | 2068 | session._set_capabilities(capabilities) |
| 2069 | + _warn_if_mcp_apps_dropped(enable_mcp_apps, capabilities, session_id) |
2042 | 2070 | except BaseException as exc: |
2043 | 2071 | with self._sessions_lock: |
2044 | 2072 | self._sessions.pop(session_id, None) |
|
0 commit comments