Skip to main content
Glama

list_clients

Retrieve clients filtered by active status and updated date, with paginated results that include billing details.

Instructions

Retrieve a list of clients with optional filtering by active status and updated date. Returns paginated results with client details including billing information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
is_activeNoFilter by active status
updated_sinceNoFilter by clients updated since this timestamp
pageNoPage number for pagination
per_pageNoNumber of clients per page (max 2000)

Implementation Reference

  • ListClientsHandler class that executes the list_clients tool logic. Validates arguments via ClientQuerySchema, calls harvestClient.getClients(), and returns paginated client results as JSON.
    class ListClientsHandler implements ToolHandler {
      constructor(private readonly config: BaseToolConfig) {}
    
      async execute(args: Record<string, any>): Promise<CallToolResult> {
        try {
          const validatedArgs = validateInput(ClientQuerySchema, args, 'client query');
          logger.info('Listing clients from Harvest API');
          const clients = await this.config.harvestClient.getClients(validatedArgs);
          
          return {
            content: [{ type: 'text', text: JSON.stringify(clients, null, 2) }],
          };
        } catch (error) {
          return handleMCPToolError(error, 'list_clients');
        }
      }
    }
  • ClientQuerySchema - Zod schema that validates input for list_clients tool: optional is_active, updated_since, page, per_page (max 2000).
    // Query parameters for listing clients
    export const ClientQuerySchema = z.object({
      is_active: z.boolean().optional(),
      updated_since: z.string().datetime({ offset: true }).optional(),
      page: z.number().int().positive().optional(),
      per_page: z.number().int().min(1).max(2000).optional().default(2000),
    });
  • registerClientTools function that registers list_clients tool with name, description, inputSchema (object with is_active, updated_since, page, per_page), and pairs it with ListClientsHandler.
    export function registerClientTools(config: BaseToolConfig): ToolRegistration[] {
      return [
        {
          tool: {
            name: 'list_clients',
            description: 'Retrieve a list of clients with optional filtering by active status and updated date. Returns paginated results with client details including billing information.',
            inputSchema: {
              type: 'object',
              properties: {
                is_active: { type: 'boolean', description: 'Filter by active status' },
                updated_since: { type: 'string', format: 'date-time', description: 'Filter by clients updated since this timestamp' },
                page: { type: 'number', minimum: 1, description: 'Page number for pagination' },
                per_page: { type: 'number', minimum: 1, maximum: 2000, description: 'Number of clients per page (max 2000)' },
              },
              additionalProperties: false,
            },
          },
          handler: new ListClientsHandler(config),
        },
  • src/server.ts:75-94 (registration)
    Tool registration wiring in HarvestMCPServer - registerClientTools is called alongside other tool modules, iterating registrations and storing them in this.tools and this.toolHandlers Maps.
    const toolModules = [
      registerCompanyTools(config),
      registerTimeEntryTools(config),
      registerProjectTools(config),
      registerTaskTools(config),
      registerClientTools(config),
      registerUserTools(config),
      registerInvoiceTools(config),
      registerExpenseTools(config),
      registerEstimateTools(config),
      registerReportTools(config),
    ];
    
    // Flatten and register all tools
    toolModules.forEach(toolRegistrations => {
      toolRegistrations.forEach(({ tool, handler }) => {
        this.tools.set(tool.name, tool);
        this.toolHandlers.set(tool.name, handler);
      });
    });
  • ClientSchema and ClientsListSchema - type definitions for the client response data structure including pagination fields.
    export const ClientSchema = z.object({
      id: z.number().int().positive(),
      name: z.string().min(1),
      is_active: z.boolean(),
      address: z.string().nullable(),
      statement_key: z.string().nullable(),
      currency: z.string().length(3).optional(), // ISO currency code
      created_at: z.string().datetime({ offset: true }),
      updated_at: z.string().datetime({ offset: true }),
    });
    
    // Clients list response (paginated)
    export const ClientsListSchema = z.object({
      clients: z.array(ClientSchema),
      per_page: z.number().int().positive(),
      total_pages: z.number().int().min(0),
      total_entries: z.number().int().min(0),
      next_page: z.number().int().positive().nullable(),
      previous_page: z.number().int().positive().nullable(),
      page: z.number().int().positive(),
      links: z.object({
        first: z.string().url(),
        next: z.string().url().nullable(),
        previous: z.string().url().nullable(),
        last: z.string().url(),
      }),
    });
    
    // Input schemas for creating/updating clients
    export const CreateClientSchema = z.object({
      name: z.string().min(1, 'Client name is required'),
      is_active: z.boolean().optional().default(true),
      address: z.string().optional(),
      currency: z.string().length(3, 'Currency must be a 3-letter ISO code').optional().default('USD'),
    });
    
    export const UpdateClientSchema = CreateClientSchema.partial().extend({
      id: z.number().int().positive(),
    });
    
    // Query parameters for listing clients
    export const ClientQuerySchema = z.object({
      is_active: z.boolean().optional(),
      updated_since: z.string().datetime({ offset: true }).optional(),
      page: z.number().int().positive().optional(),
      per_page: z.number().int().min(1).max(2000).optional().default(2000),
    });
Behavior3/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. It mentions 'retrieve' implying read-only but does not explicitly state it is non-destructive or discuss side effects, auth requirements, or rate limits. The mention of pagination is helpful.

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, well-structured sentence that efficiently communicates purpose, filtering, pagination, and return content without extraneous words.

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

Completeness4/5

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

For a 4-parameter list tool with no output schema, the description adequately covers filtering criteria, pagination, and return contents (including billing info). It could mention default pagination or ordering, but is reasonably complete for the tool's simplicity.

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?

Input schema has 100% description coverage for all 4 parameters. The description adds context that filtering is optional and results are paginated, but does not provide significant new meaning beyond what the schema already specifies. Baseline of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool retrieves a list of clients with optional filtering and returns paginated results with client details and billing information. It distinguishes from sibling tools like get_client (single) and create_client (create).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for listing clients with filtering and pagination, but does not provide explicit guidance on when to use this tool versus other list tools (e.g., list_estimates) or mention any exclusions or prerequisites.

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

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