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
- Issue: #584258 (closed)
- MCP Specification — Listing Resources: https://modelcontextprotocol.io/specification/2025-06-18/server/resources#listing-resources
- MCP Specification — Resource Templates: https://modelcontextprotocol.io/specification/2025-06-18/server/resources#resource-templates
How to set up and validate locally
- Send a
POST /api/v4/mcprequest withmethod: "initialize"and verifyresult.capabilities.resourcesreturns{"subscribe": false, "listChanged": false}. - Send a
POST /api/v4/mcprequest withmethod: "resources/list"and verifyresultreturns{"resources": []}with200 OK. - Send a
POST /api/v4/mcprequest withmethod: "resources/templates/list"and verifyresultreturns{"resourceTemplates": []}with200 OK. - 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.