list_repositories
Lists all repositories in an organization, optionally filtered by search query, to help developers manage and navigate codebases.
Instructions
List all repositories in the organization.
Args:
search_query: Optional search term to filter repositories
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| search_query | No |
Implementation Reference
- The main handler function for the 'list_repositories' tool, decorated with @mcp.tool() for registration. It makes an API request to list repositories with optional search query and handles the response.@mcp.tool() def list_repositories(search_query: str = None) -> str: """ List all repositories in the organization. Args: search_query: Optional search term to filter repositories """ payload = {} if search_query: payload["searchQuery"] = search_query response, error = make_api_request("repositories/list", payload) if error: return error if response.status_code == 200: return process_repositories_response(response.json()) elif response.status_code == 401: return "Error: Unauthorized - check API credentials" elif response.status_code == 400: return f"Error: Bad request - {response.text}" else: return f"Error: API returned status {response.status_code}: {response.text}"
- Supporting helper function that formats the raw API response from the repositories list endpoint into a human-readable string output.def process_repositories_response(raw_response): """Process repositories list response into readable format.""" # Handle list response directly if isinstance(raw_response, list): repos = raw_response else: if "error" in raw_response: return f"Error: {raw_response['error']}" repos = raw_response.get("repositories", raw_response.get("items", [])) if not repos: return "No repositories found." total_count = len(repos) result = f"Found {total_count} repository(ies).\n\n" for i, repo in enumerate(repos, 1): result += f"Repository {i}:\n" result += f" ID: {repo.get('id', 'N/A')}\n" result += f" Name: {repo.get('name', 'N/A')}\n" result += f" Full Name: {repo.get('fullName', repo.get('full_name', 'N/A'))}\n" result += f" Provider: {repo.get('provider', 'N/A')}\n" result += f" Default Branch: {repo.get('defaultBranch', repo.get('scanBranch', 'N/A'))}\n" result += f" PR Scanning: {repo.get('prScanningEnabled', 'N/A')}\n" result += f" Last Scanned: {repo.get('lastScannedAt', 'N/A')}\n" result += "\n" return result