Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

git_reset

Reset Git repository HEAD to a specified commit using soft, mixed, or hard modes to undo changes and restore previous states in development workflows.

Instructions

Reset current HEAD to specified state

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdNoRepository directory
modeNoReset modemixed
commitNoCommit to reset toHEAD
filesNoSpecific file(s) to reset

Implementation Reference

  • The main handler function gitReset that executes the git reset command. It handles both file-specific resets and full resets with soft/mixed/hard modes using the shared executeGitCommand helper.
    export async function gitReset(args: z.infer<typeof gitResetSchema>): Promise<ToolResponse> { if (args.files) { return executeGitCommand(`git reset ${args.commit} -- ${args.files}`, args.cwd); } const modeFlag = `--${args.mode}`; return executeGitCommand(`git reset ${modeFlag} ${args.commit}`, args.cwd); }
  • Zod schema defining the input parameters for the git_reset tool, including cwd, mode, commit, and optional files.
    export const gitResetSchema = z.object({ cwd: z.string().optional().describe('Repository directory'), mode: z.enum(['soft', 'mixed', 'hard']).optional().default('mixed').describe('Reset mode'), commit: z.string().optional().default('HEAD').describe('Commit to reset to'), files: z.string().optional().describe('Specific file(s) to reset') });
  • The tool registration object within the gitTools array that defines the git_reset tool for the MCP listTools endpoint.
    { name: 'git_reset', description: 'Reset current HEAD to specified state', inputSchema: { type: 'object', properties: { cwd: { type: 'string', description: 'Repository directory' }, mode: { type: 'string', enum: ['soft', 'mixed', 'hard'], default: 'mixed', description: 'Reset mode' }, commit: { type: 'string', default: 'HEAD', description: 'Commit to reset to' }, files: { type: 'string', description: 'Specific file(s) to reset' } } } },
  • src/index.ts:421-424 (registration)
    Dispatch/registration logic in the main MCP server handler that routes 'git_reset' calls to the gitReset function after schema validation.
    if (name === 'git_reset') { const validated = gitResetSchema.parse(args); return await gitReset(validated); }
  • Shared helper function executeGitCommand used by gitReset (and all git tools) to run 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