siigo_create_purchase
Create a new purchase record in Siigo accounting software to track business expenses and maintain accurate financial records.
Instructions
Create a new purchase
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| purchase | Yes | Purchase data |
Implementation Reference
- src/index.ts:1016-1019 (handler)MCP server handler method that extracts args.purchase and delegates to SiigoClient.createPurchase, then formats response as MCP content.private async handleCreatePurchase(args: any) { const result = await this.siigoClient.createPurchase(args.purchase); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
- src/siigo-client.ts:162-164 (handler)Core implementation of purchase creation: authenticates, makes POST request to Siigo API /v1/purchases endpoint with purchase data.async createPurchase(purchase: any): Promise<SiigoApiResponse<any>> { return this.makeRequest<any>('POST', '/v1/purchases', purchase);
- src/index.ts:538-548 (schema)Input schema defining the expected structure for tool arguments: an object containing 'purchase' data.{ name: 'siigo_create_purchase', description: 'Create a new purchase', inputSchema: { type: 'object', properties: { purchase: { type: 'object', description: 'Purchase data' }, }, required: ['purchase'], }, },
- src/index.ts:119-120 (registration)Switch case in CallToolRequestSchema handler that routes 'siigo_create_purchase' calls to the specific handler method.case 'siigo_create_purchase': return await this.handleCreatePurchase(args);
- src/siigo-client.ts:41-59 (helper)Generic helper method used by all API calls: handles authentication, makes Axios request, processes response or error.private async makeRequest<T>(method: string, endpoint: string, data?: any, params?: any): Promise<SiigoApiResponse<T>> { await this.authenticate(); try { const response: AxiosResponse<SiigoApiResponse<T>> = await this.httpClient.request({ method, url: endpoint, data, params, }); return response.data; } catch (error: any) { if (error.response?.data) { return error.response.data; } throw new Error(`API request failed: ${error.message}`); } }