index_repository
Analyze and query a GitHub repository's codebase by indexing it. Required step before asking questions about architecture, tech stack, or code structure.
Instructions
Index a GitHub repository to analyze its codebase. This must be done before asking questions about the repository.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_url | Yes | The GitHub repository URL to index (format: https://github.com/username/repo). |
Implementation Reference
- src/github_chat_mcp/server.py:16-43 (handler)The handler function for the 'index_repository' tool, decorated with @mcp.tool() for registration. Validates the GitHub repo URL and sends a POST request to the GitHub Chat API (/verify) to index the repository.@mcp.tool() def index_repository( repo_url: str = Field( description="The GitHub repository URL to index (format: https://github.com/username/repo)." ), ) -> str: """Index a GitHub repository to analyze its codebase. This must be done before asking questions about the repository.""" try: if not repo_url: raise ValueError("Repository URL cannot be empty.") if not repo_url.startswith("https://github.com/"): raise ValueError("Repository URL must be in the format: https://github.com/username/repo") # Call the verify API endpoint response = requests.post( f"{GITHUB_CHAT_API_BASE}/verify", headers={"Content-Type": "application/json"}, json={"repo_url": repo_url} ) if response.status_code != 200: return f"Error indexing repository: {response.text}" return f"Successfully indexed repository: {repo_url}. You can now ask questions about this repository." except Exception as e: return f"Error: {str(e) or repr(e)}"
- src/github_chat_mcp/server.py:16-16 (registration)The @mcp.tool() decorator registers the index_repository function as an MCP tool.@mcp.tool()
- src/github_chat_mcp/server.py:18-20 (schema)Pydantic Field defining the input schema for the repo_url parameter.repo_url: str = Field( description="The GitHub repository URL to index (format: https://github.com/username/repo)." ),