Skip to main content
Glama
razorback16

MCP Git Repo Browser

git_read_important_files

Read contents of specified files from any Git repository to quickly access important documentation, configuration, or source code without cloning the entire project.

Instructions

Read the contents of specified files in a given git repository.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_urlYesThe URL of the Git repository
file_pathsYesList of file paths to read (relative to repository root)

Implementation Reference

  • The main handler function that clones the Git repository to a temporary directory, reads the contents of the specified file paths relative to the repo root, handles missing files and read errors, and returns a JSON object with file contents or error messages as text content.
    async handleGitReadImportantFiles({ repo_url, file_paths }) {
      try {
        const repoPath = await cloneRepo(repo_url);
        const results = {};
    
        for (const filePath of file_paths) {
          const fullPath = path.join(repoPath, filePath);
          try {
            if (await fs.pathExists(fullPath)) {
              results[filePath] = await fs.readFile(fullPath, 'utf8');
            } else {
              results[filePath] = 'Error: File not found';
            }
          } catch (error) {
            results[filePath] = `Error reading file: ${error.message}`;
          }
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(results, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({ error: `Failed to process repository: ${error.message}` }, null, 2),
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema for the tool, specifying repo_url as a string and file_paths as an array of strings, both required.
    inputSchema: {
      type: 'object',
      properties: {
        repo_url: {
          type: 'string',
          description: 'The URL of the Git repository',
        },
        file_paths: {
          type: 'array',
          items: { type: 'string' },
          description: 'List of file paths to read (relative to repository root)',
        },
      },
      required: ['repo_url', 'file_paths'],
    },
  • src/index.js:118-136 (registration)
    Tool registration in the ListToolsRequestHandler response, including name, description, and input schema.
    {
      name: 'git_read_important_files',
      description: 'Read the contents of specified files in a given git repository.',
      inputSchema: {
        type: 'object',
        properties: {
          repo_url: {
            type: 'string',
            description: 'The URL of the Git repository',
          },
          file_paths: {
            type: 'array',
            items: { type: 'string' },
            description: 'List of file paths to read (relative to repository root)',
          },
        },
        required: ['repo_url', 'file_paths'],
      },
    },
  • Helper function to clone the Git repository to a deterministic temporary directory based on repo URL hash, reusing if valid, cleaning up on errors.
    async function cloneRepo(repoUrl) {
      // Create deterministic directory name based on repo URL
      const repoHash = crypto.createHash('sha256')
        .update(repoUrl)
        .digest('hex')
        .slice(0, 12);
      const tempDir = path.join(os.tmpdir(), `github_tools_${repoHash}`);
    
      // Check if directory exists and is a valid git repo
      if (await fs.pathExists(tempDir)) {
        try {
          const git = simpleGit(tempDir);
          const remotes = await git.getRemotes(true);
          if (remotes.length > 0 && remotes[0].refs.fetch === repoUrl) {
            return tempDir;
          }
        } catch (error) {
          // If there's any error with existing repo, clean it up
          await fs.remove(tempDir);
        }
      }
    
      // Create directory and clone repository
      await fs.ensureDir(tempDir);
      try {
        await simpleGit().clone(repoUrl, tempDir);
        return tempDir;
      } catch (error) {
        // Clean up on error
        await fs.remove(tempDir);
        throw new Error(`Failed to clone repository: ${error.message}`);
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions reading file contents but doesn't specify important behaviors like error handling (e.g., what happens if files don't exist), authentication requirements, rate limits, or output format. This leaves significant gaps for a tool that interacts with external repositories.

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 a single, clear sentence that efficiently conveys the core functionality without unnecessary words. It's front-loaded with the essential action and resource, making it easy for an agent to parse quickly. Every word earns its place.

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 interacting with git repositories (external systems, potential errors, authentication), the description is incomplete. With no annotations and no output schema, it fails to address critical aspects like return values, error conditions, or security requirements, leaving the agent under-informed for safe and effective use.

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?

Schema description coverage is 100%, so the input schema already documents both parameters thoroughly. The description adds no additional semantic context beyond what's in the schema (e.g., it doesn't clarify path conventions or URL formats), resulting in the baseline score of 3 for adequate but non-enhancing parameter documentation.

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 action ('Read the contents') and resource ('specified files in a given git repository'), making the purpose immediately understandable. It doesn't differentiate from the sibling tool 'git_directory_structure', which appears to serve a different purpose (listing structure vs reading file contents), so it earns a 4 rather than a 5.

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 or any contextual prerequisites. It simply states what the tool does without indicating scenarios where it's appropriate or inappropriate, leaving the agent to infer usage from the tool name and parameters alone.

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/razorback16/mcp-git-repo-browser'

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