GitLab MCP server runs a tools/call that has no JSON-RPC id and answers 202 with no result

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

Both GitLab MCP endpoints, /api/v4/mcp and /api/v4/orbit/mcp, run a tools/call whose body has no JSON-RPC id, then answer 202 Accepted with an empty body. The tool runs and the client never gets the result.

The Orbit endpoint also accepts an id of any JSON type. A boolean, a float or an array gets a normal result with that id echoed back. MCP allows only a string or an integer, and the main endpoint already rejects the others.

Every MCP protocol version says a request must have an id. A body without one is a notification, and a server that can't accept a notification must answer with an HTTP error status. This is true for every protocol version the server supports, not only 2026-07-28.

The id here is the JSON-RPC envelope field that pairs a request with its response. It is not a tool argument: a create call through save_merge_request leaves out merge_request_iid but still sends an envelope id.

This doesn't appear to happen in production. Recent production logs show no tools/call without an id, so no client we know of sends one. The severity is low, and the fix stops a client bug from running a tool with no reply.

Steps to reproduce

  1. Create an OAuth or personal access token with the mcp scope.

  2. POST this body to /api/v4/mcp, with no id:

    {"jsonrpc":"2.0","method":"tools/call","params":{"name":"save_note","arguments":{"project_id":"<project path>","merge_request_iid":<iid>,"body":"no id"}}}
  3. Open the merge request.

Example Project

None needed. Any project with a merge request.

What is the current bug behavior?

The server answers 202 Accepted with an empty body, and the note is created.

What is the expected correct behavior?

The server answers 400 Bad Request with a JSON-RPC -32600 (Invalid Request) error that has no id, and the tool does not run.

Relevant logs and/or screenshots

Why it happens, and the spec text
  • The tools/call branch dispatches to Handlers::CallTool whether or not the body has an id (base.rb:288-297).
  • format_jsonrpc_response then answers 202 with no body because params[:id] is nil (base.rb:201-218).
  • tools/list, initialize and ping without an id also run and answer 202. They have no side effects.
  • Orbit's invoke_basic_handler runs the handler whether or not the body has an id (orbit/mcp.rb:59-72), and its format_jsonrpc_response answers 202 the same way (#L87). Orbit queries are read-only.
  • Orbit declares id with no type (orbit/mcp.rb:105-106). The main endpoint uses types: [Integer, String] with an identity coerce_with (base.rb:238).

Spec text:

  • Base protocol, 2025-06-18, 2025-11-25 and the draft: "Requests MUST include a string or integer ID." Notifications "MUST NOT include an ID", and "The receiver MUST NOT send a response."
  • Streamable HTTP, 2025-11-25: "If the server cannot accept the input, it MUST return an HTTP error status code (e.g., 400 Bad Request). The HTTP response body MAY comprise a JSON-RPC error response that has no id." The draft keeps the same rule, and adds that it "defines no client-to-server notifications over Streamable HTTP".

Output of checks

Reproduced with request specs on master at 61a2beb6587f:

  • /api/v4/mcp: status=202 body="", and the merge request's note count went from 0 to 1.
  • /api/v4/orbit/mcp: a tools/call with no id got status=202 body="". With "id": true, 1.5 or [1], it got 200 and the same id back.

Possible fixes

  1. Before dispatch in lib/api/mcp/base.rb and ee/lib/api/orbit/mcp.rb: when params[:id] is nil and the method doesn't start with notifications/, answer 400 with -32600 and no id. notifications/initialized and notifications/cancelled keep their 202.
  2. Give Orbit's id the same types: [Integer, String] and coerce_with as base.rb:238, and drop its rubocop:disable. Other types then get 400 with -32600.

Constraints

  • Applies to every protocol version, legacy and modern.
  • An unknown method that doesn't start with notifications/ and has no id answers 400 instead of today's 202.

Open questions

  1. Ship behind a feature flag? No client can use today's response, because it never gets a result.

Patch release information for backports

Not requested.

Edited by 🤖 GitLab Bot 🤖