Skip to main content
Glama

git-status

Check the current git status of a repository to view changes, staged files, and branch information. Specify a directory path to analyze any git project.

Instructions

Get the current git status of the repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryNoDirectory path to check git status (defaults to current directory)

Implementation Reference

  • Handler for the 'git-status' tool: executes git status --porcelain=v1, git branch --show-current, and git remote -v commands in the specified directory (or cwd), formats the output including branch and remotes, handles errors.
    if (name === "git-status") { const { directory }: { directory?: string } = args || {}; try { // Change to the specified directory if provided, otherwise use current directory const cwd = directory || process.cwd(); // Execute git status command const gitStatus = execSync("git status --porcelain=v1", { cwd: cwd, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }); // Also get the branch information const gitBranch = execSync("git branch --show-current", { cwd: cwd, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim(); // Get additional git info const gitRemote = execSync("git remote -v", { cwd: cwd, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }); // Format the response let statusText = `Git Status for: ${cwd}\n`; statusText += `Current branch: ${gitBranch}\n`; statusText += `\nStatus:\n`; if (gitStatus.trim() === "") { statusText += "Working directory clean - no changes detected\n"; } else { statusText += gitStatus; } statusText += `\nRemotes:\n${gitRemote}`; return { content: [{ type: "text", text: statusText }] }; } catch (error) { // Handle errors (e.g., not a git repository, git not installed, etc.) const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error running git status: ${errorMessage}\n\nPlease ensure:\n1. You are in a git repository\n2. Git is installed and available in PATH\n3. You have proper permissions to access the directory` }], isError: true }; } }
  • Input schema for git-status tool: object with optional 'directory' string property.
    { name: "git-status", description: "Get the current git status of the repository", inputSchema: { type: "object", properties: { directory: { type: "string", description: "Directory path to check git status (defaults to current directory)" } } } },
  • src/index.ts:27-63 (registration)
    Tool list registration handler that declares the 'git-status' tool along with its description and input schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "git-status", description: "Get the current git status of the repository", inputSchema: { type: "object", properties: { directory: { type: "string", description: "Directory path to check git status (defaults to current directory)" } } } }, { name: "git-log", description: "Get recent git commit history", inputSchema: { type: "object", properties: { directory: { type: "string", description: "Directory path to check git log (defaults to current directory)" }, count: { type: "number", description: "Number of recent commits to show (default: 10)", default: 10 } } } } ] }; });

Other 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/narayana-reddy-circles/mcp-git-status'

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