clone_repo
Clone a repository into the MCP cache to prepare it for code analysis. Required before using analysis endpoints like get_source_repo_map.
Instructions
Clone a repository into MCP server's cache and prepare it for analysis.
This tool must be called before using analysis endpoints like get_source_repo_map
or get_repo_documentation. It copies the repository into MCP's cache and
automatically starts building a repository map in the background.
IMPORTANT - BEFORE CLONING:
1. CHECK IF ALREADY CACHED: Use list_cached_repository_branches(url) first to avoid
redundant clone attempts. Returns empty list if not cached, or existing branches if cached.
2. VERIFY DEFAULT BRANCH NAME: Many repositories use "master", "develop", or other names
instead of "main". If branch is not specified and clone fails:
- Use list_remote_branches(url) to discover available branches
- Look for "main", "master", "develop", or check repo documentation
- Explicitly specify the correct branch parameter
3. AFTER CLONING: The cached repository can become stale over time. Before analysis,
consider using refresh_repo() to ensure you're working with the latest code.
Args:
url (str): URL of remote repository or path to local repository to analyze
branch (str, optional): Specific branch to clone for analysis. Defaults to "main" if not
specified, but many repositories use "master" or other names - verify first!
cache_strategy (str, optional): Cache strategy - "shared" (default) or "per-branch"
- "shared": One cache entry per repo, switch branches in place
- "per-branch": Separate cache entries for each branch (useful for PR reviews)
Returns:
dict: Response with format:
{
"status": "pending" | "already_cloned" | "switched_branch" | "error",
"path": str, # Cache location where repo is being cloned
"message": str, # Status message about clone and analysis
"cache_strategy": str, # Strategy used for caching
"current_branch": str, # (if applicable) Current active branch
"previous_branch": str, # (if switched) Previous branch name
}
Recommended Workflow:
1. Check cache: cached = list_cached_repository_branches(url)
2. If not cached, discover branches: branches = list_remote_branches(url)
3. Clone with correct branch: clone_repo(url, branch=discovered_branch)
4. Before analysis, refresh if needed: refresh_repo(url)
5. Perform analysis: get_source_repo_map(url, ...)
Note:
- This is a setup operation for MCP analysis only
- Does not modify the source repository
- Repository map building starts automatically after clone completes
- Use get_source_repo_map to check analysis status and retrieve results
- Per-branch strategy allows simultaneous access to different branches
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | ||
| branch | No | ||
| cache_strategy | No | shared |