Skip to main content
Glama
PWalaGov

Enhanced Directory Context MCP Server

by PWalaGov

get_git_context

Extract Git repository context including branch information, recent commits, and working directory status to provide comprehensive project state awareness.

Instructions

Extract Git repository context (branch, recent commits, status)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
include_diffNoInclude current working directory changes
commit_countNoNumber of recent commits to include

Implementation Reference

  • Core handler function that executes Git commands to retrieve repository context: branch, recent commits, status, and optional diff using child_process.
    async getGitContext(includeDiff, commitCount) {
      const { exec } = await import('child_process');
      const { promisify } = await import('util');
      const execAsync = promisify(exec);
      
      let gitContext = '# Git Context\n\n';
      
      try {
        // Check if it's a git repository
        await execAsync('git rev-parse --git-dir', { cwd: this.workingDirectory });
        
        // Get current branch
        const { stdout: branch } = await execAsync('git branch --show-current', { cwd: this.workingDirectory });
        gitContext += `**Current Branch:** ${branch.trim()}\n\n`;
        
        // Get recent commits
        const { stdout: commits } = await execAsync(
          `git log --oneline -${commitCount}`,
          { cwd: this.workingDirectory }
        );
        gitContext += `**Recent Commits:**\n\`\`\`\n${commits}\`\`\`\n\n`;
        
        // Get status
        const { stdout: status } = await execAsync('git status --porcelain', { cwd: this.workingDirectory });
        if (status.trim()) {
          gitContext += `**Working Directory Status:**\n\`\`\`\n${status}\`\`\`\n\n`;
        }
        
        // Get diff if requested
        if (includeDiff) {
          try {
            const { stdout: diff } = await execAsync('git diff HEAD', { cwd: this.workingDirectory });
            if (diff.trim()) {
              gitContext += `**Current Changes:**\n\`\`\`diff\n${diff.slice(0, 2000)}${diff.length > 2000 ? '\n... (truncated)' : ''}\n\`\`\`\n\n`;
            }
          } catch (error) {
            // No diff available
          }
        }
        
      } catch (error) {
        gitContext += 'Not a Git repository or Git not available.\n';
      }
      
      return gitContext;
    }
  • Tool handler wrapper that parses arguments and delegates to getGitContext method, returning formatted response.
    async handleGetGitContext(args) {
      const { include_diff = true, commit_count = 10 } = args;
      const gitContext = await this.getGitContext(include_diff, commit_count);
      
      return {
        content: [
          {
            type: 'text',
            text: gitContext,
          },
        ],
      };
    }
  • Input schema definition and tool registration in the list of available tools.
    {
      name: 'get_git_context',
      description: 'Extract Git repository context (branch, recent commits, status)',
      inputSchema: {
        type: 'object',
        properties: {
          include_diff: {
            type: 'boolean',
            description: 'Include current working directory changes',
            default: true,
          },
          commit_count: {
            type: 'number',
            description: 'Number of recent commits to include',
            default: 10,
          },
        },
      },
    },
  • server.js:469-470 (registration)
    Switch case registration that routes get_git_context tool calls to the handler method.
    case 'get_git_context':
      return await this.handleGetGitContext(args);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states what the tool extracts but doesn't describe how it behaves: it doesn't mention whether it reads from the current directory, requires Git to be installed, handles errors (e.g., if not in a Git repo), or what the output format looks like. For a tool with zero annotation coverage, this leaves significant gaps in understanding its operational traits.

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 highly concise and front-loaded, using a single sentence that efficiently conveys the core purpose without unnecessary words. Every element ('Extract', 'Git repository context', 'branch, recent commits, status') earns its place by specifying the action and key outputs. There's no redundancy or wasted phrasing.

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

Completeness2/5

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

Given the complexity of a Git context tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral aspects (e.g., error handling, dependencies), output format, and usage context. While the schema covers parameters well, the description doesn't provide enough information for an agent to fully understand how to invoke and interpret results, especially without structured output documentation.

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?

The description adds no parameter-specific information beyond what the input schema provides. With 100% schema description coverage, the schema fully documents both parameters ('include_diff' and 'commit_count') with descriptions and defaults. The baseline is 3, as the description doesn't compensate with additional context like examples or edge cases, but it also doesn't detract from the schema's completeness.

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 tool's purpose with specific verbs ('Extract') and resources ('Git repository context'), listing the key elements retrieved (branch, recent commits, status). It distinguishes from siblings like 'get_directory_structure' or 'get_file_contents' by focusing on Git metadata rather than file system operations. However, it doesn't explicitly differentiate from all siblings (e.g., 'analyze_project_context' might overlap in scope).

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. It doesn't mention prerequisites (e.g., requires a Git repository), exclusions (e.g., not for non-Git projects), or comparisons with siblings like 'analyze_project_context' that might offer similar functionality. Usage is implied by the name and purpose but not explicitly stated.

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

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/PWalaGov/File-Control-MCP'

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