Skip to main content
Glama
adrian-dotco

Harvest Natural Language Time Entry MCP Server

by adrian-dotco

get_time_report

Generate time reports from Harvest using natural language queries like "Show time report for last month" or "Get time summary for Project X".

Instructions

Get time reports using natural language

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesNatural language query (e.g., "Show time report for last month", "Get time summary for Project X")

Implementation Reference

  • src/index.ts:319-332 (registration)
    Registration of the 'get_time_report' tool, including its name, description, and input schema.
    {
      name: 'get_time_report',
      description: 'Get time reports using natural language',
      inputSchema: {
        type: 'object',
        properties: {
          text: {
            type: 'string',
            description: 'Natural language query (e.g., "Show time report for last month", "Get time summary for Project X")',
          },
        },
        required: ['text'],
      },
    },
  • The main handler for the 'get_time_report' tool. Parses natural language text to extract date range, determines the appropriate Harvest API endpoint based on keywords (projects, clients, tasks, team), fetches the time report, and returns the JSON response.
    case 'get_time_report': {
      const { text } = request.params.arguments as { text: string };
      
      try {
        const { from, to } = this.parseDateRange(text);
        const lowercaseText = text.toLowerCase();
        
        let endpoint = '/reports/time/projects'; // default to project report
        
        if (lowercaseText.includes('by client') || lowercaseText.includes('for client')) {
          endpoint = '/reports/time/clients';
        } else if (lowercaseText.includes('by task') || lowercaseText.includes('tasks')) {
          endpoint = '/reports/time/tasks';
        } else if (lowercaseText.includes('by team') || lowercaseText.includes('by user')) {
          endpoint = '/reports/time/team';
        }
        
        const response = await this.axiosInstance.get<TimeReportResponse>(endpoint, {
          params: { from, to }
        });
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(response.data, null, 2),
            },
          ],
        };
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        if (axios.isAxiosError(error)) {
          throw new McpError(
            ErrorCode.InternalError,
            `Harvest API error: ${error.response?.data?.message ?? error.message}`
          );
        }
        throw error;
      }
    }
  • TypeScript interfaces defining the structure of TimeReportResult and TimeReportResponse used for typing the Harvest API response in the get_time_report handler.
    interface TimeReportResult {
      client_id?: number;
      client_name?: string;
      project_id?: number;
      project_name?: string;
      task_id?: number;
      task_name?: string;
      user_id?: number;
      user_name?: string;
      weekly_capacity?: number;
      avatar_url?: string;
      is_contractor?: boolean;
      total_hours: number;
      billable_hours: number;
      currency: string;
      billable_amount: number;
    }
    
    interface TimeReportResponse {
      results: TimeReportResult[];
      per_page: number;
      total_pages: number;
      total_entries: number;
      next_page: number | null;
      previous_page: number | null;
      page: number;
    }
  • Helper method to parse natural language date ranges (e.g., 'last month', 'this week') using chrono-node or predefined patterns, returning from/to dates in YYYY-MM-DD format. Used by the get_time_report handler.
    private parseDateRange(text: string): { from: string; to: string } {
      const lowercaseText = text.toLowerCase();
      const now = new Date(new Date().toLocaleString('en-US', { timeZone: TIMEZONE }));
      
      // Handle common time ranges
      if (lowercaseText.includes('last month')) {
        const from = new Date(now.getFullYear(), now.getMonth() - 1, 1);
        const to = new Date(now.getFullYear(), now.getMonth(), 0);
        return {
          from: from.toISOString().split('T')[0],
          to: to.toISOString().split('T')[0]
        };
      }
      
      if (lowercaseText.includes('this month')) {
        const from = new Date(now.getFullYear(), now.getMonth(), 1);
        const to = now;
        return {
          from: from.toISOString().split('T')[0],
          to: to.toISOString().split('T')[0]
        };
      }
      
      if (lowercaseText.includes('this week')) {
        const from = new Date(now);
        from.setDate(now.getDate() - now.getDay());
        return {
          from: from.toISOString().split('T')[0],
          to: now.toISOString().split('T')[0]
        };
      }
    
      if (lowercaseText.includes('last week')) {
        const from = new Date(now);
        from.setDate(now.getDate() - now.getDay() - 7);
        const to = new Date(from);
        to.setDate(from.getDate() + 6);
        return {
          from: from.toISOString().split('T')[0],
          to: to.toISOString().split('T')[0]
        };
      }
    
      // Default to parsing with chrono
      const dates = chrono.parse(text);
      if (dates.length === 0) {
        throw new McpError(ErrorCode.InvalidParams, 'Could not parse date range from input');
      }
    
      return {
        from: dates[0].start.date().toISOString().split('T')[0],
        to: (dates[0].end?.date() || dates[0].start.date()).toISOString().split('T')[0]
      };
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool uses natural language but doesn't explain how it processes queries (e.g., parsing accuracy, supported formats), what the output looks like (e.g., report format, data included), or any limitations (e.g., query complexity, error handling). This leaves significant gaps in understanding the tool's behavior, scoring a 2 for inadequate transparency.

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 extremely concise and front-loaded with a single sentence: 'Get time reports using natural language.' It efficiently conveys the core purpose without unnecessary details, earning a 5 for zero waste and appropriate sizing given the tool's simplicity.

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

Completeness2/5

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

Given the tool's complexity (natural language processing for reports) and lack of annotations or output schema, the description is incomplete. It doesn't address how reports are generated, what data they include, or any behavioral traits like error handling. For a tool that likely involves nuanced processing, this minimal description fails to provide sufficient context, scoring a 2.

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?

The input schema has 100% description coverage, with the 'text' parameter well-documented as a natural language query including examples. The description adds minimal value beyond the schema, only reiterating the natural language aspect without providing additional syntax or format details. This meets the baseline of 3 for high schema coverage, but doesn't enhance parameter understanding further.

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 time reports using natural language.' It specifies the verb ('Get') and resource ('time reports'), and distinguishes it from siblings like 'list_entries' or 'log_time' by focusing on report generation rather than listing or logging. However, it doesn't explicitly differentiate from all siblings (e.g., 'list_projects' might also involve time-related data), keeping it at a 4 rather than a 5.

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 scenarios where natural language queries are preferred over structured queries (e.g., from siblings like 'list_entries'), nor does it specify prerequisites or exclusions. This lack of usage context leaves the agent with minimal direction, scoring a 2 for no guidance.

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/adrian-dotco/harvest-mcp-server'

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