Loading
Add support for list_branches MCP tool
What does this MR do and why?
This MR adds support for list_branches MCP tool
References
closes: #605849 (closed)
Screenshots or screen recordings
N/A
How to set up and validate locally
- Create a token that can access the MCP server.
- Check the tool is registered
curl --silent --request POST "$MCP_URL" \
--header "Authorization: Bearer $MCP_OAUTH_TOKEN" \
--header 'Content-Type: application/json' \
--data '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' |
jq -er '.result.tools[] | select(.name == "list_branches") | .name'- Call the tool using a project path:
curl --silent --request POST "$MCP_URL" \
--header "Authorization: Bearer $MCP_OAUTH_TOKEN" \
--header 'Content-Type: application/json' \
--data "$(jq -cn --arg project_id "$PROJECT_PATH" \
'{jsonrpc:"2.0",id:2,method:"tools/call",
params:{name:"list_branches",
arguments:{project_id:$project_id,search:"main",page:1,per_page:20}}}')" |
jq- validate the output shape
curl --silent --request POST "$MCP_URL" \
--header "Authorization: Bearer $MCP_OAUTH_TOKEN" \
--header 'Content-Type: application/json' \
--data "$(jq -cn --argjson project_id "$PROJECT_ID" \
'{jsonrpc:"2.0",id:3,method:"tools/call",
params:{name:"list_branches",
arguments:{project_id:$project_id,page:1,per_page:1}}}')" |
jq -e '
.result.isError == false and
(.result.structuredContent.branches | type == "array") and
(.result.structuredContent.branches[0] |
has("name") and has("default") and has("protected") and
(.commit | has("sha") and has("title"))) and
(.result.structuredContent.metadata.has_more | type == "boolean")
'- Run specs
bundle exec rspec \
spec/requests/api/mcp/handlers/call_tool_spec.rb \
spec/requests/api/mcp/handlers/list_tools_spec.rb \
spec/services/mcp/tools/manager_spec.rbMR 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.
Related to #605849 (closed)
Edited by Dhairya Majmudar