@kealthas-dev/opencode-mcp-loki 1.0.14 → 1.0.18
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 +1 -1
- package/dist/server.js +14 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -82,4 +82,4 @@ The default config file is already in place inside that shell — `docker-entryp
|
|
|
82
82
|
|
|
83
83
|
**Direct-to-Loki path verified end-to-end and automated.** `loki.test.ts` covers tool listing, `loki_labels`/`loki_label_values` finding pushed test data, `loki_query_range` finding a pushed log line by content, an empty-result query returning cleanly (not an error), and a malformed LogQL query returning a clean error — driven over the real Streamable HTTP transport against the sandbox's `loki` service. Wired into `deploy/opencode.json.example` (`mcp.loki`, `type: "remote"`, `enabled: true`).
|
|
84
84
|
|
|
85
|
-
**`LOKI_VIA_GRAFANA` verified
|
|
85
|
+
**`LOKI_VIA_GRAFANA` verified against a fake stand-in HTTP server, now automated in `loki.test.ts`** (confirms the request lands on `/api/datasources/proxy/<id>/...` with the right Basic Auth header, and that a redirect-to-login response — real Grafana's actual failure mode for rejected auth, a 302, not a 401 — surfaces as a clean `{success: false}` diagnostic instead of an opaque JSON-parse error) — still not against a real Grafana instance. See `mcp-servers/TODO.md` for adding a real Grafana fixture to the sandbox.
|
package/dist/server.js
CHANGED
|
@@ -136,7 +136,20 @@ async function lokiFetch(path, params) {
|
|
|
136
136
|
if (lokiConfig.LOKI_ORG_ID)
|
|
137
137
|
headers["X-Scope-OrgID"] = lokiConfig.LOKI_ORG_ID;
|
|
138
138
|
try {
|
|
139
|
-
|
|
139
|
+
// Manual redirect handling: a Grafana instance rejecting the request
|
|
140
|
+
// (missing/expired auth, or LOKI_VIA_GRAFANA off when it should be on)
|
|
141
|
+
// responds with a 302 to its own login page, not a 401. Node's fetch
|
|
142
|
+
// follows that by default, landing on the login page's HTML with a
|
|
143
|
+
// misleadingly "successful" 200 status - the JSON.parse below would
|
|
144
|
+
// then fail with an opaque syntax error instead of a diagnosable one.
|
|
145
|
+
const response = await fetch(url, { headers, redirect: "manual" });
|
|
146
|
+
if (response.status >= 300 && response.status < 400) {
|
|
147
|
+
const location = response.headers.get("location") ?? "(no Location header)";
|
|
148
|
+
const hint = lokiConfig.LOKI_VIA_GRAFANA
|
|
149
|
+
? "check LOKI_USERNAME/LOKI_PASSWORD (must be a real Grafana user's Basic Auth) and LOKI_GRAFANA_DATASOURCE_ID"
|
|
150
|
+
: "if this Loki is only reachable through Grafana's datasource proxy, set LOKI_VIA_GRAFANA: true (see README's Configuration section)";
|
|
151
|
+
return { success: false, error: `Request was redirected (${response.status}) to ${location} instead of returning data - ${hint}.` };
|
|
152
|
+
}
|
|
140
153
|
// Text first, not response.json() - Loki's error responses aren't
|
|
141
154
|
// guaranteed the same JSON shape as success (sometimes plain text).
|
|
142
155
|
const text = await response.text();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kealthas-dev/opencode-mcp-loki",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "MCP server exposing read-only Loki query/label tools - see README.md for design and the config.json-driven config",
|
|
6
6
|
"main": "dist/server.js",
|