Loading
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
-
Check out the branch and restart Rails, since the tool registry is memoized:
gdk restart rails-web -
Create a personal access token with the
mcpscope: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" -
Confirm the tool is advertised, by looking for
fork_repositoryin 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"}' -
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". -
Call it again with the same arguments to see the 409 conflict response, or with a nonexistent
idto see the 404 response.
References
Edited by Amr Taha