@quantyapp/quanty-mcp-server 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -81,4 +81,8 @@ export declare function prepareDeleteItem(budgetId: string, itemId: string, item
81
81
  * Executes item deletion
82
82
  */
83
83
  export declare function executeDeleteItem(auth: AuthContext, data: any): Promise<void>;
84
+ /**
85
+ * Gets composition details (inputs/children) for a specific item in a budget
86
+ */
87
+ export declare function getCompositionDetails(auth: AuthContext, budgetId: string, itemId: string): Promise<any[]>;
84
88
  //# sourceMappingURL=budgetService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"budgetService.d.ts","sourceRoot":"","sources":["../../src/core/budgetService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,WAAW,SAAS;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,WAAW,GAAG,cAAc,CAAC;CAC1C;AAED,MAAM,WAAW,MAAM;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,SAAS,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC1B,EAAE,EAAE,M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,EAAE,eAAe,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,CAM3I;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAenF;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAmC/G"}
@@ -168,3 +168,38 @@ export async function executeDeleteItem(auth, data) {
168
168
  if (error)
169
169
  throw new Error(`Failed to delete item: ${error.message}`);
170
170
  }
171
+ /**
172
+ * Gets composition details (inputs/children) for a specific item in a budget
173
+ */
174
+ export async function getCompositionDetails(auth, budgetId, itemId) {
175
+ const budget = await getBudget(auth, budgetId);
176
+ if (!budget)
177
+ throw new Error('Budget not found');
178
+ // Find the item in the rows
179
+ // Note: getBudget returns a simplified BudgetRow structure.
180
+ // We need to access the raw data structure which might contain 'children' for compositions
181
+ const { data, error } = await supabase
182
+ .from('budgets')
183
+ .select('data')
184
+ .eq('id', budgetId)
185
+ .single();
186
+ if (error || !data)
187
+ throw new Error('Failed to fetch budget data');
188
+ const rows = data.data?.rows || [];
189
+ const item = rows.find((r) => r.id === itemId);
190
+ if (!item)
191
+ throw new Error('Item not found in budget');
192
+ if (!item.children || item.children.length === 0) {
193
+ return [];
194
+ }
195
+ return item.children.map((child) => ({
196
+ id: child.id,
197
+ code: child.code,
198
+ description: child.description,
199
+ unit: child.unit,
200
+ quantity: child.quantity,
201
+ unitCost: child.unitCost, // Custo unitário do insumo
202
+ total: (child.quantity || 0) * (child.unitCost || 0),
203
+ type: child.itemType || 'INSUMO'
204
+ }));
205
+ }
package/dist/mcp/index.js CHANGED
@@ -121,6 +121,19 @@ Use quanty_ver_composicao para ver os insumos de uma composição específica.`,
121
121
  required: ['id']
122
122
  }
123
123
  },
124
+ {
125
+ name: 'quanty_ver_composicao',
126
+ description: `Mostra os INSUMOS que compõem um item do tipo COMPOSIÇÃO.
127
+ Uso obrigatório quando um item tiver 'is_composicao: true' para entender seus custos internos.`,
128
+ inputSchema: {
129
+ type: 'object',
130
+ properties: {
131
+ orcamento_id: { type: 'string', description: 'ID do orçamento onde está o item' },
132
+ item_id: { type: 'string', description: 'ID do item (composição) a ser detalhado' }
133
+ },
134
+ required: ['orcamento_id', 'item_id']
135
+ }
136
+ },
124
137
  {
125
138
  name: 'quanty_listar_bancos',
126
139
  description: `Lista os bancos de composição disponíveis para buscar preços de referência.
@@ -282,6 +295,27 @@ async function handleToolCall(auth, name, args) {
282
295
  }))
283
296
  };
284
297
  }
298
+ case 'quanty_ver_composicao': {
299
+ const insumos = await budgetService.getCompositionDetails(auth, args.orcamento_id, args.item_id);
300
+ if (!insumos || insumos.length === 0) {
301
+ return {
302
+ mensagem: 'Esta composição não possui insumos listados ou não é uma composição válida.'
303
+ };
304
+ }
305
+ const totalComposicao = insumos.reduce((sum, i) => sum + i.total, 0);
306
+ return {
307
+ _info: 'Lista de insumos/filhos desta composição',
308
+ qtd_insumos: insumos.length,
309
+ custo_total_calculado: `R$ ${totalComposicao.toFixed(2)}`,
310
+ insumos: insumos.map(i => ({
311
+ descricao: i.description,
312
+ unidade: i.unit,
313
+ coeficiente: i.quantity, // Na composição, quantidade é o coeficiente
314
+ custo_unitario_insumo: i.unitCost,
315
+ custo_total_insumo: i.total
316
+ }))
317
+ };
318
+ }
285
319
  case 'quanty_listar_bancos': {
286
320
  const banks = await bankService.listBanks(auth);
287
321
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantyapp/quanty-mcp-server",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "MCP Server para conectar Claude Desktop ao Quanty - Sistema de Orçamentos de Engenharia",
5
5
  "type": "module",
6
6
  "main": "dist/mcp/index.js",