Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

git_clone

Clone a Git repository into a specified directory with options for branch selection, shallow cloning, and custom destination paths.

Instructions

Clone a repository into a new directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesRepository URL to clone
destinationNoDestination directory (defaults to repo name)
cwdNoDirectory to clone into
branchNoSpecific branch to clone
depthNoCreate shallow clone with depth

Implementation Reference

  • The gitClone function implements the core logic for the git_clone tool by constructing and executing a 'git clone' command with optional parameters using the shared executeGitCommand helper.
    export async function gitClone(args: z.infer<typeof gitCloneSchema>): Promise<ToolResponse> { const branchFlag = args.branch ? `-b ${args.branch}` : ''; const depthFlag = args.depth ? `--depth ${args.depth}` : ''; const destination = args.destination || ''; return executeGitCommand(`git clone ${branchFlag} ${depthFlag} ${args.url} ${destination}`.trim(), args.cwd); }
  • Zod schema defining the input validation for the git_clone tool parameters.
    export const gitCloneSchema = z.object({ url: z.string().describe('Repository URL to clone'), destination: z.string().optional().describe('Destination directory (defaults to repo name)'), cwd: z.string().optional().describe('Directory to clone into'), branch: z.string().optional().describe('Specific branch to clone'), depth: z.number().optional().describe('Create shallow clone with depth') });
  • src/index.ts:393-396 (registration)
    Registration in the main MCP server request handler that dispatches 'git_clone' tool calls to the gitClone function after validating arguments with gitCloneSchema.
    if (name === 'git_clone') { const validated = gitCloneSchema.parse(args); return await gitClone(validated); }
  • MCP tool definition in the gitTools array, providing the tool name, description, and JSON inputSchema for listing in MCP tool discovery.
    { name: 'git_clone', description: 'Clone a repository into a new directory', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'Repository URL to clone' }, destination: { type: 'string', description: 'Destination directory (defaults to repo name)' }, cwd: { type: 'string', description: 'Directory to clone into' }, branch: { type: 'string', description: 'Specific branch to clone' }, depth: { type: 'number', description: 'Create shallow clone with depth' } }, required: ['url'] } },
  • Shared helper function used by all git tools, including gitClone, to execute git commands and format responses.
    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