@kealthas-dev/opencode-mcp-loki 1.0.0
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 +56 -0
- package/package.json +29 -0
- package/server.js +252 -0
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# loki mcp server
|
|
2
|
+
|
|
3
|
+
A minimal MCP server exposing three read-only tools — `loki_query_range`, `loki_labels`, `loki_label_values` — against a configured Grafana Loki instance's HTTP query API. Built directly against `@modelcontextprotocol/sdk`, same hand-rolled-against-the-raw-API pattern as `mcp-servers/oracle/`. Speaks MCP over Streamable HTTP, as a persistent process opencode connects to (`type: "remote"`) rather than spawns and owns (`type: "local"`) — same deployment shape as `mcp-servers/oracle/`.
|
|
4
|
+
|
|
5
|
+
## Design, and why it looks the way it does
|
|
6
|
+
|
|
7
|
+
- **Remote, not local**, for the same reason as `mcp-servers/oracle/`: a persistent HTTP server, started independently (`npm start` under a process supervisor — see `deploy/opencode.json.example`/SETUP.md) and reachable at a fixed URL, so its uptime isn't tied to opencode's own restarts.
|
|
8
|
+
- **Stateless HTTP, one `Server`/transport pair per request** (`sessionIdGenerator: undefined`, matching the SDK's own reference example and `mcp-servers/oracle/server.js`'s shell). No session state worth keeping between calls.
|
|
9
|
+
- **Three tools, not one.** `loki_query_range` is the actual log query (arbitrary LogQL, full passthrough — no filtering, mirroring `oracle_query`'s "safety lives elsewhere" stance, except there's no write side here to guard against in the first place). `loki_labels`/`loki_label_values` exist because LogQL selectors need real label names/values to be useful — without a way to discover them, an agent (or a human) querying unfamiliar logs would have to guess. All three are read-only GETs; adding the two discovery tools costs nothing beyond `oracle_query`'s single-tool baseline.
|
|
10
|
+
- **`start`/`end` accept relative and naive-local forms, not just Loki's own RFC3339/epoch.** Handing a caller (model or human) the burden of computing an exact RFC3339 offset or a 19-digit nanosecond epoch by hand is real friction, so `resolveTimeParam()` in `server.js` accepts `"now"`/`"now-1h"`/`"now-30m"`/`"now-1d"` (Grafana's own relative-time syntax for Loki/Prometheus, not invented here) and a bare `"YYYY-MM-DDTHH:MM:SS"`/`"YYYY-MM-DD HH:MM:SS"` with no timezone (assumed to be `LOKI_DEFAULT_TZ_OFFSET`, default `+08:00`), converting either into what Loki actually expects before the request goes out. An already-qualified RFC3339 offset or bare epoch still passes straight through unchanged - purely additive, not a breaking change to the original format.
|
|
11
|
+
- **No connection lifecycle, no audit hook.** `mcp-servers/oracle/server.js`'s per-request-connection design and `auditQuery()` extension point both exist because SQL can write. Loki's query API has no write side at all, so there's nothing analogous to design around — each tool call is just a plain `fetch`, wrapped so a non-2xx response or network failure comes back as a clean `{success: false, error}` instead of a thrown error (same shape `executeQuery()` returns in `mcp-servers/oracle/server.js`, same reason: tool results should never surface as a raw MCP protocol error).
|
|
12
|
+
|
|
13
|
+
## Configuration
|
|
14
|
+
|
|
15
|
+
Copy `.env.example` to `.env` and fill in real values, or set them however the process supervisor that starts this server (see Run below) is configured. A `remote` MCP entry in `opencode.json` carries no `environment` field (just a `url`) — opencode never starts this process, so wherever it actually gets started is what needs these set:
|
|
16
|
+
|
|
17
|
+
- `LOKI_BASE_URL` — base URL of the Loki instance, no trailing path (e.g. `http://192.168.1.100:3100`)
|
|
18
|
+
- `LOKI_USERNAME` / `LOKI_PASSWORD` — optional, HTTP basic auth, only if this Loki instance requires it
|
|
19
|
+
- `LOKI_ORG_ID` — optional, sets `X-Scope-OrgID` for multi-tenant Loki / Grafana Cloud-style setups
|
|
20
|
+
- `LOKI_MCP_PORT` — port to listen on (optional, defaults to `8091` — the next free port after `mcp-servers/oracle/`'s `8090`)
|
|
21
|
+
|
|
22
|
+
Unlike `mcp-servers/oracle/`, only `LOKI_BASE_URL` is required — Loki is commonly reachable unauthenticated on an internal LAN.
|
|
23
|
+
|
|
24
|
+
## Run
|
|
25
|
+
|
|
26
|
+
Published as `@kealthas-dev/opencode-mcp-loki` — on a real deployment, install it globally and run the resulting binary (see SETUP.md step 7):
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install -g @kealthas-dev/opencode-mcp-loki
|
|
30
|
+
LOKI_BASE_URL=... opencode-mcp-loki
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
For local dev/testing against this repo's own checkout (this directory, not the published package):
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install
|
|
37
|
+
npm start
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Either way, this starts a persistent HTTP server on `LOKI_MCP_PORT` (default `8091`), serving MCP over Streamable HTTP at `/mcp`. Point opencode at it with a `type: "remote"` entry (see `deploy/opencode.json.example`) — it needs to already be running and stay running, since opencode connects rather than spawns it (either command alone exits when its terminal closes; see `mcp-servers/oracle/README.md`'s Design section for real supervisor options — the same reasoning applies here).
|
|
41
|
+
|
|
42
|
+
## Testing against a real Loki instance
|
|
43
|
+
|
|
44
|
+
`docker/docker-compose.loki.yml`'s `loki` service comes up automatically via `docker/dev.sh`, no separate step needed:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
docker/dev.sh run --rm opencode-dev bash
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`LOKI_BASE_URL` is already set inside that shell — `cd mcp-servers/loki && npm install && npm start`, then hit `http://localhost:8091/mcp` from an MCP client or `curl`.
|
|
51
|
+
|
|
52
|
+
`loki.test.mjs` (see `tests/README.md`) doesn't need this manual dance — it starts and stops its own `server.js` process on its own port as part of the test run, and seeds its own test log lines by pushing directly to Loki's push API (not through this MCP server, which is read-only by design).
|
|
53
|
+
|
|
54
|
+
## Status
|
|
55
|
+
|
|
56
|
+
**Verified end-to-end and automated.** `loki.test.mjs` 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`).
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kealthas-dev/opencode-mcp-loki",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "MCP server exposing read-only Loki query/label tools - see README.md for design",
|
|
6
|
+
"main": "server.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"opencode-mcp-loki": "server.js"
|
|
9
|
+
},
|
|
10
|
+
"files": ["server.js"],
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/Keal-thas/opencode-toolkit.git",
|
|
17
|
+
"directory": "mcp-servers/loki"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"start": "node server.js",
|
|
21
|
+
"dev": "nodemon server.js"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"nodemon": "^3.1.0"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/server.js
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import http from "node:http";
|
|
3
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
4
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
5
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
6
|
+
|
|
7
|
+
const LOKI_BASE_URL = process.env.LOKI_BASE_URL;
|
|
8
|
+
const LOKI_USERNAME = process.env.LOKI_USERNAME;
|
|
9
|
+
const LOKI_PASSWORD = process.env.LOKI_PASSWORD;
|
|
10
|
+
const LOKI_ORG_ID = process.env.LOKI_ORG_ID;
|
|
11
|
+
const LOKI_MCP_PORT = Number(process.env.LOKI_MCP_PORT ?? "8091");
|
|
12
|
+
// Only matters for the "naive" datetime case in resolveTimeParam() below -
|
|
13
|
+
// Loki itself is never told about this, it only ever sees a fully-
|
|
14
|
+
// qualified offset or an epoch. Defaults to Beijing time since that's
|
|
15
|
+
// this deployment's actual timezone; override for a different one.
|
|
16
|
+
const LOKI_DEFAULT_TZ_OFFSET = process.env.LOKI_DEFAULT_TZ_OFFSET ?? "+08:00";
|
|
17
|
+
|
|
18
|
+
if (!LOKI_BASE_URL) {
|
|
19
|
+
console.error("Missing Loki connection details. Set LOKI_BASE_URL.");
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Computing a correct start/end by hand (an exact RFC3339 offset, or -
|
|
24
|
+
// worse - a 19-digit nanosecond epoch) is real friction for whatever's
|
|
25
|
+
// calling this tool, model or human. This resolves three friendlier
|
|
26
|
+
// forms into whatever Loki actually accepts, so most callers never have
|
|
27
|
+
// to touch epoch math at all:
|
|
28
|
+
// - "now" / "now-<duration>" (duration is <n><unit> pairs, unit one of
|
|
29
|
+
// s/m/h/d, e.g. "now-1h", "now-30m", "now-1d") - the same relative-time
|
|
30
|
+
// convention Grafana itself uses for Loki/Prometheus time ranges, not
|
|
31
|
+
// an invented one.
|
|
32
|
+
// - a bare "YYYY-MM-DDTHH:MM:SS" or "YYYY-MM-DD HH:MM:SS" with no
|
|
33
|
+
// timezone - assumed to be in LOKI_DEFAULT_TZ_OFFSET and qualified
|
|
34
|
+
// before being sent.
|
|
35
|
+
// Anything else (already a full RFC3339 offset, or a bare epoch number)
|
|
36
|
+
// passes straight through unchanged - both were already correct inputs
|
|
37
|
+
// before this existed, and stay correct. An unrecognized shape also
|
|
38
|
+
// passes straight through rather than being rejected here - Loki's own
|
|
39
|
+
// parser is the final judge and returns its own clean error, same
|
|
40
|
+
// full-passthrough philosophy as everywhere else in this server.
|
|
41
|
+
const RELATIVE_TIME_RE = /^now(?:-((?:\d+[smhd])+))?$/;
|
|
42
|
+
const DURATION_PART_RE = /(\d+)([smhd])/g;
|
|
43
|
+
const NAIVE_DATETIME_RE = /^(\d{4}-\d{2}-\d{2})[T ](\d{2}:\d{2}:\d{2}(?:\.\d+)?)$/;
|
|
44
|
+
const UNIT_MS = { s: 1000, m: 60_000, h: 3_600_000, d: 86_400_000 };
|
|
45
|
+
|
|
46
|
+
function resolveTimeParam(value) {
|
|
47
|
+
if (value === undefined || value === null) return value;
|
|
48
|
+
|
|
49
|
+
const relative = RELATIVE_TIME_RE.exec(value);
|
|
50
|
+
if (relative) {
|
|
51
|
+
let offsetMs = 0;
|
|
52
|
+
for (const [, amount, unit] of relative[1]?.matchAll(DURATION_PART_RE) ?? []) {
|
|
53
|
+
offsetMs += Number(amount) * UNIT_MS[unit];
|
|
54
|
+
}
|
|
55
|
+
return String((Date.now() - offsetMs) * 1_000_000);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const naive = NAIVE_DATETIME_RE.exec(value);
|
|
59
|
+
if (naive) return `${naive[1]}T${naive[2]}${LOKI_DEFAULT_TZ_OFFSET}`;
|
|
60
|
+
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Loki's query API (what every tool below hits) has no write side at all -
|
|
65
|
+
// unlike Oracle there's no executeQuery()-style connection lifecycle or
|
|
66
|
+
// auditQuery() gate to design around here. Every call is a plain,
|
|
67
|
+
// stateless GET; this helper just centralizes URL-building, the optional
|
|
68
|
+
// auth headers, and turning a non-2xx/network failure into a clean
|
|
69
|
+
// {success: false} instead of a thrown error - mirroring the shape
|
|
70
|
+
// executeQuery() returns in mcp-servers/oracle/server.js, for the same reason:
|
|
71
|
+
// tool results should never surface as a raw MCP protocol error.
|
|
72
|
+
async function lokiFetch(path, params) {
|
|
73
|
+
const url = new URL(path, LOKI_BASE_URL);
|
|
74
|
+
for (const [key, value] of Object.entries(params ?? {})) {
|
|
75
|
+
if (value !== undefined && value !== null) url.searchParams.set(key, String(value));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const headers = {};
|
|
79
|
+
if (LOKI_USERNAME || LOKI_PASSWORD) {
|
|
80
|
+
headers.Authorization = `Basic ${Buffer.from(`${LOKI_USERNAME ?? ""}:${LOKI_PASSWORD ?? ""}`).toString("base64")}`;
|
|
81
|
+
}
|
|
82
|
+
if (LOKI_ORG_ID) headers["X-Scope-OrgID"] = LOKI_ORG_ID;
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
const response = await fetch(url, { headers });
|
|
86
|
+
// Read as text first, not response.json() directly - Loki's error
|
|
87
|
+
// responses aren't guaranteed to be the same JSON shape as its
|
|
88
|
+
// success responses (sometimes plain text), so parsing is only safe
|
|
89
|
+
// once response.ok is known.
|
|
90
|
+
const text = await response.text();
|
|
91
|
+
|
|
92
|
+
if (!response.ok) {
|
|
93
|
+
return { success: false, error: `Loki returned ${response.status}: ${text || response.statusText}` };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const body = text ? JSON.parse(text) : null;
|
|
97
|
+
return { success: true, data: body?.data };
|
|
98
|
+
} catch (err) {
|
|
99
|
+
return { success: false, error: err.message };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function queryRange({ query, start, end, limit, direction, step }) {
|
|
104
|
+
return lokiFetch("/loki/api/v1/query_range", {
|
|
105
|
+
query,
|
|
106
|
+
start: resolveTimeParam(start),
|
|
107
|
+
end: resolveTimeParam(end),
|
|
108
|
+
limit,
|
|
109
|
+
direction,
|
|
110
|
+
step,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function listLabels({ start, end }) {
|
|
115
|
+
return lokiFetch("/loki/api/v1/labels", { start: resolveTimeParam(start), end: resolveTimeParam(end) });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function listLabelValues({ label, start, end }) {
|
|
119
|
+
return lokiFetch(`/loki/api/v1/label/${encodeURIComponent(label)}/values`, {
|
|
120
|
+
start: resolveTimeParam(start),
|
|
121
|
+
end: resolveTimeParam(end),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const TIME_PARAM_DESCRIPTION =
|
|
126
|
+
`Accepts, in order of preference: a relative time ("now", "now-1h", "now-30m", "now-1d", ` +
|
|
127
|
+
`"now-1h30m" - Grafana's own relative-time syntax for Loki/Prometheus); a local datetime with ` +
|
|
128
|
+
`no timezone, e.g. "2026-09-15T10:00:00" or "2026-09-15 10:00:00" (assumed to be ${LOKI_DEFAULT_TZ_OFFSET}); ` +
|
|
129
|
+
`or an already-qualified absolute value (RFC3339 with an explicit offset, e.g. "2026-09-15T10:00:00+08:00", ` +
|
|
130
|
+
`or a unix epoch in seconds or nanoseconds).`;
|
|
131
|
+
|
|
132
|
+
function createMcpServer() {
|
|
133
|
+
const server = new Server({ name: "loki-mcp", version: "1.0.0" }, { capabilities: { tools: {} } });
|
|
134
|
+
|
|
135
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
136
|
+
tools: [
|
|
137
|
+
{
|
|
138
|
+
name: "loki_query_range",
|
|
139
|
+
description:
|
|
140
|
+
"Run a LogQL query against the configured Loki instance over a time range and return matching log lines. Full passthrough - any valid LogQL expression, no restriction.",
|
|
141
|
+
inputSchema: {
|
|
142
|
+
type: "object",
|
|
143
|
+
properties: {
|
|
144
|
+
query: { type: "string", description: "LogQL query, e.g. '{app=\"api\"} |= \"error\"'" },
|
|
145
|
+
start: { type: "string", description: TIME_PARAM_DESCRIPTION + " Optional - Loki defaults to a recent window." },
|
|
146
|
+
end: { type: "string", description: TIME_PARAM_DESCRIPTION + " Optional." },
|
|
147
|
+
limit: { type: "number", description: "Max number of log lines to return. Optional - Loki defaults to 100." },
|
|
148
|
+
direction: { type: "string", enum: ["forward", "backward"], description: "Optional - Loki defaults to backward (newest first)." },
|
|
149
|
+
step: { type: "string", description: "Query resolution step for metric queries, e.g. '30s'. Optional." },
|
|
150
|
+
},
|
|
151
|
+
required: ["query"],
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "loki_labels",
|
|
156
|
+
description: "List the label names known to Loki, optionally restricted to a time range. Use this to discover what's queryable before writing a LogQL selector.",
|
|
157
|
+
inputSchema: {
|
|
158
|
+
type: "object",
|
|
159
|
+
properties: {
|
|
160
|
+
start: { type: "string", description: TIME_PARAM_DESCRIPTION + " Optional." },
|
|
161
|
+
end: { type: "string", description: TIME_PARAM_DESCRIPTION + " Optional." },
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: "loki_label_values",
|
|
167
|
+
description: "List the values seen for one label name, optionally restricted to a time range. Use this after loki_labels to find a concrete value to filter on.",
|
|
168
|
+
inputSchema: {
|
|
169
|
+
type: "object",
|
|
170
|
+
properties: {
|
|
171
|
+
label: { type: "string", description: "The label name to list values for, e.g. 'app' or 'namespace'." },
|
|
172
|
+
start: { type: "string", description: TIME_PARAM_DESCRIPTION + " Optional." },
|
|
173
|
+
end: { type: "string", description: TIME_PARAM_DESCRIPTION + " Optional." },
|
|
174
|
+
},
|
|
175
|
+
required: ["label"],
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
}));
|
|
180
|
+
|
|
181
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
182
|
+
const { name, arguments: args } = request.params;
|
|
183
|
+
|
|
184
|
+
let result;
|
|
185
|
+
switch (name) {
|
|
186
|
+
case "loki_query_range":
|
|
187
|
+
if (!args?.query) return { content: [{ type: "text", text: "Missing required argument: query" }], isError: true };
|
|
188
|
+
result = await queryRange(args);
|
|
189
|
+
break;
|
|
190
|
+
case "loki_labels":
|
|
191
|
+
result = await listLabels(args ?? {});
|
|
192
|
+
break;
|
|
193
|
+
case "loki_label_values":
|
|
194
|
+
if (!args?.label) return { content: [{ type: "text", text: "Missing required argument: label" }], isError: true };
|
|
195
|
+
result = await listLabelValues(args);
|
|
196
|
+
break;
|
|
197
|
+
default:
|
|
198
|
+
return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true };
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
return server;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Stateless mode (sessionIdGenerator: undefined) with a fresh Server +
|
|
208
|
+
// transport pair per request - same shell as mcp-servers/oracle/server.js, for the
|
|
209
|
+
// same reason (the SDK's own reference stateless Streamable HTTP server;
|
|
210
|
+
// no session state worth sharing between calls, and sharing one pair would
|
|
211
|
+
// just mean concurrent requests fighting over the same transport).
|
|
212
|
+
const httpServer = http.createServer(async (req, res) => {
|
|
213
|
+
const url = new URL(req.url, `http://${req.headers.host ?? "localhost"}`);
|
|
214
|
+
if (url.pathname !== "/mcp") {
|
|
215
|
+
res.writeHead(404).end();
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
if (req.method !== "POST") {
|
|
219
|
+
res.writeHead(405, { "Content-Type": "application/json" }).end(
|
|
220
|
+
JSON.stringify({ jsonrpc: "2.0", error: { code: -32000, message: "Method not allowed." }, id: null }),
|
|
221
|
+
);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const mcpServer = createMcpServer();
|
|
226
|
+
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined });
|
|
227
|
+
res.on("close", () => {
|
|
228
|
+
transport.close();
|
|
229
|
+
mcpServer.close();
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
try {
|
|
233
|
+
await mcpServer.connect(transport);
|
|
234
|
+
await transport.handleRequest(req, res);
|
|
235
|
+
} catch (err) {
|
|
236
|
+
console.error("Error handling MCP request:", err);
|
|
237
|
+
if (!res.headersSent) {
|
|
238
|
+
res.writeHead(500, { "Content-Type": "application/json" }).end(
|
|
239
|
+
JSON.stringify({ jsonrpc: "2.0", error: { code: -32603, message: "Internal server error" }, id: null }),
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
httpServer.on("error", (err) => {
|
|
246
|
+
console.error("Fatal server error:", err);
|
|
247
|
+
process.exit(1);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
httpServer.listen(LOKI_MCP_PORT, () => {
|
|
251
|
+
console.error(`Loki MCP server listening on http://localhost:${LOKI_MCP_PORT}/mcp`);
|
|
252
|
+
});
|