list_users
Retrieve and manage user data in Harvest accounts, filtering by active status and pagination. Simplify user oversight with precise query parameters for efficient account administration.
Instructions
List all users in your Harvest account.
Args:
is_active: Pass true to only return active users and false to return inactive users
page: The page number for pagination
per_page: The number of records to return per page (1-2000)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| is_active | No | ||
| page | No | ||
| per_page | No |
Implementation Reference
- harvest-mcp-server.py:45-67 (handler)The handler function for the 'list_users' tool, decorated with @mcp.tool() for registration. It constructs parameters based on inputs and calls the Harvest API via harvest_request to list users, returning JSON.@mcp.tool() async def list_users(is_active: bool = None, page: int = None, per_page: int = None): """List all users in your Harvest account. Args: is_active: Pass true to only return active users and false to return inactive users page: The page number for pagination per_page: The number of records to return per page (1-2000) """ params = {} if is_active is not None: params["is_active"] = "true" if is_active else "false" else: params["is_active"] = "true" if page is not None: params["page"] = str(page) if per_page is not None: params["per_page"] = str(per_page) else: params["per_page"] = 200 response = await harvest_request("users", params) return json.dumps(response, indent=2)
- harvest-mcp-server.py:21-42 (helper)Helper function used by list_users to make authenticated 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()