Skip to main content
Glama
8bitgentleman

ActivityWatch MCP Server

activitywatch_list_buckets

Retrieve time tracking buckets from ActivityWatch to analyze application usage and productivity patterns, with options to filter by type or include detailed data.

Instructions

List all ActivityWatch buckets with optional type filtering

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeNoFilter buckets by type
includeDataNoInclude bucket data in response

Implementation Reference

  • The core handler function that implements the tool logic: fetches all buckets from the ActivityWatch API endpoint `${AW_API_BASE}/buckets`, converts to array with IDs, applies optional type filter, formats output as JSON with helpful guidance and examples for next steps, handles all errors with specific messages for API, network, and other issues.
      handler: async (args: { type?: string; includeData?: boolean }) => {
        try {
          const response = await axios.get(`${AW_API_BASE}/buckets`);
          const buckets: Record<string, Bucket> = response.data;
    
          // Convert bucket record to array with guaranteed IDs
          let bucketList: BucketWithId[] = Object.entries(buckets).map(([bucketId, bucket]) => ({
            ...bucket,
            id: bucketId
          }));
    
          // Apply type filter if specified
          if (args.type && typeof args.type === 'string') {
            bucketList = bucketList.filter(bucket => 
              bucket.type.toLowerCase().includes(args.type!.toLowerCase())
            );
          }
    
          // Format output with consistent structure
          const formattedBuckets = bucketList.map(bucket => {
            const result: BucketWithId = {
              id: bucket.id,
              type: bucket.type,
              client: bucket.client,
              hostname: bucket.hostname,
              created: bucket.created,
              name: bucket.name,
              ...(args.includeData && bucket.data ? { data: bucket.data } : {})
            };
            
            return result;
          });
    
                // Begin with the formatted buckets as JSON
          let resultText = JSON.stringify(formattedBuckets, null, 2);
          
          // Only add helpful guidance in production mode, not test mode
          if (process.env.NODE_ENV !== 'test' && bucketList.length > 0) {
            resultText += "\n\n";
            resultText += "You can access the events in these buckets using the activitywatch_get_events tool, for example:\n";
            resultText += `activitywatch_get_events with bucketId = "${bucketList[0].id}"`;
            
            if (bucketList.length > 1) {
              resultText += "\n\nOr try a different bucket:\n";
              resultText += `activitywatch_get_events with bucketId = "${bucketList[1].id}"`;
            }
          } else if (process.env.NODE_ENV !== 'test' && bucketList.length === 0) {
            resultText += "\n\nNo buckets found. Please check that ActivityWatch is running and collecting data.";
          }
    
          return {
            content: [
              {
                type: "text",
                text: resultText
              }
            ]
          };
        } catch (error) {
          console.error("Error in bucket list tool:", error);
          
          // Check if the error is an Axios error with a response property
          if (axios.isAxiosError(error) && error.response) {
            const statusCode = error.response.status;
            let errorMessage = `Failed to fetch buckets: ${error.message} (Status code: ${statusCode})`;
            
            // Include response data if available
            if (error.response.data) {
              const errorDetails = typeof error.response.data === 'object'
                ? JSON.stringify(error.response.data)
                : String(error.response.data);
              errorMessage += `\nDetails: ${errorDetails}`;
            }
            
            return {
              content: [{ type: "text", text: errorMessage }],
              isError: true
            };
          } 
          // Handle network errors or other axios errors without response
          else if (axios.isAxiosError(error)) {
            const errorMessage = `Failed to fetch buckets: ${error.message}
    
    This appears to be a network or connection error. Please check:
    - The ActivityWatch server is running (http://localhost:5600)
    - The API base URL is correct (currently: ${AW_API_BASE})
    - No firewall or network issues are blocking the connection
    `;
            return {
              content: [{ type: "text", text: errorMessage }],
              isError: true
            };
          } 
          // Handle non-axios errors
          else if (error instanceof Error) {
            return {
              content: [{ type: "text", text: `Failed to fetch buckets: ${error.message}` }],
              isError: true
            };
          } 
          // Fallback for unknown errors
          else {
            return {
              content: [{ type: "text", text: "Failed to fetch buckets: Unknown error" }],
              isError: true
            };
          }
        }
      }
  • Input schema definition for the tool parameters: optional 'type' string for filtering buckets by type, and optional 'includeData' boolean to include bucket data in the response.
    const inputSchema = {
      type: "object",
      properties: {
        type: {
          type: "string",
          description: "Filter buckets by type"
        },
        includeData: {
          type: "boolean",
          description: "Include bucket data in response"
        }
      }
    };
  • src/index.ts:45-47 (registration)
    Registration of the tool's metadata (name, description, inputSchema) in the MCP server's ListToolsRequest handler.
    name: activitywatch_list_buckets_tool.name,
    description: activitywatch_list_buckets_tool.description,
    inputSchema: activitywatch_list_buckets_tool.inputSchema
  • src/index.ts:78-83 (registration)
    Dispatch/execution registration in the MCP server's CallToolRequest handler: matches tool name and invokes the handler with properly typed arguments.
    if (request.params.name === activitywatch_list_buckets_tool.name) {
      // Cast to the expected type for the bucket list tool
      return makeSafeToolResponse(activitywatch_list_buckets_tool.handler)({
        type: typeof args.type === 'string' ? args.type : undefined,
        includeData: Boolean(args.includeData)
      });
  • TypeScript interfaces defining Bucket structure from ActivityWatch API and extended BucketWithId used in the handler.
    interface Bucket {
      id?: string;
      name?: string;
      type: string;
      client: string;
      hostname: string;
      created: string;
      data?: Record<string, any>;
    }
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 it's a list operation with optional filtering, implying it's likely read-only and non-destructive, but doesn't confirm this or address other behavioral aspects like permissions needed, rate limits, pagination, error handling, or what 'includeData' entails. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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, efficient sentence that front-loads the core purpose ('List all ActivityWatch buckets') and adds a concise modifier ('with optional type filtering'). There is no wasted verbiage, repetition, or unnecessary elaboration, making it easy to parse and understand quickly.

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 moderate complexity (2 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers the basic action and hints at filtering, but lacks details on behavioral traits, usage context, or output expectations. Without annotations or output schema, the agent must infer behavior from the description alone, which is insufficient for confident tool selection in varied scenarios.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents both parameters ('type' for filtering and 'includeData' for including bucket data). The description adds minimal value by mentioning 'optional type filtering,' which aligns with the schema but doesn't provide additional context like example types or implications of including data. With high schema coverage, the baseline is 3, and the description doesn't significantly enhance parameter understanding beyond what's structured.

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 action ('List all ActivityWatch buckets') and resource ('ActivityWatch buckets'), making the purpose immediately understandable. It distinguishes itself from siblings like 'activitywatch_get_events' by focusing on buckets rather than events, though it doesn't explicitly contrast with other bucket-related tools (none exist in the sibling list). The optional filtering aspect adds specificity beyond a basic list operation.

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 optional type filtering but doesn't explain scenarios where filtering is beneficial or when to choose this over other tools like 'activitywatch_query_examples' or 'activitywatch_run_query' for bucket-related tasks. There are no prerequisites, exclusions, or contextual recommendations provided.

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