list_time_entries
Retrieve filtered time entries by user ID, date range, or running status using the Harvest MCP Server. Streamline time tracking data management.
Instructions
List time entries with optional filtering.
Args:
user_id: Filter by user ID
from_date: Only return time entries with a spent_date on or after the given date (YYYY-MM-DD)
to_date: Only return time entries with a spent_date on or before the given date (YYYY-MM-DD)
is_running: Pass true to only return running time entries and false to return non-running time entries
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from_date | No | ||
| is_running | No | ||
| to_date | No | ||
| user_id | No |
Implementation Reference
- harvest-mcp-server.py:81-111 (handler)The handler function for the 'list_time_entries' tool, decorated with @mcp.tool() for registration. It constructs query parameters based on input arguments and calls the Harvest API via the helper function to fetch time entries, returning the JSON response.@mcp.tool() async def list_time_entries( user_id: int = None, from_date: str = None, to_date: str = None, is_running: bool = None, is_billable: bool = None, ): """List time entries with optional filtering. Args: user_id: Filter by user ID from_date: Only return time entries with a spent_date on or after the given date (YYYY-MM-DD) to_date: Only return time entries with a spent_date on or before the given date (YYYY-MM-DD) is_running: Pass true to only return running time entries and false to return non-running time entries is_billable: Pass true to only return billable time entries and false to return non-billable time entries """ params = {} if user_id is not None: params["user_id"] = str(user_id) if from_date is not None: params["from"] = from_date if to_date is not None: params["to"] = to_date if is_running is not None: params["is_running"] = "true" if is_running else "false" if is_billable is not None: params["is_billable"] = "true" if is_billable else "false" response = await harvest_request("time_entries", params) return json.dumps(response, indent=2)
- harvest-mcp-server.py:21-43 (helper)Helper function used by list_time_entries (and other tools) to make authenticated HTTP requests to the Harvest API.async def harvest_request(path, params=None, method="GET"): headers = { "Harvest-Account-Id": HARVEST_ACCOUNT_ID, "Authorization": f"Bearer {HARVEST_API_KEY}", "User-Agent": "Harvest MCP Server", "Content-Type": "application/json", } url = f"https://api.harvestapp.com/v2/{path}" async with httpx.AsyncClient() as client: if method == "GET": response = await client.get(url, headers=headers, params=params) else: response = await client.request(method, url, headers=headers, json=params) if response.status_code != 200: raise Exception( f"Harvest API Error: {response.status_code} {response.text}" ) return response.json()