Skip to main content
Glama
puravparab

Gitingest-MCP

by puravparab

git_tree

Retrieve the tree structure of a GitHub repository by specifying the owner, repository name, and optional branch. Streamline repository analysis and navigation with extracted directory and file details.

Instructions

Get the tree structure of a GitHub repository

Args:
	owner: The GitHub organization or username
	repo: The repository name
	branch: Optional branch name (default: None)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branchNo
ownerYes
repoYes

Implementation Reference

  • The handler function for the 'git_tree' tool. It is registered via @mcp.tool() decorator, validates inputs via type hints, fetches repo data using GitIngester, and returns the tree structure or error.
    @mcp.tool()
    async def git_tree(
    	owner: str, 
    	repo: str, 
    	branch: Optional[str] = None
    ) -> Union[str, Dict[str, str]]:
    	"""
    	Get the tree structure of a GitHub repository
    
    	Args:
    		owner: The GitHub organization or username
    		repo: The repository name
    		branch: Optional branch name (default: None)
    	"""
    	url = f"https://github.com/{owner}/{repo}"
    
    	try:
    		# Create GitIngester and fetch data asynchronously
    		ingester = GitIngester(url, branch=branch)
    		await ingester.fetch_repo_data()
    		return ingester.get_tree()
    	except Exception as e:
    		return {
    			"error": f"Failed to get repository tree: {str(e)}. Try https://gitingest.com/{url} instead"
    		}
  • Helper method in GitIngester class that returns the parsed repository tree structure obtained from the external 'ingest' function.
    def get_tree(self) -> Any:
    	"""Returns the repository tree structure."""
    	return self.tree
  • Helper method that asynchronously fetches the repository data (including tree) by calling the external 'ingest' function.
    async def fetch_repo_data(self) -> None:
    	"""Asynchronously fetch and process repository data."""
    	# Run the synchronous ingest function in a thread pool
    	loop = asyncio.get_event_loop()
    	summary, self.tree, self.content = await loop.run_in_executor(
    		None, lambda: ingest(self.url)
    	)
    	self.summary = self._parse_summary(summary)
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 the action ('Get') but doesn't mention permissions, rate limits, error handling, or what the tree structure output entails (e.g., format, depth). This leaves significant gaps for a tool interacting with an external API like GitHub.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with a clear purpose statement followed by parameter explanations. It avoids unnecessary fluff, though the parameter section could be more integrated into the flow rather than a separate 'Args:' block.

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 GitHub API tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the tree structure includes (e.g., files, directories), how it's formatted, or potential errors. For a tool with 3 parameters and external dependencies, more context is needed to ensure reliable 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 0%, so the description must compensate. It adds meaning by explaining 'owner' as 'GitHub organization or username', 'repo' as 'repository name', and 'branch' as 'Optional branch name (default: None)', which clarifies semantics beyond the schema's bare titles. However, it doesn't detail constraints or examples, leaving some ambiguity.

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 verb ('Get') and resource ('tree structure of a GitHub repository'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'git_files' or 'git_summary', which likely serve related but distinct purposes.

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 like 'git_files' or 'git_summary'. It lacks context about what scenarios warrant retrieving a tree structure versus other repository information, leaving the agent with no usage differentiation.

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

Related 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/puravparab/Gitingest-MCP'

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