""" Repository-level stats tool. """ from mcp.server.fastmcp import Context from pmcp.mcp_server.github_server.services.repo import RepoService from pmcp.mcp_server.github_server.github import github_client service = RepoService(github_client) async def get_repo_stats(ctx: Context, owner: str, repo: str): """ Gets the statistics of the repository Args: ctx: FastMCP request context (handles errors). owner (str): Repository owner. repo (str): Repository name. Returns: {"stars": 0, "forks": 0, "watchers": 0, "open_issues": 0} """ try: data = await service.get_stats(owner, repo) return { "stars": data["stargazers_count"], "forks": data["forks_count"], "watchers": data["watchers_count"], "open_issues": data["open_issues_count"], } except Exception as exc: error_msg = f"Failed to get statistics of repository {repo}. Error: {str(exc)}" await ctx.error(str(exc)) raise