github_get_pr_status
Retrieve the status and check runs for a GitHub pull request by specifying the repository owner, name, and PR number.
Instructions
Get the status and check runs for a pull request
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pr_number | Yes | ||
| repo_name | Yes | ||
| repo_owner | Yes |
Implementation Reference
- src/mcp_server_git/github/api.py:522-581 (handler)Core implementation of the github_get_pr_status tool. Fetches PR state, mergeability, and check runs status from GitHub API using aiohttp client.async def github_get_pr_status(repo_owner: str, repo_name: str, pr_number: int) -> str: """Get the status and check runs for a pull request""" try: async with github_client_context() as client: # Get PR details pr_response = await client.get( f"/repos/{repo_owner}/{repo_name}/pulls/{pr_number}" ) if pr_response.status != 200: return f"❌ Failed to get PR #{pr_number}: {pr_response.status}" pr_data = await pr_response.json() head_sha = pr_data["head"]["sha"] output = [f"Status for PR #{pr_number}:\n"] output.append(f"State: {pr_data.get('state', 'N/A')}") output.append(f"Mergeable: {pr_data.get('mergeable', 'N/A')}") output.append(f"Merge State: {pr_data.get('mergeable_state', 'N/A')}") output.append("") # Get check runs checks_response = await client.get( f"/repos/{repo_owner}/{repo_name}/commits/{head_sha}/check-runs" ) if checks_response.status == 200: checks_data = await checks_response.json() check_runs = checks_data.get("check_runs", []) if check_runs: output.append("Check Runs:") for run in check_runs: status_emoji = { "completed": "✅" if run.get("conclusion") == "success" else "❌", "in_progress": "🔄", "queued": "⏳", }.get(run["status"], "❓") output.append( f" {status_emoji} {run['name']}: {run['status']}" ) if run.get("conclusion"): output.append(f" Conclusion: {run['conclusion']}") return "\n".join(output) except ValueError as auth_error: logger.error(f"Authentication error getting PR status: {auth_error}") return f"❌ {str(auth_error)}" except ConnectionError as conn_error: logger.error(f"Connection error getting PR status: {conn_error}") return f"❌ Network connection failed: {str(conn_error)}" except Exception as e: logger.error( f"Unexpected error getting PR status for PR #{pr_number}: {e}", exc_info=True, ) return f"❌ Error getting PR status: {str(e)}"
- Pydantic model defining input schema for github_get_pr_status tool: repository owner, name, and PR number.class GitHubGetPRStatus(BaseModel): repo_owner: str repo_name: str pr_number: int
- src/mcp_server_git/core/handlers.py:255-257 (registration)Registers the github_get_pr_status handler by wrapping the api function with error handling and argument mapping in the GitHub handlers dictionary."github_get_pr_status": self._create_github_handler( github_get_pr_status, ["repo_owner", "repo_name", "pr_number"] ),
- src/mcp_server_git/core/tools.py:392-400 (registration)Registers tool metadata, schema, and description in the central ToolRegistry for github_get_pr_status.ToolDefinition( name=GitTools.GITHUB_GET_PR_STATUS, category=ToolCategory.GITHUB, description="Get the status and check runs for a pull request", schema=GitHubGetPRStatus, handler=placeholder_handler, requires_repo=False, requires_github_token=True, ),
- src/mcp_server_git/core/tools.py:47-47 (registration)Defines the constant name for the github_get_pr_status tool in GitTools enum.GITHUB_GET_PR_STATUS = "github_get_pr_status"