Skip to main content
Glama

create_invoice

Generate a new invoice for a client with optional line items, custom payment terms, taxes, and discounts.

Instructions

Create a new invoice for a client with optional line items and billing details. Supports custom terms, taxes, and payment configurations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
client_idYesThe client ID to invoice (required)
subjectNoInvoice subject line
notesNoInvoice notes or description
currencyNo3-letter ISO currency code (e.g., USD, EUR)
issue_dateNoInvoice issue date (YYYY-MM-DD)
due_dateNoInvoice due date (YYYY-MM-DD)
payment_termNoPayment terms (e.g., "Net 30")
taxNoTax percentage (0-100)
tax2NoSecond tax percentage (0-100)
discountNoDiscount percentage (0-100)
purchase_orderNoClient purchase order number

Implementation Reference

  • The CreateInvoiceHandler class implementing ToolHandler. It validates args with CreateInvoiceSchema, calls harvestClient.createInvoice(), and returns the result as JSON text content.
    class CreateInvoiceHandler implements ToolHandler {
      constructor(private readonly config: BaseToolConfig) {}
    
      async execute(args: Record<string, any>): Promise<CallToolResult> {
        try {
          const validatedArgs = validateInput(CreateInvoiceSchema, args, 'create invoice');
          logger.info('Creating invoice via Harvest API');
          const invoice = await this.config.harvestClient.createInvoice(validatedArgs);
          
          return {
            content: [{ type: 'text', text: JSON.stringify(invoice, null, 2) }],
          };
        } catch (error) {
          return handleMCPToolError(error, 'create_invoice');
        }
      }
    }
  • Zod schema validating create_invoice input: client_id (required positive int), plus optional fields subject, notes, currency (default USD), issue_date/due_date (YYYY-MM-DD), payment_term, tax/tax2/discount (0-100), purchase_order.
    export const CreateInvoiceSchema = z.object({
      client_id: z.number().int().positive(),
      subject: z.string().optional(),
      notes: z.string().optional(),
      currency: z.string().length(3).optional().default('USD'),
      issue_date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, 'Date must be in YYYY-MM-DD format').optional(),
      due_date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, 'Date must be in YYYY-MM-DD format').optional(),
      payment_term: z.string().optional(),
      tax: z.number().min(0).max(100).optional(),
      tax2: z.number().min(0).max(100).optional(),
      discount: z.number().min(0).max(100).optional(),
      purchase_order: z.string().optional(),
    });
  • Registration of the create_invoice tool in registerInvoiceTools(), defining its name, description, input schema (JSON Schema format), and handler instance.
    {
      tool: {
        name: 'create_invoice',
        description: 'Create a new invoice for a client with optional line items and billing details. Supports custom terms, taxes, and payment configurations.',
        inputSchema: {
          type: 'object',
          properties: {
            client_id: { type: 'number', description: 'The client ID to invoice (required)' },
            subject: { type: 'string', description: 'Invoice subject line' },
            notes: { type: 'string', description: 'Invoice notes or description' },
            currency: { type: 'string', minLength: 3, maxLength: 3, description: '3-letter ISO currency code (e.g., USD, EUR)' },
            issue_date: { type: 'string', format: 'date', description: 'Invoice issue date (YYYY-MM-DD)' },
            due_date: { type: 'string', format: 'date', description: 'Invoice due date (YYYY-MM-DD)' },
            payment_term: { type: 'string', description: 'Payment terms (e.g., "Net 30")' },
            tax: { type: 'number', minimum: 0, maximum: 100, description: 'Tax percentage (0-100)' },
            tax2: { type: 'number', minimum: 0, maximum: 100, description: 'Second tax percentage (0-100)' },
            discount: { type: 'number', minimum: 0, maximum: 100, description: 'Discount percentage (0-100)' },
            purchase_order: { type: 'string', description: 'Client purchase order number' },
          },
          required: ['client_id'],
          additionalProperties: false,
        },
      },
      handler: new CreateInvoiceHandler(config),
    },
  • src/server.ts:138-138 (registration)
    The create_invoice tool name is listed under the 'invoices' category in the server's category-to-tool-name mappings.
    'invoices': ['list_invoices', 'get_invoice', 'create_invoice', 'update_invoice', 'delete_invoice'],
  • InvoicesClient.createInvoice() - the low-level HTTP client method that validates input using the Zod schema, then POSTs to /invoices endpoint. This is called by harvestClient.createInvoice().
    async createInvoice(input: CreateInvoiceInput): Promise<any> {
      try {
        const validatedInput = CreateInvoiceSchema.parse(input);
        
        this.logger.debug('Creating invoice', {
          clientId: validatedInput.client_id,
          subject: validatedInput.subject
        });
        
        const response: AxiosResponse = await this.client.post('/invoices', validatedInput);
        
        this.logger.info('Successfully created invoice', {
          invoiceId: response.data.id,
          invoiceNumber: response.data.number,
          amount: response.data.amount
        });
        
        return response.data;
      } catch (error) {
        if (error instanceof z.ZodError) {
          this.logger.error('Create invoice validation failed:', error.errors);
          throw new Error('Invalid invoice input data');
        }
        throw error;
      }
    }
Behavior2/5

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

With no annotations, the description fails to disclose behavioral traits such as what the tool returns, whether it is idempotent, or side effects. The claim 'optional line items' is unsupported by the schema, undermining transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise at two sentences, with the main action front-loaded. However, the inaccuracy regarding line items wastes space and could confuse, preventing a perfect score.

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 11 parameters and no output schema, the description should clarify return value and behavior. It omits key details like only client_id is required, and the mention of line items indicates missing schema coverage, making it incomplete.

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?

Schema coverage is 100%, so parameters are already well-documented. The description adds little new semantic value beyond repeating 'custom terms, taxes, and payment configurations' which are already in schema descriptions. The misleading 'line items' mention slightly detracts.

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 creates an invoice for a client, distinguishing it from update_invoice and other related tools. However, the mention of 'optional line items' is misleading as the schema does not include a line items parameter, which slightly reduces clarity.

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?

No guidance is provided on when to use this tool versus alternatives like create_estimate or update_invoice. The description lists features but does not explain context, 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