Skip to main content
Glama
AstroMined
by AstroMined

get_repository

Fetch detailed information about a GitHub repository, including owner and repository name, using PyGithub MCP Server for streamlined GitHub interactions.

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 for get_repository. Validates input using RepositoryRef schema, calls the operations.repositories.get_repository helper, handles errors, and returns formatted MCP 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 RepositoryRef used for input validation in the 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 with the MCP server using register_tools.
    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 implementation of get_repository operation using GitHubClient to fetch repository details and convert to schema.
    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")

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