git_pull
Pull updates from a remote Git repository, specify branch and rebase options, and sync local code with the latest changes. Ideal for managing repository versions and maintaining up-to-date working copies.
Instructions
Pull changes from a remote repository.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| branch | No | Branch to pull (default: current branch) | |
| rebase | No | Whether to rebase instead of merge | |
| remote | No | Remote name | origin |
| repo_path | Yes | The path to the local Git repository |
Implementation Reference
- src/handlers/remote-operations.js:75-132 (handler)Core implementation of the git_pull tool handler. Performs git pull using simpleGit, supports repo_path, remote, branch, and rebase options. Returns structured MCP response with success/error details.export async function handleGitPull({ repo_path, remote = "origin", branch = null, rebase = false, }) { try { const git = simpleGit(repo_path); // If no branch specified, use current branch if (!branch) { const branchInfo = await git.branch(); branch = branchInfo.current; } // Set up pull options const pullOptions = {}; if (rebase) { pullOptions["--rebase"] = null; } // Perform the pull const pullResult = await git.pull(remote, branch, pullOptions); return { content: [ { type: "text", text: JSON.stringify( { success: true, result: pullResult, message: `Pulled from ${remote}/${branch}`, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify( { error: `Failed to pull changes: ${error.message}`, conflicts: error.git ? error.git.conflicts : null, }, null, 2 ), }, ], isError: true, }; }
- src/server.js:447-474 (schema)Input schema definition for the git_pull tool, defining parameters and validation rules in the server's toolsList.{ name: "git_pull", description: "Pull changes from a remote repository.", inputSchema: { type: "object", properties: { repo_path: { type: "string", description: "The path to the local Git repository", }, remote: { type: "string", description: "Remote name", default: "origin", }, branch: { type: "string", description: "Branch to pull (default: current branch)", }, rebase: { type: "boolean", description: "Whether to rebase instead of merge", default: false, }, }, required: ["repo_path"], }, },
- src/server.js:913-913 (registration)Registration of 'git_pull' tool name mapped to handleGitPull function in the server's handlersMap for request handling.git_pull: handleGitPull,
- src/handlers/index.js:61-63 (registration)Re-export of handleGitPull from remote-operations.js in handlers index for centralized import in server.js.handleGitPush, handleGitPull, handleGitRemote,
- src/handlers/common.js:3-10 (helper)Helper module re-exporting simpleGit library used by handleGitPull for executing git pull command.import { simpleGit } from "simple-git"; import { exec } from "child_process"; import { promisify } from "util"; import { cloneRepo, getDirectoryTree } from "../utils/git.js"; const execPromise = promisify(exec); export { path, fs, simpleGit, execPromise, cloneRepo, getDirectoryTree };