Skip to main content
Glama

reset

Reset a Git repository to a specified commit, branch, or tag using soft, mixed, or hard modes. Manage repository state by keeping changes staged, unstaging changes, or discarding changes entirely.

Instructions

Reset repository state (soft, mixed, hard).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeNoReset mode: soft (keep changes staged), mixed (unstage changes), hard (discard changes)mixed
pathspecNoLimit reset to specific paths
repoPathYesAbsolute path to the git repository
targetNoTarget commit, branch, or tag to reset to (defaults to HEAD)HEAD

Implementation Reference

  • The #handle method executes the git reset command using simple-git, validates the repo, constructs arguments based on input (target, mode, pathspec), runs sg.reset(), and returns formatted results or error.
    readonly #handle: ToolCallback<typeof GIT_RESET_INPUT_SCHEMA> = async (input) => {
    	const sg = simpleGit(input.repoPath);
    
    	const isRepo = await sg.checkIsRepo();
    	if (!isRepo) {
    		return {
    			isError: true,
    			content: [
    				{
    					type: 'text',
    					text: 'Not a git repository',
    				},
    			],
    		};
    	}
    
    	const target = input.target ?? 'HEAD';
    	const args = [`--${input.mode}`, target];
    
    	if (input.pathspec && input.pathspec.length > 0) {
    		args.push('--', ...input.pathspec);
    	}
    
    	const result = await sg.reset(args);
    
    	return {
    		content: [
    			{
    				type: 'text',
    				text: `Reset ${input.mode} to ${target}${input.pathspec ? ` (paths: ${input.pathspec.join(', ')})` : ''}`,
    			},
    			{
    				type: 'text',
    				text: JSON.stringify(result),
    			},
    		],
    	};
    };
  • Zod input schema for the reset tool defining parameters: repoPath (required string), target (optional string default HEAD), mode (enum soft/mixed/hard default mixed), pathspec (optional array of strings).
    export const GIT_RESET_INPUT_SCHEMA = {
    	repoPath: z.string().describe('Absolute path to the git repository'),
    	target: z
    		.string()
    		.optional()
    		.describe('Target commit, branch, or tag to reset to (defaults to HEAD)')
    		.default('HEAD'),
    	mode: z
    		.enum(['soft', 'mixed', 'hard'])
    		.optional()
    		.default('mixed')
    		.describe('Reset mode: soft (keep changes staged), mixed (unstage changes), hard (discard changes)'),
    	pathspec: z.array(z.string()).optional().describe('Limit reset to specific paths'),
    };
  • The register method of GitResetTool class which calls srv.registerTool with the tool's name ('reset'), config (including schema), and handler.
    register(srv: McpServer) {
    	srv.registerTool(this.name, this.config, this.#handle);
    }
  • Instantiation and registration of GitResetTool on the MCP server in the main index file.
    new GitResetTool().register(server);
  • Getter that returns the tool name 'reset' used during registration.
    get name() {
    	return 'reset';
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations indicate readOnlyHint=false, which aligns with the description's implication of a mutation operation ('reset'). The description adds value by specifying the three reset modes (soft, mixed, hard), which provides behavioral context beyond annotations. However, it doesn't detail potential side effects like data loss in 'hard' mode or authentication needs, so it's not fully transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with a single sentence that front-loads the core action ('reset repository state') and efficiently lists the modes. Every word earns its place, making it easy to parse without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no output schema and 4 parameters, the description is minimal. It covers the basic action and modes but lacks details on return values, error conditions, or integration with sibling tools. Given the complexity and annotation coverage, it's adequate but has clear gaps in completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with all parameters well-documented in the schema itself. The description mentions the modes (soft, mixed, hard) which corresponds to the 'mode' parameter, but adds no additional semantic meaning beyond what the schema already provides. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('reset') and resource ('repository state'), and specifies the three modes (soft, mixed, hard) which gives specific action details. However, it doesn't explicitly distinguish this tool from sibling tools like 'checkout' or 'revert' that might also affect repository state, keeping it from a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'checkout' or 'revert' among the sibling tools. It mentions the modes but doesn't explain when each mode is appropriate or what prerequisites might be needed, leaving the agent without contextual usage direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/ver0-project/mcps'

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