Skip to main content
Glama
bsreeram08

Git Repo Browser MCP

git_track

Stage specific files or all changes in a Git repository to prepare them for committing, enabling controlled version management of code modifications.

Instructions

Track (stage) specific files or all files.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYesThe path to the local Git repository
filesNoArray of file paths to track/stage (use ["."] for all files)

Implementation Reference

  • The main handler function for the git_track tool. It uses simpleGit to add (stage) the specified files to the index and returns the updated git status.
    export async function handleGitTrack({ repo_path, files = ["."] }) {
      try {
        const git = simpleGit(repo_path);
    
        // Add the specified files to the staging area
        await git.add(files);
    
        // Get status to show what files were tracked
        const status = await git.status();
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  success: true,
                  message: `Tracked ${
                    files.length === 1 && files[0] === "."
                      ? "all files"
                      : files.length + " files"
                  }`,
                  staged: status.staged,
                  not_staged: status.not_added,
                  modified: status.modified,
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                { error: `Failed to track files: ${error.message}` },
                null,
                2
              ),
            },
          ],
          isError: true,
        };
      }
    }
  • The tool schema definition including name, description, and inputSchema for git_track, used in ListTools response.
    {
      name: "git_track",
      description: "Track (stage) specific files or all files.",
      inputSchema: {
        type: "object",
        properties: {
          repo_path: {
            type: "string",
            description: "The path to the local Git repository",
          },
          files: {
            type: "array",
            items: { type: "string" },
            description:
              'Array of file paths to track/stage (use ["."] for all files)',
            default: ["."],
          },
        },
        required: ["repo_path"],
      },
    },
  • src/server.js:908-908 (registration)
    Registration of the git_track handler in the this.handlersMap object, mapping the tool name to its handler function.
    git_track: handleGitTrack,
  • Re-export of handleGitTrack from commit-operations.js in handlers index for centralized imports.
    handleGitTrack,
  • Import of handleGitTrack from ./commit-operations.js in handlers index.
    handleGitTrack,

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/bsreeram08/git-commands-mcp'

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