Skip to main content
Glama

get_stats

Retrieve user coding statistics from Wakatime data for specified time ranges and filters to analyze development productivity.

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

TableJSON Schema
NameRequiredDescriptionDefault
userYes
rangeYes
projectNo
languageNo
editorNo
operating_systemNo
machineNo
labelNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYes

Implementation Reference

  • Handler function for the 'get_stats' MCP tool. Decorated with @app.tool, defines input parameters with type hints and detailed OpenAPI-style docstring for schema validation. Calls wakapi client to fetch and return 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)
    Explicit import of get_stats function in initialize_tools() to trigger its automatic registration via the @app.tool decorator.
    from mcp_tools.stats import get_stats
    
    _ = get_stats  # Trigger registration
  • Pydantic model defining the output schema (StatsViewModel) returned by the get_stats tool.
    class StatsViewModel(BaseModel):
        """Model for stats view."""
    
        data: StatsData
  • Dependency injection helper function used by the handler to obtain the WakapiClient instance for API calls.
    def get_wakapi_client() -> WakapiClient:
        """Get global Wakapi client."""
        return _injector.get_wakapi_client()
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions authentication requirements ('Requires ApiKeyAuth') and references an external API, which adds some behavioral context. However, it lacks details on rate limits, error handling, or response structure beyond the HTTP 200 code. The description doesn't contradict any annotations, as none exist.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is structured but verbose, including OpenAPI-like details (operationId, tags, parameters, responses) that may be redundant with the input schema. The core purpose is stated upfront, but the additional technical specifications could be streamlined. It's not excessively long but includes elements that might not earn their place in a tool description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 8 parameters with 0% schema coverage and an output schema present, the description partially compensates by listing parameters and noting authentication. However, it lacks context on sibling tool differentiation, error cases, or usage scenarios. The output schema existence reduces the need to describe return values, but overall completeness is moderate due to missing operational guidance.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It lists all parameters with brief descriptions (e.g., 'User ID to fetch data for', 'Range interval identifier'), which adds meaning beyond the schema's titles. However, it doesn't explain parameter interactions, default behaviors, or provide examples, leaving gaps for the agent to infer usage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Retrieve statistics for a given user.' It specifies the verb ('Retrieve') and resource ('statistics'), and mentions the user context. However, it doesn't explicitly differentiate from sibling tools like 'get_user' or 'get_project_detail', which might also retrieve user-related data.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions mimicking an external API reference but doesn't explain when to choose this over sibling tools like 'get_user' or 'get_projects'. There's no mention of prerequisites, such as authentication requirements, which are only noted in a separate section.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/impure0xntk/mcp-wakapi'

If you have feedback or need assistance with the MCP directory API, please join our Discord server