Skip to main content
Glama
bsreeram08

Git Repo Browser MCP

git_local_changes

View uncommitted changes in a Git repository's working directory to track modifications before committing.

Instructions

Get uncommitted changes in the working directory.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYesThe path to the local Git repository

Implementation Reference

  • The core handler function that implements the git_local_changes tool. It uses simpleGit to retrieve the repository status, including staged, modified, new, deleted, and conflicted files, along with diffs for modified files.
     * Handles the git_local_changes tool request
     * @param {Object} params - Tool parameters
     * @param {string} params.repo_path - Local repository path
     * @returns {Object} - Tool response
     */
    export async function handleGitLocalChanges({ repo_path }) {
      try {
        // Use the provided local repo path
        const git = simpleGit(repo_path);
    
        // Get status information
        const status = await git.status();
    
        // Get detailed diff for modified files
        let diffs = {};
        for (const file of status.modified) {
          diffs[file] = await git.diff([file]);
        }
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  branch: status.current,
                  staged_files: status.staged,
                  modified_files: status.modified,
                  new_files: status.not_added,
                  deleted_files: status.deleted,
                  conflicted_files: status.conflicted,
                  diffs: diffs,
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                { error: `Failed to get local changes: ${error.message}` },
                null,
                2
              ),
            },
          ],
          isError: true,
        };
      }
    }
  • The input schema definition for the git_local_changes tool, specifying the required repo_path parameter.
      name: "git_local_changes",
      description: "Get uncommitted changes in the working directory.",
      inputSchema: {
        type: "object",
        properties: {
          repo_path: {
            type: "string",
            description: "The path to the local Git repository",
          },
        },
        required: ["repo_path"],
      },
    },
  • src/server.js:905-905 (registration)
    Registration of the git_local_changes tool name to its handler function in the handlersMap.
    git_local_changes: handleGitLocalChanges,
  • src/server.js:852-854 (registration)
    Registers the tool list including git_local_changes schema for the ListToolsRequest.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: this.toolsList,
    }));
  • src/server.js:16-16 (registration)
    Import of the handleGitLocalChanges handler from handlers/index.js.
    handleGitLocalChanges,

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