Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

git_fetch

Download objects and refs from remote Git repositories to update your local copy with changes from team members or upstream sources.

Instructions

Download objects and refs from remote repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdNoRepository directory
remoteNoRemote nameorigin
pruneNoRemove deleted remote branches

Implementation Reference

  • The main handler function that executes the git fetch command by calling the shared executeGitCommand helper with constructed git fetch arguments.
    export async function gitFetch(args: z.infer<typeof gitFetchSchema>): Promise<ToolResponse> { const pruneFlag = args.prune ? '--prune' : ''; return executeGitCommand(`git fetch ${pruneFlag} ${args.remote}`.trim(), args.cwd); }
  • Zod schema used for input validation of the git_fetch tool parameters in the dispatcher.
    export const gitFetchSchema = z.object({ cwd: z.string().optional().describe('Repository directory'), remote: z.string().optional().default('origin').describe('Remote name'), prune: z.boolean().optional().default(false).describe('Remove deleted remote branches') });
  • MCP protocol tool registration definition for git_fetch, including name, description, and JSON schema for tool listing.
    { name: 'git_fetch', description: 'Download objects and refs from remote repository', inputSchema: { type: 'object', properties: { cwd: { type: 'string', description: 'Repository directory' }, remote: { type: 'string', default: 'origin', description: 'Remote name' }, prune: { type: 'boolean', default: false, description: 'Remove deleted remote branches' } } } },
  • src/index.ts:409-411 (registration)
    Server request handler dispatcher that routes 'git_fetch' tool calls by parsing arguments with schema and invoking the gitFetch handler.
    if (name === 'git_fetch') { const validated = gitFetchSchema.parse(args); return await gitFetch(validated);
  • Core helper function that executes any git command via child_process.execAsync, handles errors, and returns standardized ToolResponse format used by all git tools including gitFetch.
    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 }; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ConnorBoetig-dev/mcp2'

If you have feedback or need assistance with the MCP directory API, please join our Discord server