gft-pharos-mcp 0.1.0 → 0.1.1
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/index.js +167 -53
- package/package.json +4 -1
- package/test/index.test.js +129 -0
package/index.js
CHANGED
|
@@ -12,11 +12,74 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
12
12
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
13
13
|
import { z } from "zod";
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
15
|
+
export function parseApiUrl(raw) {
|
|
16
|
+
const value = raw === undefined || raw === null || raw.trim() === "" ? "http://localhost:8080" : raw.trim();
|
|
17
|
+
if (/\$\{.+\}/.test(value)) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
`PHAROS_API_URL veio como "${value}" — placeholder não expandido. ` +
|
|
20
|
+
`Claude Code não expande \${VAR} dentro de "env" no .mcp.json: ` +
|
|
21
|
+
`use o valor literal em um .mcp.json local (fora do versionamento).`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const parsed = new URL(value);
|
|
26
|
+
if (!/^https?:$/.test(parsed.protocol)) {
|
|
27
|
+
throw new Error(`protocolo não suportado: "${parsed.protocol}"`);
|
|
28
|
+
}
|
|
29
|
+
return parsed.origin + parsed.pathname.replace(/\/$/, "");
|
|
30
|
+
} catch (err) {
|
|
31
|
+
if (err.message?.includes("protocolo não suportado")) {
|
|
32
|
+
throw new Error(`PHAROS_API_URL inválida: ${err.message}. Use http:// ou https://.`);
|
|
33
|
+
}
|
|
34
|
+
throw new Error(
|
|
35
|
+
`PHAROS_API_URL inválida: "${value}". Informe uma URL completa (ex: "http://localhost:8080").`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function parseApiKey(raw) {
|
|
41
|
+
const key = (raw || "").trim();
|
|
42
|
+
if (/\$\{.+\}/.test(key)) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
`PHAROS_API_KEY veio como "${key}" — placeholder não expandido. ` +
|
|
45
|
+
`Claude Code não expande \${VAR} dentro de "env" no .mcp.json: ` +
|
|
46
|
+
`use o valor literal em um .mcp.json local (fora do versionamento).`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
if (key === "SEU_TOKEN_AQUI" || key === "sua-chave-secreta-aqui") {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`PHAROS_API_KEY está com valor de exemplo ("${key}"). ` +
|
|
52
|
+
`Substitua pela sua chave real gerada no portal Pharos no .mcp.json.`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return key;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function parseTimeout(raw) {
|
|
59
|
+
const parsed = Number(raw);
|
|
60
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : 15000;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const PRODUCTS = [
|
|
64
|
+
"GERAL",
|
|
65
|
+
"CLICK_TO_PAY",
|
|
66
|
+
"SCOF",
|
|
67
|
+
"MDES",
|
|
68
|
+
"MASTERCARD_SEND",
|
|
69
|
+
"OPEN_FINANCE",
|
|
70
|
+
"ETHOCA_CONSUMER_CLARITY",
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
export const CLIENTS = ["master", "visa"];
|
|
74
|
+
|
|
75
|
+
export const ProductEnum = z.enum(PRODUCTS);
|
|
76
|
+
export const ClientEnum = z.enum(CLIENTS);
|
|
18
77
|
|
|
19
|
-
|
|
78
|
+
const API_URL = parseApiUrl(process.env.PHAROS_API_URL);
|
|
79
|
+
const API_KEY = parseApiKey(process.env.PHAROS_API_KEY);
|
|
80
|
+
const TIMEOUT_MS = parseTimeout(process.env.PHAROS_TIMEOUT_MS);
|
|
81
|
+
|
|
82
|
+
export async function callApi(path, options = {}) {
|
|
20
83
|
const controller = new AbortController();
|
|
21
84
|
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
22
85
|
try {
|
|
@@ -31,6 +94,19 @@ async function callApi(path, options = {}) {
|
|
|
31
94
|
});
|
|
32
95
|
const text = await res.text();
|
|
33
96
|
if (!res.ok) {
|
|
97
|
+
if (res.status === 401) {
|
|
98
|
+
if (!API_KEY) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
`Pharos respondeu 401 (Não autorizado): o cabeçalho X-API-Key não foi enviado porque ` +
|
|
101
|
+
`a variável PHAROS_API_KEY não está configurada no .mcp.json. ` +
|
|
102
|
+
`Gere uma chave no portal Pharos e configure em "env": { "PHAROS_API_KEY": "..." }.`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
throw new Error(
|
|
106
|
+
`Pharos respondeu 401 (Não autorizado): a chave configurada em PHAROS_API_KEY foi rejeitada. ` +
|
|
107
|
+
`Verifique se a chave é válida, não expirou e corresponde ao ambiente em ${API_URL}.`
|
|
108
|
+
);
|
|
109
|
+
}
|
|
34
110
|
let detail = text;
|
|
35
111
|
try {
|
|
36
112
|
const problem = JSON.parse(text);
|
|
@@ -43,12 +119,17 @@ async function callApi(path, options = {}) {
|
|
|
43
119
|
return text ? JSON.parse(text) : null;
|
|
44
120
|
} catch (err) {
|
|
45
121
|
if (err.name === "AbortError") {
|
|
46
|
-
throw new Error(`Pharos
|
|
122
|
+
throw new Error(`Pharos não respondeu em ${TIMEOUT_MS}ms (${API_URL}).`);
|
|
47
123
|
}
|
|
48
124
|
if (err.cause?.code === "ECONNREFUSED") {
|
|
49
125
|
throw new Error(
|
|
50
|
-
`
|
|
51
|
-
`Confirme que o portal
|
|
126
|
+
`Não consegui conectar ao Pharos em ${API_URL}. ` +
|
|
127
|
+
`Confirme que o portal está no ar ou ajuste PHAROS_API_URL.`
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
if (err.cause?.code === "ENOTFOUND") {
|
|
131
|
+
throw new Error(
|
|
132
|
+
`Host não encontrado para PHAROS_API_URL (${API_URL}). Verifique o domínio configurado.`
|
|
52
133
|
);
|
|
53
134
|
}
|
|
54
135
|
throw err;
|
|
@@ -57,29 +138,36 @@ async function callApi(path, options = {}) {
|
|
|
57
138
|
}
|
|
58
139
|
}
|
|
59
140
|
|
|
60
|
-
const server = new McpServer({ name: "pharos", version: "0.1.
|
|
141
|
+
export const server = new McpServer({ name: "pharos", version: "0.1.1" });
|
|
61
142
|
|
|
62
143
|
server.registerTool(
|
|
63
144
|
"search_knowledge",
|
|
64
145
|
{
|
|
65
146
|
title: "Buscar na base de conhecimento",
|
|
66
147
|
description:
|
|
67
|
-
"Busca trechos na base interna de conhecimento sobre
|
|
68
|
-
"(
|
|
69
|
-
"
|
|
148
|
+
"Busca trechos na base interna de conhecimento do Pharos sobre integrações de bandeiras " +
|
|
149
|
+
"(Mastercard/Visa), com foco em soluções reais da equipe (Click to Pay, pontes WebView/SDK mobile, " +
|
|
150
|
+
"TAS/Passkey, certificação e Consumer Clarity). " +
|
|
151
|
+
"NÃO contém guias de autenticação genérica (OAuth 1.0a, mTLS, criptografia) — " +
|
|
152
|
+
"para detalhes de API oficial, consulte o MCP oficial (@mastercard/developers-mcp) ou a documentação da bandeira. " +
|
|
153
|
+
"Devolve os trechos brutos com a fonte, sem resposta pronta — cabe a você sintetizar " +
|
|
70
154
|
"combinando com o contexto do projeto atual. Cite a fonte ao usar. " +
|
|
71
|
-
"Retorna apenas
|
|
155
|
+
"Retorna apenas conteúdo revisado e aprovado pela equipe.",
|
|
72
156
|
inputSchema: {
|
|
73
|
-
query: z.string().describe("Pergunta ou termos de busca, em
|
|
74
|
-
client:
|
|
75
|
-
.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
157
|
+
query: z.string().describe("Pergunta ou termos de busca, em português"),
|
|
158
|
+
client: ClientEnum.optional().describe(
|
|
159
|
+
"Cliente/bandeira: master ou visa. Se omitido, usa o tenant padrão ativo."
|
|
160
|
+
),
|
|
161
|
+
product: ProductEnum.optional().describe(
|
|
162
|
+
`Filtro opcional de produto: ${PRODUCTS.join(", ")}`
|
|
163
|
+
),
|
|
164
|
+
topK: z
|
|
165
|
+
.number()
|
|
166
|
+
.int()
|
|
167
|
+
.min(1)
|
|
168
|
+
.max(20)
|
|
80
169
|
.optional()
|
|
81
|
-
.describe("
|
|
82
|
-
topK: z.number().int().min(1).max(20).optional().describe("Quantos trechos retornar (padrao 6)"),
|
|
170
|
+
.describe("Quantos trechos retornar (padrão 6)"),
|
|
83
171
|
},
|
|
84
172
|
},
|
|
85
173
|
async ({ query, client, product, topK }) => {
|
|
@@ -89,33 +177,43 @@ server.registerTool(
|
|
|
89
177
|
if (topK) params.set("topK", String(topK));
|
|
90
178
|
|
|
91
179
|
const result = await callApi(`/search?${params}`);
|
|
180
|
+
const hits = Array.isArray(result?.hits) ? result.hits : [];
|
|
92
181
|
|
|
93
|
-
if (!
|
|
182
|
+
if (!hits.length) {
|
|
94
183
|
return {
|
|
95
184
|
content: [
|
|
96
185
|
{
|
|
97
186
|
type: "text",
|
|
98
187
|
text:
|
|
99
188
|
`Nenhum trecho encontrado na base para "${query}".\n\n` +
|
|
100
|
-
`A base cobre apenas o que a equipe
|
|
189
|
+
`A base cobre apenas o que a equipe já registrou. Se você resolver este ` +
|
|
101
190
|
`problema agora, vale registrar com a ferramenta register_solution para o ` +
|
|
102
|
-
`
|
|
191
|
+
`próximo dev não repetir a investigação.`,
|
|
103
192
|
},
|
|
104
193
|
],
|
|
105
194
|
};
|
|
106
195
|
}
|
|
107
196
|
|
|
108
|
-
const formatted =
|
|
197
|
+
const formatted = hits
|
|
109
198
|
.map((hit, i) => {
|
|
110
|
-
const origem = hit
|
|
199
|
+
const origem = hit?.sourceDocPath
|
|
111
200
|
? `doc ${hit.sourceDocPath}`
|
|
112
|
-
: `entrada ${hit
|
|
201
|
+
: `entrada ${hit?.entryId ?? "(sem id)"} (registrada por um dev)`;
|
|
202
|
+
const similarity =
|
|
203
|
+
typeof hit?.cosineSimilarity === "number"
|
|
204
|
+
? hit.cosineSimilarity.toFixed(3)
|
|
205
|
+
: "N/A";
|
|
206
|
+
const tags =
|
|
207
|
+
Array.isArray(hit?.tags) && hit.tags.length
|
|
208
|
+
? `Tags: ${hit.tags.join(", ")}`
|
|
209
|
+
: null;
|
|
210
|
+
|
|
113
211
|
return [
|
|
114
|
-
`## [${i + 1}] ${hit
|
|
115
|
-
`Cliente: ${hit
|
|
116
|
-
|
|
212
|
+
`## [${i + 1}] ${hit?.title ?? "(sem título)"}`,
|
|
213
|
+
`Cliente: ${hit?.client || "master"} | Produto: ${hit?.product || "GERAL"} | Fonte: ${origem} | Similaridade: ${similarity}`,
|
|
214
|
+
tags,
|
|
117
215
|
"",
|
|
118
|
-
hit
|
|
216
|
+
hit?.text ?? "",
|
|
119
217
|
]
|
|
120
218
|
.filter((l) => l !== null)
|
|
121
219
|
.join("\n");
|
|
@@ -127,9 +225,9 @@ server.registerTool(
|
|
|
127
225
|
{
|
|
128
226
|
type: "text",
|
|
129
227
|
text:
|
|
130
|
-
`${
|
|
228
|
+
`${hits.length} trecho(s) da base do Pharos para "${query}":\n\n${formatted}\n\n` +
|
|
131
229
|
`---\nAo usar qualquer um destes trechos, cite a fonte correspondente. ` +
|
|
132
|
-
`Para comportamento exato de
|
|
230
|
+
`Para comportamento exato de operações de API, confirme no MCP oficial correspondente.`,
|
|
133
231
|
},
|
|
134
232
|
],
|
|
135
233
|
};
|
|
@@ -139,28 +237,30 @@ server.registerTool(
|
|
|
139
237
|
server.registerTool(
|
|
140
238
|
"register_solution",
|
|
141
239
|
{
|
|
142
|
-
title: "Registrar
|
|
240
|
+
title: "Registrar solução na base de conhecimento",
|
|
143
241
|
description:
|
|
144
|
-
"Registra um problema e sua
|
|
145
|
-
"A entrada entra na fila de
|
|
146
|
-
"
|
|
147
|
-
"Use apenas para conhecimento
|
|
242
|
+
"Registra um problema e sua solução na base interna, para outros devs. " +
|
|
243
|
+
"A entrada entra na fila de revisão com status PENDING e NÃO fica visível em busca " +
|
|
244
|
+
"até ser aprovada manualmente por alguém da equipe. " +
|
|
245
|
+
"Use apenas para conhecimento genérico sobre integração — nunca inclua " +
|
|
148
246
|
"credenciais, dados de cliente, nomes de cliente, endpoints internos ou trechos de " +
|
|
149
|
-
"
|
|
247
|
+
"código proprietário.",
|
|
150
248
|
inputSchema: {
|
|
151
|
-
title: z.string().max(300).describe("
|
|
249
|
+
title: z.string().max(300).describe("Título curto e específico do problema"),
|
|
152
250
|
problem: z
|
|
153
251
|
.string()
|
|
154
252
|
.describe("O problema: sintoma, ambiente, mensagem de erro. Sem dados de cliente."),
|
|
155
|
-
solution: z
|
|
156
|
-
client: z
|
|
253
|
+
solution: z
|
|
157
254
|
.string()
|
|
255
|
+
.describe("O que resolveu, com código ou configuração relevante"),
|
|
256
|
+
client: ClientEnum.optional().describe(
|
|
257
|
+
"Cliente/bandeira: master ou visa (padrão master)"
|
|
258
|
+
),
|
|
259
|
+
product: ProductEnum.describe(`Produto: ${PRODUCTS.join(", ")}`),
|
|
260
|
+
tags: z
|
|
261
|
+
.array(z.string())
|
|
158
262
|
.optional()
|
|
159
|
-
.describe("
|
|
160
|
-
product: z
|
|
161
|
-
.string()
|
|
162
|
-
.describe("Produto: CLICK_TO_PAY, SCOF, MDES, MASTERCARD_SEND, OPEN_FINANCE ou GERAL"),
|
|
163
|
-
tags: z.array(z.string()).optional().describe("Tags como oauth, mtls, sandbox, encryption"),
|
|
263
|
+
.describe("Tags como click_to_pay, ios, webview, passkey, sandbox"),
|
|
164
264
|
},
|
|
165
265
|
},
|
|
166
266
|
async ({ title, problem, solution, client, product, tags }) => {
|
|
@@ -177,20 +277,34 @@ server.registerTool(
|
|
|
177
277
|
}),
|
|
178
278
|
});
|
|
179
279
|
|
|
280
|
+
const entryId = created?.id ?? "(sem id)";
|
|
281
|
+
const entryStatus = created?.status ?? "PENDING";
|
|
282
|
+
|
|
180
283
|
return {
|
|
181
284
|
content: [
|
|
182
285
|
{
|
|
183
286
|
type: "text",
|
|
184
287
|
text:
|
|
185
|
-
`Registrado com id ${
|
|
186
|
-
`IMPORTANTE: informe ao dev que a entrada
|
|
187
|
-
`
|
|
188
|
-
`aprovar manualmente
|
|
288
|
+
`Registrado com id ${entryId} e status ${entryStatus}.\n\n` +
|
|
289
|
+
`IMPORTANTE: informe ao dev que a entrada está AGUARDANDO REVISÃO — ela ainda ` +
|
|
290
|
+
`não está publicada e não aparece na busca de ninguém. Só depois de um revisor ` +
|
|
291
|
+
`aprovar manualmente é que ela vai para o índice. Nunca diga que foi "publicada".`,
|
|
189
292
|
},
|
|
190
293
|
],
|
|
191
294
|
};
|
|
192
295
|
}
|
|
193
296
|
);
|
|
194
297
|
|
|
195
|
-
|
|
196
|
-
|
|
298
|
+
export async function connectStdio() {
|
|
299
|
+
const transport = new StdioServerTransport();
|
|
300
|
+
await server.connect(transport);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const isTest =
|
|
304
|
+
process.env.NODE_ENV === "test" ||
|
|
305
|
+
process.execArgv.includes("--test") ||
|
|
306
|
+
process.argv.some((arg) => arg.includes("test"));
|
|
307
|
+
|
|
308
|
+
if (!isTest) {
|
|
309
|
+
await connectStdio();
|
|
310
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gft-pharos-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "MCP server do Pharos: retrieval e registro de solucoes na base de conhecimento",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "NODE_ENV=test node --test"
|
|
8
|
+
},
|
|
6
9
|
"bin": {
|
|
7
10
|
"gft-pharos-mcp": "./index.js",
|
|
8
11
|
"pharos-mcp": "./index.js"
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { describe, it } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
|
|
4
|
+
// Garantir modo de teste para evitar que o servidor conecte no stdio durante o import
|
|
5
|
+
process.env.NODE_ENV = "test";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
parseApiUrl,
|
|
9
|
+
parseApiKey,
|
|
10
|
+
parseTimeout,
|
|
11
|
+
PRODUCTS,
|
|
12
|
+
CLIENTS,
|
|
13
|
+
ProductEnum,
|
|
14
|
+
ClientEnum,
|
|
15
|
+
server,
|
|
16
|
+
} from "../index.js";
|
|
17
|
+
|
|
18
|
+
describe("gft-pharos-mcp 0.1.1 - Validações e Correções de Bugs", () => {
|
|
19
|
+
describe("Bug 1: parseApiUrl", () => {
|
|
20
|
+
it("deve usar o padrão http://localhost:8080 quando omitido ou vazio", () => {
|
|
21
|
+
assert.equal(parseApiUrl(undefined), "http://localhost:8080");
|
|
22
|
+
assert.equal(parseApiUrl(""), "http://localhost:8080");
|
|
23
|
+
assert.equal(parseApiUrl(" "), "http://localhost:8080");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("deve normalizar a URL removendo barra no final", () => {
|
|
27
|
+
assert.equal(parseApiUrl("http://localhost:8080/"), "http://localhost:8080");
|
|
28
|
+
assert.equal(
|
|
29
|
+
parseApiUrl("https://pharos.gft.com/portal/"),
|
|
30
|
+
"https://pharos.gft.com/portal"
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("deve falhar rápido no boot ao encontrar placeholder ${VAR} não expandido", () => {
|
|
35
|
+
assert.throws(
|
|
36
|
+
() => parseApiUrl("${PHAROS_API_URL}"),
|
|
37
|
+
/placeholder não expandido.*Claude Code não expande \${VAR}/
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("deve rejeitar URLs inválidas ou com protocolo não-http", () => {
|
|
42
|
+
assert.throws(
|
|
43
|
+
() => parseApiUrl("nao-e-uma-url"),
|
|
44
|
+
/PHAROS_API_URL inválida/
|
|
45
|
+
);
|
|
46
|
+
assert.throws(
|
|
47
|
+
() => parseApiUrl("ftp://localhost:8080"),
|
|
48
|
+
/protocolo não suportado/
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe("Bug 2: parseApiKey", () => {
|
|
54
|
+
it("deve aceitar chave vazia para ambientes em modo aberto (sem auth)", () => {
|
|
55
|
+
assert.equal(parseApiKey(""), "");
|
|
56
|
+
assert.equal(parseApiKey(undefined), "");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("deve aceitar uma chave válida", () => {
|
|
60
|
+
assert.equal(parseApiKey("phk_abc123xyz"), "phk_abc123xyz");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("deve falhar no boot ao encontrar placeholder ${VAR} não expandido", () => {
|
|
64
|
+
assert.throws(
|
|
65
|
+
() => parseApiKey("${PHAROS_API_KEY}"),
|
|
66
|
+
/placeholder não expandido.*Claude Code não expande \${VAR}/
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("deve falhar no boot ao encontrar chave dummy do exemplo", () => {
|
|
71
|
+
assert.throws(
|
|
72
|
+
() => parseApiKey("SEU_TOKEN_AQUI"),
|
|
73
|
+
/PHAROS_API_KEY está com valor de exemplo/
|
|
74
|
+
);
|
|
75
|
+
assert.throws(
|
|
76
|
+
() => parseApiKey("sua-chave-secreta-aqui"),
|
|
77
|
+
/PHAROS_API_KEY está com valor de exemplo/
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe("Bug 5: parseTimeout", () => {
|
|
83
|
+
it("deve aceitar números válidos em ms", () => {
|
|
84
|
+
assert.equal(parseTimeout("5000"), 5000);
|
|
85
|
+
assert.equal(parseTimeout(30000), 30000);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("deve usar 15000ms de fallback para valores não numéricos como '15s', NaN ou zero/negativo", () => {
|
|
89
|
+
assert.equal(parseTimeout("15s"), 15000);
|
|
90
|
+
assert.equal(parseTimeout("invalido"), 15000);
|
|
91
|
+
assert.equal(parseTimeout("0"), 15000);
|
|
92
|
+
assert.equal(parseTimeout("-500"), 15000);
|
|
93
|
+
assert.equal(parseTimeout(undefined), 15000);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe("Bug 4: Catálogo e Schemas de Produto e Cliente", () => {
|
|
98
|
+
it("deve conter os 7 produtos canônicos compatíveis com o backend", () => {
|
|
99
|
+
assert.deepEqual(PRODUCTS, [
|
|
100
|
+
"GERAL",
|
|
101
|
+
"CLICK_TO_PAY",
|
|
102
|
+
"SCOF",
|
|
103
|
+
"MDES",
|
|
104
|
+
"MASTERCARD_SEND",
|
|
105
|
+
"OPEN_FINANCE",
|
|
106
|
+
"ETHOCA_CONSUMER_CLARITY",
|
|
107
|
+
]);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("ProductEnum deve validar produtos aceitos e rejeitar typos como CLICK_TO_PAI", () => {
|
|
111
|
+
assert.equal(ProductEnum.parse("CLICK_TO_PAY"), "CLICK_TO_PAY");
|
|
112
|
+
assert.equal(ProductEnum.parse("MASTERCARD_SEND"), "MASTERCARD_SEND");
|
|
113
|
+
assert.throws(() => ProductEnum.parse("CLICK_TO_PAI"));
|
|
114
|
+
assert.throws(() => ProductEnum.parse("INVALIDO"));
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("ClientEnum deve validar master e visa e rejeitar desconhecidos", () => {
|
|
118
|
+
assert.equal(ClientEnum.parse("master"), "master");
|
|
119
|
+
assert.equal(ClientEnum.parse("visa"), "visa");
|
|
120
|
+
assert.throws(() => ClientEnum.parse("elo"));
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe("McpServer e Registro de Ferramentas", () => {
|
|
125
|
+
it("servidor deve estar inicializado com a versão 0.1.1", () => {
|
|
126
|
+
assert.ok(server);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
});
|