Skip to main content
Glama
bsreeram08

Git Repo Browser MCP

git_directory_structure

Clone Git repositories to view their directory structure in a tree format, enabling users to explore repository organization without downloading files locally.

Instructions

Clone a Git repository and return its directory structure in a tree format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_urlYesThe URL of the Git repository

Implementation Reference

  • The core handler function for the git_directory_structure tool. Clones the Git repository using cloneRepo and generates a directory tree using getDirectoryTree, returning the tree as text content or an error message.
    export async function handleGitDirectoryStructure({ repo_url }) {
      try {
        const repoPath = await cloneRepo(repo_url);
        const tree = await getDirectoryTree(repoPath);
        return {
          content: [
            {
              type: "text",
              text: tree,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error: ${error.message}`,
            },
          ],
          isError: true,
        };
      }
  • Defines the tool metadata including name, description, and input schema (requires repo_url string) for use in MCP tool listing.
    {
      name: "git_directory_structure",
      description:
        "Clone a Git repository and return its directory structure in a tree format.",
      inputSchema: {
        type: "object",
        properties: {
          repo_url: {
            type: "string",
            description: "The URL of the Git repository",
          },
        },
        required: ["repo_url"],
      },
  • src/server.js:900-900 (registration)
    Registers the tool name 'git_directory_structure' by mapping it to the handleGitDirectoryStructure handler function in the handlersMap.
    git_directory_structure: handleGitDirectoryStructure,
  • src/server.js:883-883 (registration)
    Provides an alias 'git_ls' that maps to the 'git_directory_structure' tool for user-friendly command naming.
    git_ls: "git_directory_structure",

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