What happens when an autonomous AI agent calls a CI/CD tool with a fine-grained token that has permission to trigger a production pipeline job, but lacks permission to read the resulting job object? In a naive GraphQL wrapper, the production deployment fires, the response query fails, and the AI agent thinks the call failed—setting up a catastrophic retry loop.
When exposing CI/CD state mutations to AI agents via MCP, authorization cannot be treated as a single flat check. In GitLab's MCP server, the save_pipeline_job tool (Mcp::Tools::Jobs::SavePipelineJobTool) executes a GraphQL mutation ( jobPlay or jobRetry) that both transitions a pipeline job's state and selects fields on the mutated CiJob and its parent Pipeline (such as stage metadata) to return structured confirmation to the agent. While working on Issue #639861 and authoring MR !270865 (test(mcp): add granular token authorization coverage for save_pipeline_job), I analyzed the authorization boundary for GitLab's fine-grained Personal Access Tokens (granular PATs).
A granular PAT configured with the :run_job permission expands internally to :play_job and :retry_job. If the pre-execution guard in find_job! only validates authorize_granular_token!(project, [:play_job]), a token holding :run_job alone passes the gate and invokes GitlabSchema.execute. Inside GraphQL, the mutation succeeds and enqueues the manual CI/CD job on a runner—a permanent side effect. Immediately afterward, GraphQL attempts to resolve the returned job and pipeline stage fields, which require :read_job and :read_pipeline permissions. Because the token lacks those read scopes, GraphQL redacts the return node to nil, and the MCP tool surfaces "Operation returned no job data" (isError: true) back to the agent after the job is already running.
In MR !270865, we enforced atomic pre-mutation authorization by requiring the complete composite permission set—authorize_granular_token!(project, [:play_job, :read_job, :read_pipeline])—inside find_job! before GitlabSchema.execute is ever invoked, accompanied by full service and request-level RSpec suites proving that partial granular tokens ([:run_job] without :read_job and :read_pipeline) are rejected with :unauthorized while the manual job remains untouched in manual status.
GitLab's granular Personal Access Token architecture and MCP security layer (MR !270865) enforce composite pre-flight permission verification across mutation and response-projection boundaries, ensuring AI agents never trigger silent, unobservable CI/CD pipeline executions.
When an AI tool executes a GraphQL mutation and projects fields from the mutated graph, pre-authorize the union of both mutation permissions and response-graph read permissions before executing the mutation—otherwise read redaction looks like a failed write to an autonomous agent.