@hasna/logs 0.3.8 → 0.3.9
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/mcp/index.js +32 -0
- package/package.json +1 -1
- package/src/mcp/index.ts +25 -0
package/dist/mcp/index.js
CHANGED
|
@@ -41,6 +41,10 @@ import {
|
|
|
41
41
|
import {
|
|
42
42
|
parseTime
|
|
43
43
|
} from "../index-997bkzr2.js";
|
|
44
|
+
import {
|
|
45
|
+
exportToCsv,
|
|
46
|
+
exportToJson
|
|
47
|
+
} from "../index-eh9bkbpa.js";
|
|
44
48
|
import {
|
|
45
49
|
__commonJS,
|
|
46
50
|
__export,
|
|
@@ -28654,6 +28658,34 @@ server.tool("log_context_from_id", {
|
|
|
28654
28658
|
}, ({ log_id, brief }) => ({
|
|
28655
28659
|
content: [{ type: "text", text: JSON.stringify(applyBrief(getLogContextFromId(db, log_id), brief !== false)) }]
|
|
28656
28660
|
}));
|
|
28661
|
+
server.tool("log_export", {
|
|
28662
|
+
project_id: exports_external.string().optional().describe("Project name or ID"),
|
|
28663
|
+
format: exports_external.enum(["json", "csv"]).optional().default("json").describe("Output format"),
|
|
28664
|
+
since: exports_external.string().optional().describe("Since time (1h, 24h, 7d, ISO)"),
|
|
28665
|
+
until: exports_external.string().optional(),
|
|
28666
|
+
level: exports_external.array(exports_external.string()).optional().describe("Filter by levels"),
|
|
28667
|
+
service: exports_external.string().optional(),
|
|
28668
|
+
limit: exports_external.number().optional().default(1e5)
|
|
28669
|
+
}, (args) => {
|
|
28670
|
+
const chunks = [];
|
|
28671
|
+
const write = (s) => {
|
|
28672
|
+
chunks.push(s);
|
|
28673
|
+
return true;
|
|
28674
|
+
};
|
|
28675
|
+
const options = {
|
|
28676
|
+
project_id: rp(args.project_id),
|
|
28677
|
+
level: args.level,
|
|
28678
|
+
service: args.service,
|
|
28679
|
+
since: args.since,
|
|
28680
|
+
until: args.until,
|
|
28681
|
+
limit: args.limit ?? 1e5
|
|
28682
|
+
};
|
|
28683
|
+
if (args.format === "csv")
|
|
28684
|
+
exportToCsv(db, options, write);
|
|
28685
|
+
else
|
|
28686
|
+
exportToJson(db, options, write);
|
|
28687
|
+
return { content: [{ type: "text", text: chunks.join("") }] };
|
|
28688
|
+
});
|
|
28657
28689
|
server.tool("log_diagnose", {
|
|
28658
28690
|
project_id: exports_external.string(),
|
|
28659
28691
|
since: exports_external.string().optional(),
|
package/package.json
CHANGED
package/src/mcp/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { getLatestSnapshot, getPerfTrend, scoreLabel } from "../lib/perf.ts"
|
|
|
13
13
|
import { createAlertRule, deleteAlertRule, listAlertRules } from "../lib/alerts.ts"
|
|
14
14
|
import { listIssues, updateIssueStatus } from "../lib/issues.ts"
|
|
15
15
|
import { diagnose } from "../lib/diagnose.ts"
|
|
16
|
+
import { exportToJson, exportToCsv } from "../lib/export.ts"
|
|
16
17
|
import { compare } from "../lib/compare.ts"
|
|
17
18
|
import { getHealth } from "../lib/health.ts"
|
|
18
19
|
import { getSessionContext } from "../lib/session-context.ts"
|
|
@@ -189,6 +190,30 @@ server.tool("log_context_from_id", {
|
|
|
189
190
|
content: [{ type: "text", text: JSON.stringify(applyBrief(getLogContextFromId(db, log_id), brief !== false)) }]
|
|
190
191
|
}))
|
|
191
192
|
|
|
193
|
+
server.tool("log_export", {
|
|
194
|
+
project_id: z.string().optional().describe("Project name or ID"),
|
|
195
|
+
format: z.enum(["json", "csv"]).optional().default("json").describe("Output format"),
|
|
196
|
+
since: z.string().optional().describe("Since time (1h, 24h, 7d, ISO)"),
|
|
197
|
+
until: z.string().optional(),
|
|
198
|
+
level: z.array(z.string()).optional().describe("Filter by levels"),
|
|
199
|
+
service: z.string().optional(),
|
|
200
|
+
limit: z.number().optional().default(100000),
|
|
201
|
+
}, (args) => {
|
|
202
|
+
const chunks: string[] = []
|
|
203
|
+
const write = (s: string) => { chunks.push(s); return true }
|
|
204
|
+
const options = {
|
|
205
|
+
project_id: rp(args.project_id),
|
|
206
|
+
level: args.level as never,
|
|
207
|
+
service: args.service,
|
|
208
|
+
since: args.since,
|
|
209
|
+
until: args.until,
|
|
210
|
+
limit: args.limit ?? 100000,
|
|
211
|
+
}
|
|
212
|
+
if (args.format === "csv") exportToCsv(db, options, write)
|
|
213
|
+
else exportToJson(db, options, write)
|
|
214
|
+
return { content: [{ type: "text" as const, text: chunks.join("") }] }
|
|
215
|
+
})
|
|
216
|
+
|
|
192
217
|
server.tool("log_diagnose", {
|
|
193
218
|
project_id: z.string(),
|
|
194
219
|
since: z.string().optional(),
|