Add enum constraint to scope parameter in MCP search tool

Closes #595159 (closed)

What does this MR do?

Adds an enum constraint to the scope parameter in the Mcp::Tools::Search::SearchService JSON schema. The enum array is dynamically populated using the union of available_search_scopes across :global, :group, and :project contexts:

scope: {
  type: 'string',
  enum: (available_search_scopes(:global) | available_search_scopes(:group) | available_search_scopes(:project)).uniq,
  description: scope_description
}

Also updates the unit spec (spec/services/mcp/tools/search/search_service_spec.rb) to assert that the enum array is present on the scope property.

Why was this MR needed?

The MCP search tool documented valid scopes only in description text. Adding a formal enum constraint enables:

  • MCP client-side validation prior to sending requests
  • Proper schema introspection in schema-aware tooling and AI agents
  • Predictable parameter validation

Checklist

  • Implemented according to issue specification
  • Added spec assertions matching match_array for all available scopes
  • Closes #595159 (closed)

Merge request reports

Loading
Loading