feat: add Update Environment MCP App#10260
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new visual interface for selecting the active Firebase project within a workspace, including an HTML template, a TypeScript application for logic, and a resource definition to serve the UI. Several critical issues were identified: the HTML template incorrectly references a .ts file instead of the compiled .js file, and the firebase_get_environment tool is expected to return structured data but currently returns a string, which will break the 'Current Context' display. Additionally, there are multiple violations of the repository style guide, specifically the use of any types and deeply nested logic, along with a UI bug where safe area insets could overwrite necessary default padding.
| if (ctx.styles?.css?.fonts) applyHostFonts(ctx.styles.css.fonts); | ||
| if (ctx.safeAreaInsets) { | ||
| const { top, right, bottom, left } = ctx.safeAreaInsets; | ||
| document.body.style.padding = `${top}px ${right}px ${bottom}px ${left}px`; |
There was a problem hiding this comment.
Setting document.body.style.padding directly from safeAreaInsets will overwrite the default 24px padding defined in the CSS (line 27). If the safe area insets are zero, the UI will lose its intended margins. It is better to ensure a minimum padding that respects both the safe area and the design's spacing.
| document.body.style.padding = `${top}px ${right}px ${bottom}px ${left}px`; | |
| document.body.style.padding = `${Math.max(top, 24)}px ${Math.max(right, 24)}px ${Math.max(bottom, 24)}px ${Math.max(left, 24)}px`; |
|
|
||
| // Fetch projects on load | ||
| const result = await app.callServerTool({ name: "firebase_list_projects", arguments: {} }); | ||
| const data = result.structuredContent as any; |
There was a problem hiding this comment.
Avoid using any for the tool result data. Use the FirebaseProject interface to maintain type safety as per the style guide (line 38).
| const data = result.structuredContent as any; | |
| const data = result.structuredContent as { projects: FirebaseProject[] } | undefined; |
References
- Never use any or unknown as an escape hatch. Define proper interfaces/types or use type guards. (link)
69b87cf to
a5b2a79
Compare
| <div id="status-box"></div> | ||
| </div> | ||
| </div> | ||
| <script type="module" src="mcp-app.ts"></script> |
There was a problem hiding this comment.
I know you dismissed this feedback, but how does this get compiled?
| const statusBox = document.getElementById("status-box") as HTMLDivElement; | ||
|
|
||
| let projects: any[] = []; | ||
| let filteredProjects: any[] = []; |
There was a problem hiding this comment.
Could we strongly type this and line 15?
| import * as path from "path"; | ||
| import * as fs from "fs/promises"; | ||
|
|
||
| export const RESOURCE_MIME_TYPE = "application/vnd.mcp.ext-app+html"; |
There was a problem hiding this comment.
nit: we probably want to share this between mcp apps
| renderProjects(); | ||
| showStatus("Projects loaded successfully.", "success"); | ||
| setTimeout(() => { | ||
| if (statusBox.className === "status success") statusBox.style.display = "none"; |
There was a problem hiding this comment.
Not sure I follow here. Should this be a setInterval instead?
maneesht
left a comment
There was a problem hiding this comment.
Lg, but I'd rather we replace the any in this
0be62c8 to
5d8e23c
Compare
### Description - Adds mcpapps experiment flag to src/experiments.ts. - Adds applyAppMeta helper function to src/mcp/util.ts to conditionally add UI metadata. - Adds unit tests for applyAppMeta in src/mcp/util.spec.ts. ### Scenarios Tested - Unit tests passed. - Build succeeds.
### Description - Fixes applyAppMeta to preserve existing metadata. - Moves mcpapps flag to be grouped with other MCP experiments. - Removes as any in util.spec.ts by importing CallToolResult. ### Scenarios Tested - Build succeeds. - Lint passes for modified files (ignoring pre-existing warnings). - Unit tests for applyAppMeta pass.
Adds support for returning structured content from tools, which is used by MCP Apps to pass complex data to the host. Also updates the resource index. - Verified build and file changes.
### Description Adds the Update Environment MCP App, allowing users to switch projects and directories from the UI. ### Scenarios Tested - Verified build and file changes.
5d8e23c to
9cb1bff
Compare
* feat: add SSE mode support for MCP server ### Description Adds support for running the MCP server in SSE (HTTP) mode, in addition to the default Stdio transport. This allows clients to connect over network or via tools that support SSE. ### Scenarios Tested - Started server in SSE mode and verified log output. * fix: add progressToken to McpContext interface to fix build error ### Description Fixes a type error where progressToken was not defined on McpContext. ### Scenarios Tested - Verified build succeeds. * refactor: address PR comments on SSE support ### Description Addresses PR comments by: - Moving inline require calls to top-level imports. - Replacing any types with specific interfaces or unknown. ### Scenarios Tested - Verified build succeeds. * fix: address remaining review comments on SSE support ### Description - Reverts accidental GA4 tracking change in mcpListResources. - Replaces console.error with this.logger calls for better logging. - Changes default server binding from 0.0.0.0 to 127.0.0.1 for security. ### Scenarios Tested - Verified build succeeds. * style: lint and format fixes for SSE support ### Description - Applied auto-formatting fixes from npm run format. ### Scenarios Tested - Verified build succeeds. * feat: add infrastructure for MCP Apps (#10259) * feat: add infrastructure for MCP Apps ### Description Adds support for returning structured content from tools, which is used by MCP Apps to pass complex data to the host. Also updates the resource index. ### Scenarios Tested - Verified build and file changes. * fix: resolve build errors and address review comments on infra ### Description - Removes imports and registry entries for UI resources that are not yet available in this branch (login, update_environment, deploy, init). - Replaces as any in toContent with an intersection type for better type safety. ### Scenarios Tested - Verified build succeeds. * chore: avoid any for sessionId in SSE transport ### Description - Defines a local interface extending SSEServerTransport to avoid using when accessing . ### Scenarios Tested - Build succeeds. - Lint passes for modified lines. * feat: change sse flag to mode flag and fix build errors ### Description - Replaced boolean flag with string flag (defaults to 'stdio'). - Added validation for to accept only 'stdio' or 'sse'. - Fixed build errors by adding to interface and removing missing resource. ### Scenarios Tested - Build succeeds. - Lint passes with no new errors. * feat: add Update Environment MCP App (#10260) * feat: add mcpapps experiment flag and helper ### Description - Adds mcpapps experiment flag to src/experiments.ts. - Adds applyAppMeta helper function to src/mcp/util.ts to conditionally add UI metadata. - Adds unit tests for applyAppMeta in src/mcp/util.spec.ts. ### Scenarios Tested - Unit tests passed. - Build succeeds. * chore: address PR comments on experiments and util ### Description - Fixes applyAppMeta to preserve existing metadata. - Moves mcpapps flag to be grouped with other MCP experiments. - Removes as any in util.spec.ts by importing CallToolResult. ### Scenarios Tested - Build succeeds. - Lint passes for modified files (ignoring pre-existing warnings). - Unit tests for applyAppMeta pass. * feat: add infrastructure for MCP Apps Adds support for returning structured content from tools, which is used by MCP Apps to pass complex data to the host. Also updates the resource index. - Verified build and file changes. * feat: add Update Environment MCP App ### Description Adds the Update Environment MCP App, allowing users to switch projects and directories from the UI. ### Scenarios Tested - Verified build and file changes. * fix: resolve compilation errors in mcp-update-env-app * fix: resolve remaining lint errors in mcp-update-env-app * refactor: extract app MIME type shared constant * added changelog'
Adds the Update Environment MCP App. (Chained off #10259)