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
| Name | Required | Description | Default |
|---|---|---|---|
| repo_url | Yes | The 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, }; }
- src/server.js:94-107 (schema)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",