Return the branch web_url from the add_branch MCP tool
What does this MR do and why?
add_branch is the MCP counterpart of POST /projects/:id/repository/branches, which returns web_url for the created branch, and it is aliased as create_branch. Its GraphQL-backed implementation returns only what Types::BranchType exposes — name and commit — because the Gitlab::Git::Branch behind that type carries no project to build a URL from. This MR restores parity with the REST endpoint by adding the URL in the tool's process_result, where the project is already resolved, the same way get_job uses project_job_url.
This MR adds the URL back in the tool's process_result, where the project has already been resolved, using project_tree_url as get_job does with project_job_url. The GraphQL type is unchanged, so no schema or docs change is needed. Both the text content and structuredContent carry the field.
References
- Resolves #611539 (closed)
- Related: !248453 (merged)
Differences
Before: The add_branch tool response contains branch: { name, commit }.
After: The response contains branch: { name, commit, web_url }, where web_url points at the branch's tree page.
How to set up and validate locally
-
Call the tool through the MCP endpoint:
curl -s -X POST "http://gdk.test:3000/api/v4/mcp" \ -H "Authorization: Bearer <mcp-scoped token>" -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":"1","method":"tools/call","params":{"name":"add_branch","arguments":{"project_id":"<full path>","branch":"mcp-test","ref":"master"}}}' -
result.structuredContent.branch.web_urlis present and resolves to the new branch.
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.