git_pull
Fetch and integrate changes from remote Git repositories to keep local code synchronized with upstream developments.
Instructions
Fetch and integrate changes from remote repository
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Repository directory | |
| remote | No | Remote name | origin |
| branch | No | Branch to pull (defaults to current branch) | |
| rebase | No | Rebase instead of merge |
Implementation Reference
- src/tools/git.ts:289-293 (handler)The main handler function that constructs and executes the 'git pull' command using the shared executeGitCommand helper, handling optional parameters for remote, branch, rebase, and cwd.export async function gitPull(args: z.infer<typeof gitPullSchema>): Promise<ToolResponse> { const rebaseFlag = args.rebase ? '--rebase' : ''; const branch = args.branch || ''; return executeGitCommand(`git pull ${rebaseFlag} ${args.remote} ${branch}`.trim(), args.cwd); }
- src/tools/git.ts:113-118 (schema)Zod schema defining the input parameters and validation for the git_pull tool.export const gitPullSchema = z.object({ cwd: z.string().optional().describe('Repository directory'), remote: z.string().optional().default('origin').describe('Remote name'), branch: z.string().optional().describe('Branch to pull (defaults to current branch)'), rebase: z.boolean().optional().default(false).describe('Rebase instead of merge') });
- src/tools/git.ts:590-602 (registration)MCP tool definition/registration in the gitTools array exported from git.ts, including name, description, and inputSchema for tool listing.{ name: 'git_pull', description: 'Fetch and integrate changes from remote repository', inputSchema: { type: 'object', properties: { cwd: { type: 'string', description: 'Repository directory' }, remote: { type: 'string', default: 'origin', description: 'Remote name' }, branch: { type: 'string', description: 'Branch to pull (defaults to current branch)' }, rebase: { type: 'boolean', default: false, description: 'Rebase instead of merge' } } } },
- src/index.ts:385-388 (registration)Runtime dispatch/registration in the main MCP server handler that routes 'git_pull' calls to the gitPull function after schema validation.if (name === 'git_pull') { const validated = gitPullSchema.parse(args); return await gitPull(validated); }
- src/tools/git.ts:21-61 (helper)Shared utility function that executes git commands via child_process.exec, handles errors, and formats standardized ToolResponse for all git tools including git_pull.async function executeGitCommand(command: string, cwd?: string): Promise<ToolResponse> { try { const { stdout, stderr } = await execAsync(command, { cwd: cwd || process.cwd(), shell: '/bin/bash', maxBuffer: 10 * 1024 * 1024 // 10MB buffer }); return { content: [ { type: "text" as const, text: JSON.stringify({ success: true, command: command, stdout: stdout.trim(), stderr: stderr.trim(), cwd: cwd || process.cwd() }, null, 2) } ] }; } catch (error: any) { return { content: [ { type: "text" as const, text: JSON.stringify({ success: false, command: command, stdout: error.stdout?.trim() || '', stderr: error.stderr?.trim() || error.message, exitCode: error.code || 1, cwd: cwd || process.cwd() }, null, 2) } ], isError: true }; } }