Skip to main content
Glama

add

Stage files in a Git repository by specifying the repository path and file paths. Simplify Git workflows and prepare changes for commits efficiently.

Instructions

Add files to the git staging area.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filesYesList of pathspecs to add
repoPathYesAbsolute path to the git repository

Implementation Reference

  • The private handler method that implements the core logic of the 'add' tool: validates the repository, executes git add on the input files using simple-git, and returns success or error message.
    readonly #handle: ToolCallback<typeof GIT_ADD_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', }, ], }; } // Execute git add await sg.add(input.files); return { content: [ { type: 'text', text: `Files added to staging area.`, }, ], }; };
  • Zod input schema defining the parameters for the 'add' tool: repository path and list of files to add.
    export const GIT_ADD_INPUT_SCHEMA = { repoPath: z.string().describe('Absolute path to the git repository'), files: z.array(z.string()).describe('List of pathspecs to add'), };
  • The register method of GitAddTool class that registers the tool with the MCP server using its name ('add'), config, and handler.
    register(srv: McpServer) { srv.registerTool(this.name, this.config, this.#handle); }
  • Instantiation of GitAddTool and call to its register method on the MCP server instance, effectively registering the 'add' tool.
    new GitAddTool().register(server);
  • Getter that returns the tool name 'add' used during registration.
    get name() { return 'add'; }

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