get_stats
Retrieve coding statistics for a specific user across various time ranges, with optional filters for projects, languages, editors, and operating systems to analyze development activity patterns.
Instructions
Retrieve statistics for a given user.
operationId: get-wakatime-stats summary: Retrieve statistics for a given user description: Mimics https://wakatime.com/developers#stats tags: [wakatime] parameters:
name: user in: path description: User ID to fetch data for (or 'current') required: true schema: type: string
name: range in: path description: Range interval identifier required: true schema: type: string enum: [ "today", "yesterday", "week", "month", "year", "7_days", "last_7_days", "30_days", "last_30_days", "6_months", "last_6_months", "12_months", "last_12_months", "last_year", "any", "all_time" ]
name: project in: query description: Project to filter by schema: type: string
name: language in: query description: Language to filter by schema: type: string
name: editor in: query description: Editor to filter by schema: type: string
name: operating_system in: query description: OS to filter by schema: type: str
name: machine in: query description: Machine to filter by schema: type: string
name: label in: query description: Project label to filter by schema: type: string responses: 200: description: OK schema: v1.StatsViewModel
Requires ApiKeyAuth: Set header Authorization to your API Key
encoded as Base64 and prefixed with Basic.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| editor | No | ||
| label | No | ||
| language | No | ||
| machine | No | ||
| operating_system | No | ||
| project | No | ||
| range | Yes | ||
| user | Yes |
Implementation Reference
- src/mcp_tools/stats.py:9-101 (handler)The core handler function for the 'get_stats' MCP tool. It is decorated with @app.tool, defines input parameters with types and docstring-based OpenAPI schema, fetches data via Wakapi client, and returns StatsViewModel.@app.tool async def get_stats( user: str, range: str, project: Optional[str] = None, language: Optional[str] = None, editor: Optional[str] = None, operating_system: Optional[str] = None, machine: Optional[str] = None, label: Optional[str] = None, ) -> StatsViewModel: """ Retrieve statistics for a given user. operationId: get-wakatime-stats summary: Retrieve statistics for a given user description: Mimics https://wakatime.com/developers#stats tags: [wakatime] parameters: - name: user in: path description: User ID to fetch data for (or 'current') required: true schema: type: string - name: range in: path description: Range interval identifier required: true schema: type: string enum: [ "today", "yesterday", "week", "month", "year", "7_days", "last_7_days", "30_days", "last_30_days", "6_months", "last_6_months", "12_months", "last_12_months", "last_year", "any", "all_time" ] - name: project in: query description: Project to filter by schema: type: string - name: language in: query description: Language to filter by schema: type: string - name: editor in: query description: Editor to filter by schema: type: string - name: operating_system in: query description: OS to filter by schema: type: str - name: machine in: query description: Machine to filter by schema: type: string - name: label in: query description: Project label to filter by schema: type: string responses: 200: description: OK schema: v1.StatsViewModel 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: stats_data: StatsViewModel = await client.get_stats( range=range, user=user, project=project, language=language, editor=editor, operating_system=operating_system, machine=machine, label=label, ) return stats_data except Exception as e: raise ValueError(f"Failed to fetch stats: {e}") from e
- main.py:130-132 (registration)Registration of the get_stats tool by importing it in initialize_tools(), which triggers the @app.tool decorator registration.from mcp_tools.stats import get_stats _ = get_stats # Trigger registration
- src/mcp_tools/stats.py:20-83 (schema)OpenAPI-style schema definition in the docstring of get_stats, defining input parameters, enums, and output schema reference.""" Retrieve statistics for a given user. operationId: get-wakatime-stats summary: Retrieve statistics for a given user description: Mimics https://wakatime.com/developers#stats tags: [wakatime] parameters: - name: user in: path description: User ID to fetch data for (or 'current') required: true schema: type: string - name: range in: path description: Range interval identifier required: true schema: type: string enum: [ "today", "yesterday", "week", "month", "year", "7_days", "last_7_days", "30_days", "last_30_days", "6_months", "last_6_months", "12_months", "last_12_months", "last_year", "any", "all_time" ] - name: project in: query description: Project to filter by schema: type: string - name: language in: query description: Language to filter by schema: type: string - name: editor in: query description: Editor to filter by schema: type: string - name: operating_system in: query description: OS to filter by schema: type: str - name: machine in: query description: Machine to filter by schema: type: string - name: label in: query description: Project label to filter by schema: type: string responses: 200: description: OK schema: v1.StatsViewModel Requires ApiKeyAuth: Set header `Authorization` to your API Key encoded as Base64 and prefixed with `Basic`. """