Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

git_add

Stage files for commit in Git repositories. Use this tool to prepare file changes for version control by adding them to the staging area before committing.

Instructions

Stage files for commit. Use "." to stage all changes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filesYesFile(s) to stage. Use "." for all files
cwdNoRepository directory

Implementation Reference

  • The core handler function that processes input arguments, formats the git add command, and executes it via the shared executeGitCommand helper.
    export async function gitAdd(args: z.infer<typeof gitAddSchema>): Promise<ToolResponse> { const files = Array.isArray(args.files) ? args.files.join(' ') : args.files; return executeGitCommand(`git add ${files}`, args.cwd); }
  • Zod schema used for input validation in the git_add handler and dispatch.
    export const gitAddSchema = z.object({ files: z.union([z.string(), z.array(z.string())]).describe('File(s) to stage. Use "." for all files'), cwd: z.string().optional().describe('Repository directory') });
  • src/index.ts:361-364 (registration)
    Dispatch logic in the main MCP server that routes 'git_add' tool calls to the handler after schema validation.
    if (name === 'git_add') { const validated = gitAddSchema.parse(args); return await gitAdd(validated); }
  • MCP tool registration object defining name, description, and JSON input schema for tool listing.
    { name: 'git_add', description: 'Stage files for commit. Use "." to stage all changes', inputSchema: { type: 'object', properties: { files: { oneOf: [ { type: 'string' }, { type: 'array', items: { type: 'string' } } ], description: 'File(s) to stage. Use "." for all files' }, cwd: { type: 'string', description: 'Repository directory' } }, required: ['files'] } },
  • Shared helper function that executes git commands asynchronously and formats success/error 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