@agimon-ai/log-sink-mcp 0.24.3 → 0.25.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 +109 -16
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -7,8 +7,9 @@ AI-powered log analysis MCP server with HTTP ingestion and SQLite storage.
|
|
|
7
7
|
`log-sink-mcp` provides a complete log analysis solution for AI assistants like Claude. It combines:
|
|
8
8
|
|
|
9
9
|
- **HTTP Server**: REST endpoint for log ingestion from any application
|
|
10
|
-
- **MCP Server**:
|
|
10
|
+
- **MCP Server**: 5 application-focused tools for searching/filtering, tracing, and inspecting logs
|
|
11
11
|
- **CLI Analysis Commands**: Local shell commands for deeper error and agent-issue analysis
|
|
12
|
+
- **Pi Extension**: Ships a Pi extension that exports the agent's own session telemetry into the sink
|
|
12
13
|
- **SQLite Database**: Fast local storage with FTS5 full-text search plus cached local embeddings
|
|
13
14
|
- **Real-time Analysis**: Query logs, trace distributed requests, analyze error patterns
|
|
14
15
|
|
|
@@ -17,7 +18,8 @@ Perfect for debugging, monitoring, and understanding application behavior throug
|
|
|
17
18
|
## Features
|
|
18
19
|
|
|
19
20
|
- ✅ **HTTP Log Ingestion**: POST logs from any application via REST API
|
|
20
|
-
- ✅ **
|
|
21
|
+
- ✅ **5 MCP Tools**: Search/filter, trace, agent-issue analysis, and inspect stats/services
|
|
22
|
+
- ✅ **Agent Telemetry**: Pi extension records prompts, turns, tool calls, token usage, and cost
|
|
21
23
|
- ✅ **Hybrid Search**: FTS5-powered search plus optional local semantic retrieval across messages and errors
|
|
22
24
|
- ✅ **Distributed Tracing**: Timeline view for trace IDs and span relationships
|
|
23
25
|
- ✅ **Error Analysis**: Pattern detection and error categorization
|
|
@@ -43,7 +45,7 @@ Perfect for debugging, monitoring, and understanding application behavior throug
|
|
|
43
45
|
▼
|
|
44
46
|
┌──────────────┐ MCP Protocol ┌─────────────────┐
|
|
45
47
|
│ Claude / │ <─────────────────────> │ MCP Server │
|
|
46
|
-
│ AI Agent │
|
|
48
|
+
│ AI Agent │ 5 App Log Tools │ (stdio) │
|
|
47
49
|
└──────────────┘ └────────┬────────┘
|
|
48
50
|
│
|
|
49
51
|
▼
|
|
@@ -319,10 +321,13 @@ Search and filter log entries. Without `query`/`searchQuery`, it behaves as a st
|
|
|
319
321
|
- `traceId?`: string - Filter by trace ID
|
|
320
322
|
- `spanId?`: string - Filter by span ID
|
|
321
323
|
- `errorType?`: string - Filter by error type
|
|
322
|
-
- `sessionId?`: string - Filter by agent session ID
|
|
323
|
-
- `
|
|
324
|
-
- `
|
|
325
|
-
- `
|
|
324
|
+
- `sessionId?` / `parentSessionId?`: string - Filter by agent session ID or its parent
|
|
325
|
+
- `agentName?`: string - Filter by agent name
|
|
326
|
+
- `workflowRunId?` / `workflowRunKey?` / `workflowId?`: string - Filter by workflow run ID, stable run key, or workflow file ID
|
|
327
|
+
- `workflowName?` / `workflowWorkspace?`: string - Filter by workflow name or workspace
|
|
328
|
+
- `jobName?` / `jobId?`: string - Filter by workflow job name or job execution ID
|
|
329
|
+
- `stepName?` / `phase?`: string - Filter by workflow step name or phase
|
|
330
|
+
- `signalType?`: string - `log` or `span`
|
|
326
331
|
- `startTime?`: string - ISO 8601 start time filter
|
|
327
332
|
- `endTime?`: string - ISO 8601 end time filter
|
|
328
333
|
- `limit?`: number - Maximum results (default: 100)
|
|
@@ -336,7 +341,30 @@ Find error logs from user-service that mention "database timeout"
|
|
|
336
341
|
|
|
337
342
|
---
|
|
338
343
|
|
|
339
|
-
### 2. `
|
|
344
|
+
### 2. `analyze_agent_issues`
|
|
345
|
+
|
|
346
|
+
Detect and aggregate agent-run problems for reviewing agent performance and improving the harness: failed tool calls, API errors, refusals, retries exhausted, rejected tools, and error logs. Unlike error-severity analysis, this understands agent event semantics, so it also catches warning-level returned tool errors and info-level tool results carrying `success=false`.
|
|
347
|
+
|
|
348
|
+
**Parameters:**
|
|
349
|
+
- `sessionId?` / `parentSessionId?`: string - Scope to one agent launch
|
|
350
|
+
- `agentName?`: string - Scope to one agent identity
|
|
351
|
+
- `service?`: string or string[] - Scope by agent/service name (for example `claude-code`, `codex`)
|
|
352
|
+
- `workflowRunId?` / `workflowRunKey?` / `workflowName?` / `workflowWorkspace?`: string - Scope by workflow
|
|
353
|
+
- `jobName?` / `jobId?` / `stepName?` / `phase?`: string - Scope within a run
|
|
354
|
+
- `startTime?` / `endTime?`: string - ISO 8601 analysis window
|
|
355
|
+
- `limit?`: number - Maximum issue samples returned (default: 100)
|
|
356
|
+
- `scanLimit?`: number - Maximum matching records scanned (default: 50000); the response reports when this truncates the window
|
|
357
|
+
|
|
358
|
+
**Example:**
|
|
359
|
+
```
|
|
360
|
+
Why did the last agent session keep failing its edits?
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
**Returns:** Counts by category, tool, and error type, plus sample issues carrying the tool, input, and error context needed to diagnose them.
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
### 3. `get_trace_timeline`
|
|
340
368
|
|
|
341
369
|
Get chronological timeline for a distributed trace.
|
|
342
370
|
|
|
@@ -352,22 +380,25 @@ Show me the trace timeline for trace ID a1b2c3d4e5f6789012345678901234ab
|
|
|
352
380
|
|
|
353
381
|
---
|
|
354
382
|
|
|
355
|
-
###
|
|
383
|
+
### 4. `get_log_stats`
|
|
356
384
|
|
|
357
|
-
Get statistics grouped
|
|
385
|
+
Get aggregate statistics, grouped along whichever dimension you ask for.
|
|
358
386
|
|
|
359
|
-
**Parameters:**
|
|
387
|
+
**Parameters:**
|
|
388
|
+
- `groupBy?`: string - `both` (default), `level`, `service`, `agent`, `workflow`, `job`, or `signal`
|
|
389
|
+
- `signalType?`: string - `log` (default), `span`, or `all`
|
|
390
|
+
- `startTime?` / `endTime?`: string - ISO 8601 window
|
|
360
391
|
|
|
361
392
|
**Example:**
|
|
362
393
|
```
|
|
363
394
|
Show me log statistics
|
|
364
395
|
```
|
|
365
396
|
|
|
366
|
-
**Returns:**
|
|
397
|
+
**Returns:** Counts per group, plus a total.
|
|
367
398
|
|
|
368
399
|
---
|
|
369
400
|
|
|
370
|
-
###
|
|
401
|
+
### 5. `get_services`
|
|
371
402
|
|
|
372
403
|
List all unique services that have logged.
|
|
373
404
|
|
|
@@ -380,6 +411,44 @@ What services are logging to the database?
|
|
|
380
411
|
|
|
381
412
|
**Returns:** Array of service names with log counts.
|
|
382
413
|
|
|
414
|
+
## Pi extension
|
|
415
|
+
|
|
416
|
+
The package ships a [Pi](https://github.com/earendil-works/pi) extension, declared in the `pi.extensions` field of `package.json` and loaded when the package is installed as a Pi package. It registers no commands and no tools. It subscribes to Pi's session events and exports them as OTLP logs under the service name `pi`, so the agent's own behaviour lands in the same database as your application's.
|
|
417
|
+
|
|
418
|
+
| Pi event | Record | Level |
|
|
419
|
+
|---|---|---|
|
|
420
|
+
| `session_start` | `pi.session.started` | info |
|
|
421
|
+
| `before_agent_start` | `pi.user_prompt` | info |
|
|
422
|
+
| `agent_start` | `pi.agent.started` | info |
|
|
423
|
+
| `turn_start` | `pi.turn.started` | debug |
|
|
424
|
+
| `turn_end` | `pi.turn.finished` | info |
|
|
425
|
+
| `tool_execution_start` | `pi.tool_call` | debug |
|
|
426
|
+
| `tool_execution_end` | `pi.tool_result` | info |
|
|
427
|
+
| `after_provider_response` | `pi.api_response`, or `pi.api_error` on status 400 and above | debug / error |
|
|
428
|
+
| `model_select` | `pi.model.selected` | info |
|
|
429
|
+
| `agent_end` | `pi.agent.finished` | info |
|
|
430
|
+
| `agent_settled` | `pi.agent.settled` | debug |
|
|
431
|
+
| `session_shutdown` | `pi.session.finished` | info |
|
|
432
|
+
|
|
433
|
+
Every record carries the session ID, cwd, mode, thinking level, and selected model. `pi.turn.finished` adds the standard `gen_ai.usage.*` attributes: input, output, cache read, cache write, reasoning, total tokens, and cost. `pi.tool_result` adds the tool name and its duration in milliseconds.
|
|
434
|
+
|
|
435
|
+
Two things are deliberate about what it does not do:
|
|
436
|
+
|
|
437
|
+
- **Prompts and tool payloads are omitted by default.** Set `AGENT_OTEL_REDACT=0` to include `user.prompt`, `tool.input`, and `tool.result`.
|
|
438
|
+
- **Telemetry is dropped rather than written to disk when no sink is reachable.** Endpoint discovery health-checks a running server; if there is none, the file backend is shut down instead of quietly filling a log directory. Set `LOG_SINK_PI_FILE_FALLBACK=1` to keep it.
|
|
439
|
+
|
|
440
|
+
Failures in the extension itself warn to the console and never propagate: telemetry that breaks the agent it is measuring is worse than no telemetry.
|
|
441
|
+
|
|
442
|
+
Once a session has run, query it like any other service:
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
# What went wrong in this agent session
|
|
446
|
+
log-sink-mcp logs agent-issues --session-id <session-id>
|
|
447
|
+
|
|
448
|
+
# Token spend and per-tool consumption for the session
|
|
449
|
+
log-sink-mcp logs metrics --service pi --group-by agent
|
|
450
|
+
```
|
|
451
|
+
|
|
383
452
|
## Integration Examples
|
|
384
453
|
|
|
385
454
|
### Pino Logger
|
|
@@ -548,7 +617,7 @@ bun run src/cli.ts mcp-serve --type sse --port 3002
|
|
|
548
617
|
|
|
549
618
|
#### `logs` command
|
|
550
619
|
|
|
551
|
-
Run log analysis capabilities directly from the shell.
|
|
620
|
+
Run log analysis capabilities directly from the shell. Most subcommands mirror an MCP tool; `analyze-errors` and `clear` are CLI-only.
|
|
552
621
|
|
|
553
622
|
```bash
|
|
554
623
|
bun run src/cli.ts logs <subcommand> [options]
|
|
@@ -560,6 +629,7 @@ Subcommands:
|
|
|
560
629
|
- `search --mode hybrid`: Default hybrid search across FTS5 and semantic embeddings
|
|
561
630
|
- `trace`: Equivalent to `get_trace_timeline`
|
|
562
631
|
- `analyze-errors`: CLI-only grouped error analysis
|
|
632
|
+
- `agent-issues`: Equivalent to `analyze_agent_issues`
|
|
563
633
|
- `stats`: Equivalent to `get_log_stats`
|
|
564
634
|
- `metrics`: Workflow, token, failure, and per-tool consumption metrics
|
|
565
635
|
- `services`: Equivalent to `get_services`
|
|
@@ -603,7 +673,22 @@ bun run src/cli.ts logs services
|
|
|
603
673
|
|
|
604
674
|
### Environment Variables
|
|
605
675
|
|
|
606
|
-
None required
|
|
676
|
+
None are required: the server and its CLI are configured entirely through flags. These apply to the telemetry side, meaning the Pi extension and any process using `@agimon-ai/log-sink-mcp/telemetry/node`.
|
|
677
|
+
|
|
678
|
+
| Variable | Effect |
|
|
679
|
+
|---|---|
|
|
680
|
+
| `LOG_SINK_ENDPOINT` | Send to this log-sink instead of discovering a running one |
|
|
681
|
+
| `OTEL_EXPORTER_OTLP_ENDPOINT` | Standard OTLP endpoint; the signal-specific `_LOGS_` and `_TRACES_` forms take precedence, and any of them override discovery |
|
|
682
|
+
| `OTEL_EXPORTER_OTLP_HEADERS` | Extra export headers; `_LOGS_` and `_TRACES_` variants apply per signal |
|
|
683
|
+
| `OTEL_EXPORTER_OTLP_TIMEOUT` | Export timeout in milliseconds; `_LOGS_` and `_TRACES_` variants apply per signal |
|
|
684
|
+
| `OTEL_SDK_DISABLED` | Disable telemetry entirely |
|
|
685
|
+
| `AGENT_TELEMETRY_DISABLED=1` | Disable the Pi extension only |
|
|
686
|
+
| `AGENT_OTEL_TRACES` | `1`, `true`, or `yes` to export spans as well as logs |
|
|
687
|
+
| `AGENT_OTEL_REDACT=0` | Include prompts, tool inputs, and tool results |
|
|
688
|
+
| `LOG_SINK_PI_FILE_FALLBACK=1` | Let the Pi extension write to files when no sink is reachable |
|
|
689
|
+
| `LOG_SINK_FILE_MAX_BYTES`, `LOG_SINK_FILE_MAX_FILES` | Rotation limits for the file backend |
|
|
690
|
+
|
|
691
|
+
Telemetry is tagged for later filtering from the environment it runs in. `AGENT_SESSION_ID` and `PARENT_AGENT_SESSION_ID` scope records to an agent launch, and `WORKFLOW_RUN_ID`, `WORKFLOW_RUN_KEY`, `WORKFLOW_ID`, `WORKFLOW_NAME`, `WORKFLOW_WORKSPACE`, `WORKFLOW_JOB_ID`, `WORKFLOW_JOB_NAME`, `WORKFLOW_STEP_NAME`, `WORKFLOW_PHASE`, and `WORKFLOW_RUNNER` scope them to a workflow run. Each becomes an ingest header and then a queryable field, which is what makes `--workflow-run-id` and `--session-id` work across the CLI and MCP tools.
|
|
607
692
|
|
|
608
693
|
## Development
|
|
609
694
|
|
|
@@ -628,8 +713,15 @@ log-sink-mcp/
|
|
|
628
713
|
│ ├── cli.ts # CLI entry point
|
|
629
714
|
│ ├── commands/ # CLI commands
|
|
630
715
|
│ │ ├── http-serve.ts # HTTP server command
|
|
631
|
-
│ │
|
|
716
|
+
│ │ ├── mcp-serve.ts # MCP server command
|
|
717
|
+
│ │ ├── logs.ts # Log analysis subcommands
|
|
718
|
+
│ │ └── claude-hook.ts # Claude Code hook context command
|
|
632
719
|
│ ├── container/ # InversifyJS DI container
|
|
720
|
+
│ ├── extensions/ # Pi extension
|
|
721
|
+
│ │ ├── pi.ts # Extension entry point
|
|
722
|
+
│ │ └── piTelemetry.ts # Pi session event to OTLP mapping
|
|
723
|
+
│ ├── telemetry/
|
|
724
|
+
│ │ └── node.ts # Node OTLP setup, endpoint discovery, file fallback
|
|
633
725
|
│ ├── models/ # Drizzle schemas
|
|
634
726
|
│ │ └── schema.ts # Log table schema
|
|
635
727
|
│ ├── server/
|
|
@@ -645,6 +737,7 @@ log-sink-mcp/
|
|
|
645
737
|
│ │ ├── QueryLogsTool.ts # Compatibility wrapper for filter-only queries
|
|
646
738
|
│ │ ├── GetTraceTimelineTool.ts
|
|
647
739
|
│ │ ├── AnalyzeErrorsTool.ts
|
|
740
|
+
│ │ ├── AnalyzeAgentIssuesTool.ts
|
|
648
741
|
│ │ ├── GetLogStatsTool.ts
|
|
649
742
|
│ │ ├── GetServicesTool.ts
|
|
650
743
|
│ │ └── ClearLogsTool.ts
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/log-sink-mcp",
|
|
3
3
|
"description": "Log sink MCP server with HTTP ingestion and AI analysis",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.25.0",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mcp",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"sqlite-vec": "0.1.9",
|
|
44
44
|
"ulidx": "2.4.1",
|
|
45
45
|
"yaml": "2.8.3",
|
|
46
|
-
"@agimon-ai/foundation-
|
|
47
|
-
"@agimon-ai/foundation-
|
|
48
|
-
"@agimon-ai/foundation-
|
|
46
|
+
"@agimon-ai/foundation-validator": "0.22.0",
|
|
47
|
+
"@agimon-ai/foundation-process-registry": "0.25.0",
|
|
48
|
+
"@agimon-ai/foundation-port-registry": "0.25.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@earendil-works/pi-coding-agent": "*",
|