Skip to main content
Glama
8bitgentleman

ActivityWatch MCP Server

activitywatch_query_examples

Access properly formatted query examples to retrieve time tracking data, application usage, browsing history, and productivity patterns from ActivityWatch.

Instructions

Get examples of properly formatted queries for the ActivityWatch MCP server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that returns a static markdown document containing examples of correct query formats for ActivityWatch tools, instructions, and common error patterns.
      handler: async () => {
        const examples = `
    # ActivityWatch MCP Query Examples
    
    Here are several examples of properly formatted queries for the ActivityWatch MCP server.
    
    ## CORRECT FORMAT
    
    All queries must follow this structure:
    
    \`\`\`json
    {
      "timeperiods": ["2024-10-28/2024-10-29"],
      "query": ["events = query_bucket('aw-watcher-window_hostname'); RETURN = events;"]
    }
    \`\`\`
    
    Note that:
    1. 'timeperiods' is an array with date ranges in the format "start/end"
    2. 'query' is an array with a SINGLE STRING containing ALL statements
    3. All query statements are in the same string, separated by semicolons
    
    ## COMMONLY USED QUERIES
    
    ### Get Active Window Events
    
    \`\`\`json
    {
      "timeperiods": ["2024-10-28/2024-10-29"],
      "query": ["window_events = query_bucket(find_bucket('aw-watcher-window_')); RETURN = window_events;"]
    }
    \`\`\`
    
    ### Get Active Window Events When Not AFK
    
    \`\`\`json
    {
      "timeperiods": ["2024-10-28/2024-10-29"],
      "query": ["window_events = query_bucket(find_bucket('aw-watcher-window_')); afk_events = query_bucket(find_bucket('aw-watcher-afk_')); not_afk = filter_keyvals(afk_events, 'status', ['not-afk']); active_events = filter_period_intersect(window_events, not_afk); RETURN = active_events;"]
    }
    \`\`\`
    
    ### Group Events by App
    
    \`\`\`json
    {
      "timeperiods": ["2024-10-28/2024-10-29"],
      "query": ["window_events = query_bucket(find_bucket('aw-watcher-window_')); events_by_app = merge_events_by_keys(window_events, ['app']); RETURN = sort_by_duration(events_by_app);"]
    }
    \`\`\`
    
    ### Filter by App Name
    
    \`\`\`json
    {
      "timeperiods": ["2024-10-28/2024-10-29"],
      "query": ["window_events = query_bucket(find_bucket('aw-watcher-window_')); vscode_events = filter_keyvals(window_events, 'app', ['Code']); RETURN = vscode_events;"]
    }
    \`\`\`
    
    ## COMMON ERRORS
    
    ### ❌ INCORRECT: Splitting query into multiple array items
    
    \`\`\`json
    {
      "timeperiods": ["2024-10-28/2024-10-29"],
      "query": [
        "window_events = query_bucket(find_bucket('aw-watcher-window_'));",
        "RETURN = window_events;"
      ]
    }
    \`\`\`
    
    ### ❌ INCORRECT: Not wrapping query in an array
    
    \`\`\`json
    {
      "timeperiods": ["2024-10-28/2024-10-29"],
      "query": "window_events = query_bucket(find_bucket('aw-watcher-window_')); RETURN = window_events;"
    }
    \`\`\`
    
    ### ❌ INCORRECT: Double-wrapping query in nested arrays
    
    \`\`\`json
    {
      "timeperiods": ["2024-10-28/2024-10-29"],
      "query": [[
        "window_events = query_bucket(find_bucket('aw-watcher-window_')); RETURN = window_events;"
      ]]
    }
    \`\`\`
    
    ### ✅ CORRECT: Single string with all statements in an array
    
    \`\`\`json
    {
      "timeperiods": ["2024-10-28/2024-10-29"],
      "query": ["window_events = query_bucket(find_bucket('aw-watcher-window_')); RETURN = window_events;"]
    }
    \`\`\`
    
    ## NOTE FOR MCP CLIENT DEVELOPERS
    
    If you're developing an MCP client that interacts with this server, be aware that:
    
    1. The server expects \`query\` to be an array of strings
    2. The server then transforms this to an array of arrays for the ActivityWatch API
    3. Some MCP clients may inadvertently add extra array nesting
    4. The server tries to automatically detect and handle these cases
    
    Potential issues to watch for:
    - The server transforming already-nested arrays (e.g., turning \`[["query"]]\` into \`[[["query"]]]\`)
    - Error messages that don't match the actual issue
    
    ## INSTRUCTIONS FOR CLAUDE USERS
    
    When asking Claude to run a query using the 'activitywatch_run_query' tool in the ActivityWatch MCP server, use this format in your request:
    
    "Please run this query with the 'activitywatch_run_query' tool:
    - timeperiods: ['2024-10-28/2024-10-29']
    - query: ['all statements go here in one string separated by semicolons; RETURN = results;']"
    
    ⚠️ Important: Make sure you explicitly tell Claude to put ALL query statements in ONE string inside the array. Do not double-wrap the query in another array.
    
    ⚠️ If you consistently get errors about query format, try modifying your query to include explicit formatting instructions:
    
    "Please run this query with the 'activitywatch_run_query' tool using EXACTLY this format:
    {
      'timeperiods': ['2024-10-28/2024-10-29'],
      'query': ['all statements go here in one string separated by semicolons; RETURN = results;']
    }"
    `;
    
        return {
          content: [
            {
              type: "text",
              text: examples
            }
          ]
        };
      }
  • The input schema defining no required parameters for this tool.
    inputSchema: {
      type: "object",
      properties: {}
    },
  • src/index.ts:49-53 (registration)
    Registration of the tool in the MCP server's listTools handler, providing name, description, and schema.
    {
      name: activitywatch_query_examples_tool.name,
      description: activitywatch_query_examples_tool.description,
      inputSchema: activitywatch_query_examples_tool.inputSchema
    },
  • src/index.ts:84-85 (registration)
    Dispatch logic in the MCP server's callTool handler that invokes the tool's handler function when requested.
    } else if (request.params.name === activitywatch_query_examples_tool.name) {
      return makeSafeToolResponse(activitywatch_query_examples_tool.handler)();
  • src/index.ts:7-7 (registration)
    Import of the tool definition from its implementation file.
    import { activitywatch_query_examples_tool } from "./queryExamples.js";
Behavior2/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 of behavioral disclosure. It states the tool 'gets examples,' implying a read-only operation, but doesn't clarify if this requires authentication, has rate limits, returns structured data, or involves any side effects. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior and constraints.

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

Conciseness5/5

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

The description is a single, clear sentence: 'Get examples of properly formatted queries for the ActivityWatch MCP server.' It is front-loaded with the core action ('Get examples') and specifies the context ('for the ActivityWatch MCP server'), with zero wasted words. This makes it highly efficient and easy for an agent to parse.

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 the tool's simplicity (0 parameters, no output schema, no annotations), the description is adequate but has gaps. It explains what the tool does but lacks behavioral details (e.g., response format, authentication needs) and usage guidelines relative to siblings. Without an output schema, it doesn't describe return values, which could hinder an agent's understanding of how to use the examples provided.

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

Parameters4/5

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

The tool has 0 parameters, and the input schema has 100% description coverage (though empty). The description doesn't need to explain parameters, as there are none. It appropriately focuses on the tool's purpose without redundant parameter details, earning a high baseline score for parameter semantics in this context.

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: 'Get examples of properly formatted queries for the ActivityWatch MCP server.' It uses a specific verb ('Get') and identifies the resource ('examples of properly formatted queries'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'activitywatch_run_query' or 'activitywatch_get_events,' which prevents a perfect score.

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 doesn't mention prerequisites (e.g., needing to understand query syntax before using 'activitywatch_run_query'), exclusions, or contextual cues. Without such information, an agent might struggle to choose between this and sibling tools like 'activitywatch_run_query' or 'activitywatch_get_events.'

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/8bitgentleman/activitywatch-mcp-server'

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