git_rebase
Reapply commits from your current branch onto another branch to maintain a linear project history and integrate changes without merge commits.
Instructions
Reapply commits on top of another branch
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "git_rebase"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| branch | No | Branch to rebase onto | |
| cwd | No | Repository directory | |
| interactive | No | Interactive rebase (not supported) | |
| abort | No | Abort current rebase | |
| continue | No | Continue rebase after resolving conflicts |
Implementation Reference
- src/tools/git.ts:322-342 (handler)The main handler function that executes the git rebase command based on provided arguments, handling special cases like abort, continue, and interactive.
export async function gitRebase(args: z.infer<typeof gitRebaseSchema>): Promise<ToolResponse> { if (args.abort) { return executeGitCommand('git rebase --abort', args.cwd); } if (args.continue) { return executeGitCommand('git rebase --continue', args.cwd); } if (args.interactive) { return { content: [{ type: "text", text: JSON.stringify({ success: false, error: 'Interactive rebase not supported in non-interactive environment' }, null, 2) }], isError: true }; } if (!args.branch) { return { content: [{ type: "text", text: JSON.stringify({ success: false, error: 'Branch required for rebase' }, null, 2) }], isError: true }; } return executeGitCommand(`git rebase ${args.branch}`, args.cwd); } - src/tools/git.ts:148-154 (schema)Zod schema for input validation of the git_rebase tool parameters.
export const gitRebaseSchema = z.object({ branch: z.string().optional().describe('Branch to rebase onto'), cwd: z.string().optional().describe('Repository directory'), interactive: z.boolean().optional().default(false).describe('Interactive rebase'), abort: z.boolean().optional().default(false).describe('Abort current rebase'), continue: z.boolean().optional().default(false).describe('Continue rebase after resolving conflicts') }); - src/index.ts:405-408 (registration)Dispatch/registration in the main MCP server handler that routes 'git_rebase' calls to the gitRebase function after validation.
if (name === 'git_rebase') { const validated = gitRebaseSchema.parse(args); return await gitRebase(validated); } - src/tools/git.ts:657-670 (schema)MCP tool definition schema for 'git_rebase' used in tool listing.
{ name: 'git_rebase', description: 'Reapply commits on top of another branch', inputSchema: { type: 'object', properties: { branch: { type: 'string', description: 'Branch to rebase onto' }, cwd: { type: 'string', description: 'Repository directory' }, interactive: { type: 'boolean', default: false, description: 'Interactive rebase (not supported)' }, abort: { type: 'boolean', default: false, description: 'Abort current rebase' }, continue: { type: 'boolean', default: false, description: 'Continue rebase after resolving conflicts' } } } }, - src/index.ts:284-296 (registration)Registration of gitTools (including git_rebase) in the MCP list tools handler.
this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ ...filesystemTools, ...shellTools, ...dockerTools, ...mongodbTools, ...redisTools, ...gitTools, ...processTools, ...networkTools ] };