list_repositories
Retrieve a list of all Git repositories stored in a specified directory path using the Git MCP server, for easy management and access.
Instructions
List all git repositories in the configured path
Returns:
List of repository names
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- git_mcp/server.py:144-162 (handler)The main handler function for the 'list_repositories' tool. It retrieves the git_repos_path from the context, lists directories containing a .git folder, and returns their names as a list of strings. The @mcp.tool() decorator registers this function as an MCP tool.@mcp.tool() def list_repositories(ctx: Context) -> List[str]: """List all git repositories in the configured path Returns: List of repository names """ git_repos_path = ctx.request_context.lifespan_context.git_repos_path if not os.path.exists(git_repos_path): raise ValueError(f"Git repositories path does not exist: {git_repos_path}") repos = [] for item in os.listdir(git_repos_path): item_path = os.path.join(git_repos_path, item) if os.path.isdir(item_path) and os.path.exists(os.path.join(item_path, ".git")): repos.append(item) return repos