@quantyapp/quanty-mcp-server 1.0.0 → 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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;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,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
|
@@ -86,6 +86,12 @@ Itens podem ser organizados em níveis hierárquicos:
|
|
|
86
86
|
`;
|
|
87
87
|
// Tool definitions with detailed descriptions
|
|
88
88
|
const TOOLS = [
|
|
89
|
+
// === DOCUMENTATION TOOLS ===
|
|
90
|
+
{
|
|
91
|
+
name: 'quanty_ler_manual',
|
|
92
|
+
description: 'Lê o manual completo do Quanty com conceitos de engenharia e instruções de uso.',
|
|
93
|
+
inputSchema: { type: 'object', properties: {} }
|
|
94
|
+
},
|
|
89
95
|
// === READ TOOLS ===
|
|
90
96
|
{
|
|
91
97
|
name: 'quanty_listar_orcamentos',
|
|
@@ -115,6 +121,19 @@ Use quanty_ver_composicao para ver os insumos de uma composição específica.`,
|
|
|
115
121
|
required: ['id']
|
|
116
122
|
}
|
|
117
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
|
+
},
|
|
118
137
|
{
|
|
119
138
|
name: 'quanty_listar_bancos',
|
|
120
139
|
description: `Lista os bancos de composição disponíveis para buscar preços de referência.
|
|
@@ -225,6 +244,13 @@ Retorna média, mínimo, máximo e percentil 90 (para detecção de outliers).`,
|
|
|
225
244
|
];
|
|
226
245
|
async function handleToolCall(auth, name, args) {
|
|
227
246
|
switch (name) {
|
|
247
|
+
// === DOCUMENTATION ===
|
|
248
|
+
case 'quanty_ler_manual': {
|
|
249
|
+
return {
|
|
250
|
+
conteudo: QUANTY_MANUAL,
|
|
251
|
+
_info: 'Este manual contém tudo sobre BDI, Composições e estrutura do Quanty.'
|
|
252
|
+
};
|
|
253
|
+
}
|
|
228
254
|
// === READ ===
|
|
229
255
|
case 'quanty_listar_orcamentos': {
|
|
230
256
|
const budgets = await budgetService.listBudgets(auth, args.limite || 10);
|
|
@@ -269,6 +295,27 @@ async function handleToolCall(auth, name, args) {
|
|
|
269
295
|
}))
|
|
270
296
|
};
|
|
271
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
|
+
}
|
|
272
319
|
case 'quanty_listar_bancos': {
|
|
273
320
|
const banks = await bankService.listBanks(auth);
|
|
274
321
|
return {
|
package/package.json
CHANGED