next-finance-mcp 0.9.2 → 0.9.3

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.
package/dist/client.js CHANGED
@@ -826,13 +826,18 @@ export async function buscarLancamentos(opts) {
826
826
  if (opts.nomeConta?.trim()) {
827
827
  const { contas } = await fetchContas();
828
828
  const termo = opts.nomeConta.trim().toLowerCase();
829
- const encontrada = contas
830
- .map(c => c)
831
- .filter(c => c["Ativo"] !== false) // apenas contas ativas
832
- .find(c => String(c["Nome"] ?? c["NomeConta"] ?? "").toLowerCase().includes(termo));
833
- if (!encontrada)
834
- throw new Error(`Conta "${opts.nomeConta}" não encontrada entre as contas ativas. Use listar_contas para ver as contas disponíveis.`);
835
- // Tenta todos os nomes possíveis de campo ID na resposta da API
829
+ const ativas = contas.map(c => c).filter(c => c["Ativo"] !== false);
830
+ const matches = ativas.filter(c => String(c["Nome"] ?? c["NomeConta"] ?? "").toLowerCase().includes(termo));
831
+ if (matches.length === 0) {
832
+ throw new Error(`Conta "${opts.nomeConta}" não encontrada. Use listar_contas para ver as contas disponíveis.`);
833
+ }
834
+ // Preferir match exato; se ainda ambíguo, listar as opções
835
+ const exata = matches.find(c => String(c["Nome"] ?? c["NomeConta"] ?? "").toLowerCase() === termo);
836
+ const encontrada = exata ?? (matches.length === 1 ? matches[0] : null);
837
+ if (!encontrada) {
838
+ const nomes = matches.map(c => String(c["Nome"] ?? c["NomeConta"] ?? "")).join(", ");
839
+ throw new Error(`"${opts.nomeConta}" corresponde a ${matches.length} contas: ${nomes}. Informe um nome mais específico.`);
840
+ }
836
841
  idContaResolvido = String(encontrada["Id"] ?? encontrada["IdConta"] ?? encontrada["id"] ?? encontrada["idConta"] ?? "");
837
842
  }
838
843
  let lancamentos;
@@ -863,8 +868,6 @@ export async function buscarLancamentos(opts) {
863
868
  if (r.status !== 200)
864
869
  throw new Error(`Erro ${r.status} ao buscar lançamentos (endpoint legado).`);
865
870
  const raw = JSON.parse(r.text);
866
- // O endpoint legado retorna { Lancamentos: [...], SaldosPorMes: [...], ... }
867
- // Extraímos explicitamente o campo Lancamentos para não confundir com SaldosPorMes
868
871
  if (Array.isArray(raw)) {
869
872
  lancamentos = raw;
870
873
  }
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
8
8
  import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
9
9
  import * as client from "./client.js";
10
10
  import { openLoginUI } from "./login-server.js";
11
- const server = new Server({ name: "next-finance-mcp", version: "0.9.2" }, { capabilities: { tools: {} } });
11
+ const server = new Server({ name: "next-finance-mcp", version: "0.9.3" }, { capabilities: { tools: {} } });
12
12
  // ── Ferramentas ─────────────────────────────────────────────────────────────
13
13
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
14
14
  tools: [
@@ -361,6 +361,6 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
361
361
  async function main() {
362
362
  const transport = new StdioServerTransport();
363
363
  await server.connect(transport);
364
- console.error("NEXT Finance MCP server v0.9.0 iniciado.");
364
+ console.error("NEXT Finance MCP server v0.9.3 iniciado.");
365
365
  }
366
366
  main().catch((err) => { console.error("Erro fatal:", err); process.exit(1); });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-finance-mcp",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "mcpName": "io.github.paivapiovesan/next-finance",
5
5
  "description": "MCP Server para o NEXT Finance (finance.net.br) — login via browser, listagem de carteiras, contas e lançamentos",
6
6
  "type": "module",