Skip to content

feat: MCP v2 (draft)#10757

Open
KKonstantinov wants to merge 1 commit into
firebase:mainfrom
KKonstantinov:feature/mcp-v2-migration-draft
Open

feat: MCP v2 (draft)#10757
KKonstantinov wants to merge 1 commit into
firebase:mainfrom
KKonstantinov:feature/mcp-v2-migration-draft

Conversation

@KKonstantinov

@KKonstantinov KKonstantinov commented Jul 2, 2026

Copy link
Copy Markdown

Description

Migrates the Firebase CLI MCP integration (src/mcp/) from the v1 monolithic @modelcontextprotocol/sdk package to the v2 split packages (@modelcontextprotocol/core, @modelcontextprotocol/server, @modelcontextprotocol/server-legacy).

This is a dependency/API migration only — there are no behavioral changes to the MCP server, its tools, resources, or prompts. All call sites were updated to the v2 import paths and renamed symbols; the server still speaks the same protocol over the same transports.

Note

Do not merge this. Goal of PR is to remain open and be updated through beta, stable. See Roadmap section below.

Roadmap

  • Initial alpha draft
  • Review // @mcp-codemod-error comments
  • Update to beta (legacy era MCP on modern interfaces)
  • Update to stable - backwards compatible with legacy era MCP clients; enabling Modern stateless MCP will need maintainers support

Details

Dependency changes (package.json):

Before After
@modelcontextprotocol/sdk ^1.24.0 @modelcontextprotocol/server ^2.0.0-beta.2Server, transports, protocol types
@modelcontextprotocol/core ^2.0.0-beta.2 — runtime Zod schemas (CallToolResultSchema, ListToolsResultSchema)
@modelcontextprotocol/server-legacy ^2.0.0-beta.2 — frozen v1 SSE transport (migration-only)

Import-path changes (v1 → v2):

  • @modelcontextprotocol/sdk/server/index.jsServer from @modelcontextprotocol/server
  • @modelcontextprotocol/sdk/server/stdio.jsStdioServerTransport from @modelcontextprotocol/server/stdio
  • @modelcontextprotocol/sdk/server/sse.jsSSEServerTransport from @modelcontextprotocol/server-legacy/sse
  • @modelcontextprotocol/sdk/types.js → protocol types (CallToolResult, ReadResourceResult, JSONRPCMessage, PromptMessage, …) from @modelcontextprotocol/server
  • runtime *Schema constants → from @modelcontextprotocol/core

API/symbol renames:

  • McpErrorProtocolError

  • ErrorCodeProtocolErrorCode (e.g. ErrorCode.InvalidParamsProtocolErrorCode.InvalidParams)

  • Request-handler registration now uses method-string literals instead of imported request-schema objects:

    v1 schema object v2 method string
    ListToolsRequestSchema "tools/list"
    CallToolRequestSchema "tools/call"
    ListPromptsRequestSchema "prompts/list"
    GetPromptRequestSchema "prompts/get"
    ListResourcesRequestSchema "resources/list"
    ReadResourceRequestSchema "resources/read"
    ListResourceTemplatesRequestSchema "resources/templates/list"
    SetLevelRequestSchema "logging/setLevel"

Files touched (16): src/mcp/index.ts (the bulk of the change — the McpServer wrapper), src/mcp/onemcp/onemcp_server.ts, and 12 one-line import-path swaps across errors.ts, logging-transport.ts, prompt.ts, resource.ts, resources/index.ts, tool.ts, tools/crashlytics/{events,issues,reports}.ts, util.ts, util.spec.ts, util/dataconnect/converter.ts, plus package.json and npm-shrinkwrap.json.

The mechanical portion was produced by the MCP v1→v2 codemod; the imports and method-name strings were then re-formatted to satisfy the repo's Prettier config (multi-line import blocks, double-quoted strings).

Scenarios Tested

  • Typechecktsc --project tsconfig.compile.json (whole project): ✅ 0 errors.
  • Unit testsmocha 'src/mcp/**/*.spec.ts' (the entire migrated area, ~20 spec files): ✅ 149 passing, 0 failing. Covers tool/prompt/resource registration, the onemcp server, JSON-schema conversion, toContent, and feature-availability checks (crashlytics, apptesting, etc.).
  • Linteslint --config .eslintrc.js src/mcp: ✅ 0 errors under the repo's --quiet gate. (Pre-existing style warnings unrelated to this change remain.)

Scope note: tests were run against src/mcp/** (the only code this change touches). The full firebase-tools suite (emulator/integration legs) was not exercised.

Sample Commands

No user-facing commands or flags changed. The MCP server is invoked exactly as before:

# Start the Firebase MCP server (stdio transport)
firebase experimental:mcp

# Verify locally after the migration
npm run test:compile                 # typecheck
npx mocha 'src/mcp/**/*.spec.ts'     # MCP unit tests
npm run lint                         # lint

Notes / follow-ups before merge

  • Dependency spec: the three @modelcontextprotocol/* packages reference the published ^2.0.0-beta.2 releases — the first beta to ship native CommonJS builds, which firebase-tools requires because src/mcp compiles to CJS. npm-shrinkwrap.json was regenerated (npm install) against these. Once v2 reaches a stable 2.0.0, bump the three ranges to ^2.0.0.
  • server-legacy is intentional but temporary: it is a frozen copy of v1's SSE transport shipped only to ease migration. A follow-up should move the SSE endpoint in src/mcp/index.ts to StreamableHTTP from @modelcontextprotocol/server and drop the server-legacy dependency.

@google-cla

google-cla Bot commented Jul 2, 2026

Copy link
Copy Markdown

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.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants