create_client
Add a new client for project management and billing. Provide client name and optionally set active status, address, and currency.
Instructions
Create a new client for project management and billing. Requires client name and supports address and currency configuration.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Client name (required) | |
| is_active | No | Whether the client is active | |
| address | No | Client address | |
| currency | No | 3-letter ISO currency code (e.g., USD, EUR) |
Implementation Reference
- src/tools/clients.ts:58-74 (handler)The CreateClientHandler class is the MCP tool handler that executes the 'create_client' tool logic. It validates arguments using CreateClientSchema, calls harvestClient.createClient(), and returns the result.
class CreateClientHandler implements ToolHandler { constructor(private readonly config: BaseToolConfig) {} async execute(args: Record<string, any>): Promise<CallToolResult> { try { const validatedArgs = validateInput(CreateClientSchema, args, 'create client'); logger.info('Creating client via Harvest API'); const client = await this.config.harvestClient.createClient(validatedArgs); return { content: [{ type: 'text', text: JSON.stringify(client, null, 2) }], }; } catch (error) { return handleMCPToolError(error, 'create_client'); } } } - src/schemas/client.ts:38-43 (schema)The CreateClientSchema defines the input validation schema for creating a client, with fields: name (required), is_active (optional, default true), address (optional), and currency (optional, default 'USD').
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'), }); - src/tools/clients.ts:148-165 (registration)The tool registration entry for 'create_client' in the registerClientTools function. It defines the tool name, description, inputSchema (name required, optional is_active, address, currency), and associates the CreateClientHandler.
{ tool: { name: 'create_client', description: 'Create a new client for project management and billing. Requires client name and supports address and currency configuration.', inputSchema: { type: 'object', properties: { name: { type: 'string', minLength: 1, description: 'Client name (required)' }, is_active: { type: 'boolean', description: 'Whether the client is active' }, address: { type: 'string', description: 'Client address' }, currency: { type: 'string', minLength: 3, maxLength: 3, description: '3-letter ISO currency code (e.g., USD, EUR)' }, }, required: ['name'], additionalProperties: false, }, }, handler: new CreateClientHandler(config), }, - src/client/clients-client.ts:60-80 (helper)The ClientsClient.createClient() method is the low-level API helper that performs the actual HTTP POST request to Harvest API /clients endpoint, with Zod validation and error handling.
async createClient(input: CreateClientInput): Promise<any> { try { const validatedInput = CreateClientSchema.parse(input); this.logger.debug('Creating client', { name: validatedInput.name }); const response: AxiosResponse = await this.client.post('/clients', validatedInput); this.logger.info('Successfully created client', { clientId: response.data.id, clientName: response.data.name }); return response.data; } catch (error) { if (error instanceof z.ZodError) { this.logger.error('Create client validation failed:', error.errors); throw new Error('Invalid client input data'); } throw error; } } - src/server.ts:136-136 (registration)The server category mapping includes 'create_client' in the 'clients' tool category.
'clients': ['list_clients', 'get_client', 'create_client', 'update_client', 'delete_client'],