[Refactor] Govern the remaining MCP tools by their own container lookup

What does this MR do and why?

This is the last of three stacked MRs that make MCP governance resolve a call's containers through each tool's own lookup. It's stacked on !268283 and targets its branch. !261045 adds the plumbing and explains the change.

It has two commits:

  1. Convert the remaining tools. These are the projects, project members, groups, labels, pipelines, jobs, list_todos, wikis and releases tools, plus the EE security and Duo workflow tools. The custom services get_job, get_artifact_file and list_releases, and the aggregated start_duo_session, use their own lookup. Record arguments (pipeline_id, vulnerability_id, workflow_id) still use the declared record: lookups.
  2. Make GraphqlTool#governed_containers raise NotImplementedError by default and remove the fallback to the declared lookup from GraphqlService. Every GraphQL tool has converted by now, so no tool can be governed through a stale declaration. An ungovernable service such as get_user returns before it builds its tool, because that tool has no governed_containers.

REST tools keep the declared lookup through Gitlab::ResourceLookup, the same function Grape's find_project uses.

This MR targets !268283's branch instead of !261045's. The NotImplementedError default needs every tool converted, including the ones in !268283, so its pipeline can only pass on top of that MR. The diff against the target branch shows only this MR's files, so both MRs can still be reviewed in parallel.

!261051 is stacked on this MR.

How to reproduce the issue

There is no user-facing defect.

  1. Check out 633015-mcp-governance-mr-repository-tools.
  2. Define a GraphqlTool subclass without governed_containers and call governed_containers on its service.
  3. You can see that the call falls back to the declared lookup.

How to test the fix

  1. On this branch, repeat the call. It raises NotImplementedError.
  2. Call governed_containers for get_pipeline and get_vulnerability. The result is the project the tool's execute path resolves.

Run the specs:

bin/rspec spec/services/mcp ee/spec/services/mcp ee/spec/services/ee/mcp spec/lib/api/mcp/handlers ee/spec/lib/ee/api/mcp/handlers ee/spec/lib/ai/tool_rules spec/requests/api/mcp ee/spec/requests/api/mcp

References

Edited by Raounak Sharma

Merge request reports

Loading
Loading