get_leaders
Retrieve a ranked list of users based on coding activity to track team productivity and identify top contributors in development workflows.
Instructions
List of users ranked by coding activity in descending order.
operationId: get-wakatime-leaders summary: List of users ranked by coding activity in descending order. description: Mimics https://wakatime.com/developers#leaders tags: [wakatime] responses: 200: description: OK schema: v1.LeadersViewModel
Requires ApiKeyAuth: Set header Authorization to your API Key
encoded as Base64 and prefixed with Basic.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp_tools/leaders.py:7-31 (handler)The MCP tool handler function for "get_leaders". It uses dependency injection to get the Wakapi client and calls its get_leaders method, with error handling.@app.tool async def get_leaders() -> LeadersViewModel: """List of users ranked by coding activity in descending order. operationId: get-wakatime-leaders summary: List of users ranked by coding activity in descending order. description: Mimics https://wakatime.com/developers#leaders tags: [wakatime] responses: 200: description: OK schema: v1.LeadersViewModel Requires ApiKeyAuth: Set header `Authorization` to your API Key encoded as Base64 and prefixed with `Basic`. """ from mcp_tools.dependency_injection import get_wakapi_client client = get_wakapi_client() try: return await client.get_leaders() except Exception as e: raise ValueError(f"Failed to fetch leaders: {e}") from e
- main.py:136-138 (registration)The import statement in main.py that triggers the registration of the get_leaders tool via its @app.tool decorator.from mcp_tools.leaders import get_leaders _ = get_leaders # Trigger registration
- Pydantic BaseModel defining the structure of the LeadersViewModel, which is the return type of the get_leaders tool.class LeadersViewModel(BaseModel): """Model for leaders view.""" current_user: Optional[LeadersCurrentUser] = None data: list[LeadersEntry] language: str page: int range: LeadersRange total_pages: int
- The WakapiClient.get_leaders() method called by the tool handler, which makes the HTTP request to the Wakapi API and validates the response using LeadersViewModel.async def get_leaders(self) -> LeadersViewModel: """ List of users ranked by coding activity in descending order. operationId: get-wakatime-leaders summary: List of users ranked by coding activity in descending order. description: Mimics https://wakatime.com/developers#leaders tags: [wakatime] responses: 200: description: OK schema: v1.LeadersViewModel Requires ApiKeyAuth: Set header `Authorization` to your API Key encoded as Base64 and prefixed with `Basic`. """ url = f"{self.base_url}{self.api_path}/leaders" logger = logging.getLogger(__name__) logger.debug("Calling real Wakapi API for get_leaders") try: response = await self.client.get(url, headers=self._get_headers()) response.raise_for_status() except httpx.HTTPStatusError as e: raise ApiError( f"Wakapi API error in get_leaders: {e.response.status_code} - " f"{e.response.text}", details={ "status_code": e.response.status_code, "method": "get_leaders", }, ) from e json_data = response.json() return LeadersViewModel.model_validate(json_data)