Skip to main content
Glama
AstroMined

PyGithub MCP Server

by AstroMined

get_repository

Retrieve GitHub repository details including owner, name, and metadata for accessing project information and managing code repositories.

Instructions

Get details about a GitHub repository.

Args:
    params: Dictionary with repository parameters
        - owner: Repository owner (username or organization)
        - repo: Repository name

Returns:
    MCP response with repository details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • MCP tool handler: validates input with RepositoryRef, calls operations.repositories.get_repository(owner, repo), returns JSON-formatted repository details or error response.
    @tool()
    def get_repository(params: Dict) -> Dict:
        """Get details about a GitHub repository.
    
        Args:
            params: Dictionary with repository parameters
                - owner: Repository owner (username or organization)
                - repo: Repository name
    
        Returns:
            MCP response with repository details
        """
        try:
            logger.debug(f"get_repository called with params: {params}")
            # Convert dict to Pydantic model
            repo_params = RepositoryRef(**params)
            
            # Call operation
            result = repositories.get_repository(repo_params.owner, repo_params.repo)
            
            logger.debug(f"Got result: {result}")
            return {
                "content": [{"type": "text", "text": json.dumps(result, indent=2)}]
            }
        except ValidationError as e:
            logger.error(f"Validation error: {e}")
            return {
                "content": [{"type": "error", "text": f"Validation error: {str(e)}"}],
                "is_error": True
            }
        except GitHubError as e:
            logger.error(f"GitHub error: {e}")
            return {
                "content": [{"type": "error", "text": format_github_error(e)}],
                "is_error": True
            }
        except Exception as e:
            logger.error(f"Unexpected error: {e}")
            logger.error(traceback.format_exc())
            error_msg = str(e) if str(e) else "An unexpected error occurred"
            return {
                "content": [{"type": "error", "text": f"Internal server error: {error_msg}"}],
                "is_error": True
            }
  • Pydantic schema for repository reference (owner, repo) used for input validation in get_repository tool.
    class RepositoryRef(BaseModel):
        """Reference to a GitHub repository."""
    
        model_config = ConfigDict(strict=True)
        
        owner: str = Field(..., description="Repository owner (username or organization)")
        repo: str = Field(..., description="Repository name")
    
        @field_validator('owner')
        @classmethod
        def validate_owner(cls, v):
            """Validate that owner is not empty."""
            if not v.strip():
                raise ValueError("owner cannot be empty")
            return v
    
        @field_validator('repo')
        @classmethod
        def validate_repo(cls, v):
            """Validate that repo is not empty."""
            if not v.strip():
                raise ValueError("repo cannot be empty")
            return v
  • Registration of repository tools including get_repository via register_tools call in the module's register function.
    def register(mcp: FastMCP) -> None:
        """Register all repository tools with the MCP server.
    
        Args:
            mcp: The MCP server instance
        """
        from pygithub_mcp_server.tools import register_tools
        from .tools import (
            get_repository,
            create_repository,
            fork_repository,
            search_repositories,
            get_file_contents,
            create_or_update_file,
            push_files,
            create_branch,
            list_commits
        )
    
        # Register all repository tools
        register_tools(mcp, [
            get_repository,
            create_repository,
            fork_repository,
            search_repositories,
            get_file_contents,
            create_or_update_file,
            push_files,
            create_branch,
            list_commits
        ])
  • Core operation: fetches repository using GitHubClient.get_repo and converts to schema using convert_repository.
    def get_repository(owner: str, repo: str) -> Dict[str, Any]:
        """Get a repository by owner and name.
    
        Args:
            owner: Repository owner (user or organization)
            repo: Repository name
    
        Returns:
            Repository data in our schema
    
        Raises:
            GitHubError: If repository access fails
        """
        logger.debug(f"Getting repository: {owner}/{repo}")
        try:
            client = GitHubClient.get_instance()
            repository = client.get_repo(f"{owner}/{repo}")
            return convert_repository(repository)
        except GithubException as e:
            logger.error(f"GitHub exception when getting repo {owner}/{repo}: {str(e)}")
            raise client._handle_github_exception(e, resource_hint="repository")
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves repository details but fails to mention critical aspects like whether it's read-only, requires authentication, has rate limits, or what the response format entails (e.g., JSON structure, error handling). This leaves significant gaps in understanding the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the core purpose followed by structured sections for arguments and returns. Each sentence serves a clear function, with no redundant information, though the 'Returns' section is vague ('MCP response with repository details') and could be more specific.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (interacting with GitHub API), lack of annotations, no output schema, and minimal schema coverage, the description is incomplete. It doesn't cover authentication needs, error cases, response structure, or usage context, making it inadequate for an agent to reliably invoke the tool without additional assumptions.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds substantial value beyond the input schema, which has 0% coverage and only specifies a generic 'params' object. It clarifies that 'params' is a dictionary with 'owner' and 'repo' keys, providing essential semantic details that the schema lacks. However, it doesn't explain data types or constraints for these parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'Get details about a GitHub repository' with a specific verb ('Get') and resource ('GitHub repository'), making it immediately understandable. However, it doesn't differentiate from sibling tools like 'search_repositories' or 'get_file_contents', which also retrieve GitHub data but for different resources or with different scopes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description lacks any mention of prerequisites, context for usage, or comparisons to sibling tools such as 'search_repositories' (for broader searches) or 'get_issue' (for specific issue details), leaving the agent without direction on tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AstroMined/pygithub-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server