Skip to content

feat: Gitlab list repository tree tool #1337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

BobMerkus
Copy link
Contributor

This PR adds a list_repository_tree tool for the Gitlab MCP, so AI agents can explore repositories interactively.

Description

This PR adds a list_repository_tree tool for the Gitlab MCP, so It can explore a repository interactively. It wraps around the corresponding List repository tree.

Server Details

  • Server: gitlab
  • Changes to: tools

Motivation and Context

The AI agents are in the dark regarding the structure of a repository and can only read specific files in their entirety. This PR adds the list_repository_tree to allow the AI to explore the repository before reading/updating specific files.

How Has This Been Tested?

Yes, have tested locally using Claude Sonnet 3.7

Breaking Changes

No

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • I have updated the server's README accordingly
  • I have tested this with an LLM client
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options

Additional context

See List repository tree - Gitlab Documentation.

Get a list of repository files and directories in a project. This endpoint can be accessed without authentication if the repository is publicly accessible.

This command provides essentially the same features as the git ls-tree command. For more information, refer to the section Tree Objects in the Git internals documentation.

Attribute Type Required Description
id integer or string yes The ID or URL-encoded path of the project.
page_token string no The tree record ID at which to fetch the next page. Used only with keyset pagination.
pagination string no If keyset, use the keyset-based pagination method.
path string no The path inside the repository. Used to get content of subdirectories.
per_page integer no Number of results to show per page. If not specified, defaults to 20. For more information, see Pagination.
recursive boolean no Boolean value used to get a recursive tree. Default is false.
ref string no The name of a repository branch or tag or, if not given, the default branch.

@olaservo olaservo added enhancement New feature or request server-gitlab Reference implementation for the GitLab MCP server - src/gitlab labels Apr 18, 2025
@BobMerkus BobMerkus force-pushed the feat/gitlab-list-repository-tree branch from d432335 to 73a66b3 Compare April 22, 2025 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request server-gitlab Reference implementation for the GitLab MCP server - src/gitlab
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants