jaylog-mcp 0.1.2 → 0.1.4
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/README.md +43 -1
- package/dist/api.js +18 -1
- package/dist/index.js +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ agendamento de tarefas, contra a API do Jaylog.
|
|
|
24
24
|
|
|
25
25
|
## Instalação
|
|
26
26
|
|
|
27
|
-
Requer Node.js 18+. Não precisa instalar nada: o `npx` baixa e executa o pacote.
|
|
27
|
+
Requer Node.js 20.18+. Não precisa instalar nada: o `npx` baixa e executa o pacote.
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
30
|
export JAYLOG_URL=https://seu-app-jaylog # URL do app web do Jaylog
|
|
@@ -88,6 +88,48 @@ npx -y jaylog-mcp logout # remove a credencial local
|
|
|
88
88
|
| `JAYLOG_API_BASE_URL` | Override opcional: URL base da API chamada diretamente, sem passar pelo proxy (ex: `http://localhost:3000`). Quando definida, tem prioridade sobre `JAYLOG_URL` nas chamadas à API. |
|
|
89
89
|
| `JAYLOG_FRONTEND_URL` | Override opcional: URL do app web usada só pelo `login`. Útil em desenvolvimento local, onde a API e o app web rodam em portas diferentes. Se omitida, cai para `JAYLOG_URL`. |
|
|
90
90
|
| `JAYLOG_API_TOKEN` | Override explícito: se definida, tem prioridade sobre a credencial salva pelo `login`. Útil para CI/scripting. Qualquer perfil (guest, standard, staff, admin) funciona — cada tool exige o perfil mínimo que a rota correspondente já exige na API. |
|
|
91
|
+
| `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY` | Opcionais: proxy corporativo usado nas chamadas à API (ex: `http://proxy.empresa:8080`). Aceitos em maiúsculas ou minúsculas; `NO_PROXY` lista hosts que devem ignorar o proxy. |
|
|
92
|
+
|
|
93
|
+
### Proxy corporativo
|
|
94
|
+
|
|
95
|
+
Se a sua rede exige proxy para acessar o Jaylog, defina `HTTPS_PROXY` (e `NO_PROXY`, se precisar)
|
|
96
|
+
no bloco `env` do cliente MCP, junto com o `JAYLOG_URL`:
|
|
97
|
+
|
|
98
|
+
**Claude Code:**
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
claude mcp add jaylog \
|
|
102
|
+
--env JAYLOG_URL=https://seu-app-jaylog \
|
|
103
|
+
--env HTTPS_PROXY=http://proxy.empresa:8080 \
|
|
104
|
+
--env NO_PROXY=localhost,127.0.0.1 \
|
|
105
|
+
-- npx -y jaylog-mcp
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Outros clientes (Claude Desktop, Cursor etc.):**
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"mcpServers": {
|
|
113
|
+
"jaylog": {
|
|
114
|
+
"command": "npx",
|
|
115
|
+
"args": ["-y", "jaylog-mcp"],
|
|
116
|
+
"env": {
|
|
117
|
+
"JAYLOG_URL": "https://seu-app-jaylog",
|
|
118
|
+
"HTTPS_PROXY": "http://proxy.empresa:8080",
|
|
119
|
+
"NO_PROXY": "localhost,127.0.0.1"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
- Como o `JAYLOG_URL` normalmente é `https://`, vale o `HTTPS_PROXY`. O `HTTP_PROXY` só é usado
|
|
127
|
+
quando a URL é `http://`.
|
|
128
|
+
- Se o proxy exigir autenticação, informe as credenciais na URL: `http://usuario:senha@proxy.empresa:8080`.
|
|
129
|
+
- Se o Jaylog for interno e não deve passar pelo proxy, inclua o domínio dele no `NO_PROXY`.
|
|
130
|
+
- As variáveis também podem ser exportadas no shell (`export HTTPS_PROXY=...`) ao rodar o
|
|
131
|
+
servidor manualmente. Nomes em minúsculas (`https_proxy`) também funcionam.
|
|
132
|
+
- Sem nenhuma dessas variáveis, as requisições saem direto, como antes.
|
|
91
133
|
|
|
92
134
|
## Desenvolvimento
|
|
93
135
|
|
package/dist/api.js
CHANGED
|
@@ -51,13 +51,30 @@ function buildUrl(path, qs = {}) {
|
|
|
51
51
|
}
|
|
52
52
|
return url.toString();
|
|
53
53
|
}
|
|
54
|
+
const hasProxyEnv = () => ['HTTP_PROXY', 'HTTPS_PROXY', 'http_proxy', 'https_proxy'].some((name) => process.env[name]);
|
|
55
|
+
let proxyFetch;
|
|
56
|
+
/**
|
|
57
|
+
* Bun's `fetch` already honours `HTTP_PROXY`/`HTTPS_PROXY`/`NO_PROXY`, but
|
|
58
|
+
* Node's does not (the published bin runs on Node). So on Node, when a proxy is
|
|
59
|
+
* configured, route through undici's `EnvHttpProxyAgent`, which reads the same
|
|
60
|
+
* variables. Without a proxy configured, plain `fetch` is used untouched.
|
|
61
|
+
*/
|
|
62
|
+
async function proxyAwareFetch(url, init) {
|
|
63
|
+
if (process.versions.bun || !hasProxyEnv())
|
|
64
|
+
return fetch(url, init);
|
|
65
|
+
proxyFetch ??= import('undici').then(({ fetch: undiciFetch, EnvHttpProxyAgent }) => {
|
|
66
|
+
const dispatcher = new EnvHttpProxyAgent();
|
|
67
|
+
return ((input, init) => undiciFetch(input, { ...init, dispatcher }));
|
|
68
|
+
});
|
|
69
|
+
return (await proxyFetch)(url, init);
|
|
70
|
+
}
|
|
54
71
|
async function fetchJSON(path, qs = {}) {
|
|
55
72
|
const url = buildUrl(path, qs);
|
|
56
73
|
const headers = await getAuthHeaders();
|
|
57
74
|
if (!headers.Authorization) {
|
|
58
75
|
throw new Error('Not authenticated. Run `bun run login` (or set JAYLOG_API_TOKEN) before using jaylog-mcp.');
|
|
59
76
|
}
|
|
60
|
-
const resp = await
|
|
77
|
+
const resp = await proxyAwareFetch(url, { headers });
|
|
61
78
|
if (!resp.ok) {
|
|
62
79
|
const body = await resp.text().catch(() => '');
|
|
63
80
|
throw new Error(`Jaylog API error [${resp.status}] ${resp.statusText}${body ? `: ${body}` : ''}`);
|
package/dist/index.js
CHANGED
|
@@ -11,10 +11,13 @@ const keyUsers_1 = require("./tools/keyUsers");
|
|
|
11
11
|
const logs_1 = require("./tools/logs");
|
|
12
12
|
const schedules_1 = require("./tools/schedules");
|
|
13
13
|
const services_1 = require("./tools/services");
|
|
14
|
+
// `require` (not `import`) keeps package.json out of tsc's rootDir; the path resolves
|
|
15
|
+
// the same from src/ (bun) and dist/ (published), so the reported version can't drift.
|
|
16
|
+
const { version } = require('../package.json');
|
|
14
17
|
async function runServer() {
|
|
15
18
|
const server = new mcp_js_1.McpServer({
|
|
16
19
|
name: 'Jaylog',
|
|
17
|
-
version
|
|
20
|
+
version
|
|
18
21
|
});
|
|
19
22
|
(0, logs_1.registerLogTools)(server);
|
|
20
23
|
(0, services_1.registerServiceTools)(server);
|