feat(mcp): add Streamable HTTP transport support with SSE#9858
feat(mcp): add Streamable HTTP transport support with SSE#9858yakir-shriker wants to merge 4 commits intofirebase:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello @yakir-shriker, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Firebase MCP server by integrating a Streamable HTTP transport. This upgrade moves beyond the existing STDIO transport, providing capabilities for remote connections, real-time data streaming via Server-Sent Events, and improved scalability for cloud environments. The changes include new configuration options, robust security measures, and a clear structure for HTTP-based interactions, making the MCP server more versatile and production-ready. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces Streamable HTTP transport support for the MCP server, which is a significant feature enabling remote connections and better scalability. The implementation is well-structured, with new modules for HTTP transport and comprehensive tests. I've identified a few areas for improvement, including a potential race condition during server shutdown and some redundant code in route handling and argument parsing. Overall, this is a great addition.
Add support for the MCP Streamable HTTP transport protocol alongside the existing STDIO transport. This enables remote MCP connections, production deployments, and horizontal scaling capabilities. Changes: - Add --transport CLI option to choose between 'stdio' and 'streamable-http' - Add --port, --host, and --stateless options for HTTP transport configuration - Create http-transport.ts module using StreamableHTTPServerTransport from MCP SDK - Implement /mcp endpoint for MCP communication (POST/GET/DELETE) - Add /health endpoint for health checks - Add CORS middleware with configurable allowed origins - Add security headers (X-Content-Type-Options, X-Frame-Options, etc.) - Update FirebaseMcpServer.start() to support transport options - Add stop() method for graceful server shutdown - Update server.json with streamable-http transport documentation - Update README.md with HTTP transport usage instructions - Add comprehensive unit tests for HTTP transport
335b973 to
a1f1f5c
Compare
- Fix race condition in close() by awaiting transport.close() before server.close() - Remove redundant DELETE route handler (already handled by app.all) - Remove redundant OR fallbacks in mcp.ts (parseArgs already has defaults)
Summary
This PR adds support for the MCP Streamable HTTP transport protocol alongside the existing STDIO transport, enabling:
Changes
New CLI Options
--transportstdioorstreamable-httpstdio--port8000--host127.0.0.1--statelessfalseNew Files
src/mcp/http-transport.ts- HTTP transport module usingStreamableHTTPServerTransportfrom MCP SDKsrc/mcp/http-transport.spec.ts- Comprehensive unit testsModified Files
src/bin/mcp.ts- Added transport CLI options and validationsrc/mcp/index.ts- Updatedstart()method to support transport options, addedstop()methodsrc/mcp/README.md- Added HTTP transport documentationsrc/mcp/server.json- Added streamable-http transport configurationHTTP Endpoints
POST /mcp- Main MCP endpoint for JSON-RPC requestsGET /mcp- SSE endpoint for server-initiated messagesDELETE /mcp- Session termination (when not in stateless mode)GET /health- Health check endpointSecurity Features
Usage Examples
MCP client configuration for HTTP:
{ "mcpServers": { "firebase": { "transport": { "type": "streamable-http", "url": "http://localhost:8000/mcp" } } } }Test Plan
Dependencies
No new dependencies required - uses existing:
express(already in package.json)@modelcontextprotocol/sdk(already includesStreamableHTTPServerTransport)