Skip to content

Commit a899bdd

Browse files
committed
feat: add SSE mode support for MCP server (#10258)
* 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'
1 parent 1be7bfe commit a899bdd

14 files changed

Lines changed: 750 additions & 50 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Added 'firebase_deploy' and 'firebase_deploy_status' MCP tools.
2+
- Added SSE mode support to `firebase mcp`. To use it, run `firebase mcp --mode=sse --port=3000`, and connect your client on `http://localhost:3000`.

npm-shrinkwrap.json

Lines changed: 100 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
"@angular-devkit/architect": "^0.1402.2",
186186
"@angular-devkit/core": "^14.2.2",
187187
"@google/events": "^5.1.1",
188+
"@modelcontextprotocol/ext-apps": "^1.3.2",
188189
"@types/archiver": "^6.0.0",
189190
"@types/async-lock": "^1.4.2",
190191
"@types/body-parser": "^1.17.0",

src/bin/mcp.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ Options:
4949
If specified, auto-detection is disabled for other features.
5050
--tools <tools> Comma-separated list of specific tools to enable. Disables
5151
auto-detection entirely.
52+
--mode <mode> Server mode: stdio, sse (defaults to stdio).
53+
--port <port> The port to listen on when running in SSE mode (defaults to 3000).
5254
-h, --help Show this help message.
5355
`;
5456

@@ -58,6 +60,8 @@ export async function mcp(): Promise<void> {
5860
only: { type: "string", default: "" },
5961
tools: { type: "string", default: "" },
6062
dir: { type: "string" },
63+
mode: { type: "string", default: "stdio" },
64+
port: { type: "string", default: "3000" },
6165
"generate-tool-list": { type: "boolean", default: false },
6266
"generate-prompt-list": { type: "boolean", default: false },
6367
"generate-resource-list": { type: "boolean", default: false },
@@ -85,6 +89,11 @@ export async function mcp(): Promise<void> {
8589
}
8690
if (earlyExit) return;
8791

92+
if (values.mode !== "stdio" && values.mode !== "sse") {
93+
console.error("Error: --mode must be either 'stdio' or 'sse'");
94+
process.exit(1);
95+
}
96+
8897
setFirebaseMcp(true);
8998
// Write debug logs to ~/.cache/firebase to avoid polluting the user's project directory.
9099
const mcpLogDir = join(homedir(), ".cache", "firebase");
@@ -103,6 +112,9 @@ export async function mcp(): Promise<void> {
103112
enabledTools,
104113
projectRoot: values.dir ? resolve(values.dir) : undefined,
105114
});
106-
await server.start();
115+
await server.start({
116+
useSSE: values.mode === "sse",
117+
port: values.port ? parseInt(values.port, 10) : undefined,
118+
});
107119
if (process.stdin.isTTY) process.stderr.write(STARTUP_MESSAGE);
108120
}

src/experiments.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ export const ALL_EXPERIMENTS = experiments({
184184
default: false,
185185
public: true,
186186
},
187+
mcpapps: {
188+
shortDescription: "Enables MCP Apps features",
189+
fullDescription: "Enables MCP Apps features, including returning UI resource URIs.",
190+
public: true,
191+
},
187192
fdcift: {
188193
shortDescription: "Enable instrumentless trial for SQL Connect",
189194
default: true,

0 commit comments

Comments
 (0)