Add fork_repository MCP server tool

What does this MR do and why?

Adds a fork_repository MCP server tool so agents can fork a project into a namespace, matching the workflows already available for issues and merge requests (create_issue, create_merge_request).

How to test locally

  1. Check out the branch and restart Rails, since the tool registry is memoized:

    gdk restart rails-web
  2. Create a personal access token with the mcp scope:

    bundle exec rails runner "u=User.find_by_username('root'); t=u.personal_access_tokens.create!(name: 'mcp-test', scopes: [:mcp], expires_at: 2.days.from_now); raw='glpat-'+SecureRandom.hex(20); t.set_token(raw); t.save!; puts raw"
  3. Confirm the tool is advertised, by looking for fork_repository in the response:

    curl -s -X POST http://gdk.test:3000/api/v4/mcp -H "Authorization: Bearer <TOKEN>" -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
  4. Call the tool:

    curl -s -X POST http://gdk.test:3000/api/v4/mcp -H "Authorization: Bearer <TOKEN>" -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"fork_repository","arguments":{"id":"gitlab-org/gitlab-test"}}}'

    Expected: a successful response with the forked project's attributes, including import_status: "scheduled".

  5. Call it again with the same arguments to see the 409 conflict response, or with a nonexistent id to see the 404 response.

References

Edited by Amr Taha

Merge request reports

Loading
Loading