Add rake task to verify MCP server setup

What does this MR do and why?

Add rake task to verify MCP server setup

The check_oauth_discovery method was using Rails.application.routes.recognize_path to detect the MCP endpoint, which always fails because MCP is a Grape API endpoint mounted as a Rack application, not a Rails route. Replace with a check for the API::Mcp::Base Grape class and its registered routes.

Also add the rake task entry in duo.rake and spec coverage.

Changelog: added EE: true

References

Screenshots or screen recordings

~/dev/gdk/gitlab (lkorbasiewicz-mcpcheck-rake) $ bin/rake 'gitlab:duo:verify_mcp_server_setup'

═══════════════════════════════════════════════════════════════
GitLab MCP Server Setup Verification
═══════════════════════════════════════════════════════════════
This task verifies that the MCP server endpoint (/api/v4/mcp)
is correctly configured and accessible on this instance.

Collecting system information...
  GitLab 18.11.0-pre (EE) — http://gdk.test:3000

✔ License: Ultimate — :mcp_server feature is available.

✔ Duo availability: 'On by default' (duo_features_enabled=true, lock=false)

✔ duo_features_enabled: true

✗ instance_level_ai_beta_features_enabled: false
  The MCP server requires experiment and beta features to be enabled. Enable via: Admin > GitLab Duo > Turn on experiment and beta features.

✔ MCP Grape API endpoint is loaded (API::Mcp::Base).
  Endpoint: http://gdk.test:3000/api/v4/mcp
  OAuth discovery: http://gdk.test:3000/.well-known/oauth-authorization-server/api/v4/mcp
  Dynamic registration: http://gdk.test:3000/oauth/register

ℹ No instance-level access rules configured (Ai::FeatureAccessRule).
  All users with appropriate license will have access to Duo features.

ℹ No username provided. Skipping user-specific checks.
  Re-run with: rake gitlab:duo:verify_mcp_server_setup[username]

═══════════════════════════════════════════════════════════════
✗ 1 check(s) failed. MCP server may not work.
═══════════════════════════════════════════════════════════════


═══════════════════════════════════════════════════════════════
DIAGNOSTIC SUMMARY (sanitize before sharing with support)
═══════════════════════════════════════════════════════════════
{
  "system": {
    "gitlab_version": "18.11.0-pre",
    "gitlab_revision": "af6737553b2",
    "gitlab_edition": "EE",
    "rails_env": "development",
    "timestamp": "2026-03-19T15:53:40Z",
    "instance_url": "http://gdk.test:3000",
    "user": null
  },
  "license": {
    "status": "PASS",
    "message": "License: Ultimate — :mcp_server feature is available."
  },
  "duo_availability": {
    "status": "PASS",
    "message": "Duo availability: 'On by default' (duo_features_enabled=true, lock=false)"
  },
  "duo_features_enabled": {
    "status": "PASS",
    "message": "duo_features_enabled: true"
  },
  "instance_level_ai_beta_features_enabled": {
    "status": "FAIL",
    "message": "instance_level_ai_beta_features_enabled: false",
    "detail": "The MCP server requires experiment and beta features to be enabled. Enable via: Admin > GitLab Duo > Turn on experiment and beta features."
  },
  "oauth_discovery": {
    "status": "PASS",
    "message": "MCP Grape API endpoint is loaded (API::Mcp::Base).",
    "detail": "Endpoint: http://gdk.test:3000/api/v4/mcp\n  OAuth discovery: http://gdk.test:3000/.well-known/oauth-authorization-server/api/v4/mcp\n  Dynamic registration: http://gdk.test:3000/oauth/register"
  },
  "instance_access_rules": {
    "status": "INFO",
    "message": "No instance-level access rules configured (Ai::FeatureAccessRule).",
    "detail": "All users with appropriate license will have access to Duo features."
  }
}

NOTE: Review the above output and remove any sensitive information
before sharing with GitLab support.
~/dev/gdk/gitlab (lkorbasiewicz-mcpcheck-rake) $

How to set up and validate locally

gdk switch lkorbasiewicz-mcpcheck-rake
bin/rake 'gitlab:duo:verify_mcp_server_setup'
bin/rake 'gitlab:duo:verify_mcp_server_setup[root]'

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