Add MCP resources and resource templates list endpoints

What does this MR do and why?

Implements the missing resources/list and resources/templates/list JSON-RPC endpoints in the GitLab MCP Server and advertises the resources capability (subscribe: false, listChanged: false) during the initialize handshake.

Previously, MCP clients such as Cline that automatically query resources/templates/list or resources/list upon connecting received a 404 Method not found (-32601) error and failed to initialize the MCP server connection. Returning empty resources and resourceTemplates arrays in accordance with the MCP 2025-06-18 Server Resources specification allows these clients to connect cleanly.

Closes #584258 (closed)

References

How to set up and validate locally

  1. Send a POST /api/v4/mcp request with method: "initialize" and verify result.capabilities.resources returns {"subscribe": false, "listChanged": false}.
  2. Send a POST /api/v4/mcp request with method: "resources/list" and verify result returns {"resources": []} with 200 OK.
  3. Send a POST /api/v4/mcp request with method: "resources/templates/list" and verify result returns {"resourceTemplates": []} with 200 OK.
  4. Run the specs:
    bundle exec rspec spec/lib/api/mcp/handlers/list_resources_spec.rb \
      spec/lib/api/mcp/handlers/list_resource_templates_spec.rb \
      spec/requests/api/mcp/handlers/list_resources_spec.rb \
      spec/requests/api/mcp/handlers/list_resource_templates_spec.rb \
      spec/requests/api/mcp/handlers/initialize_request_spec.rb \
      spec/requests/api/mcp/base_spec.rb

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading
Loading