@mandujs/mcp 0.19.3 → 0.19.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mandujs/mcp",
3
- "version": "0.19.3",
3
+ "version": "0.19.4",
4
4
  "description": "Mandu MCP Server - Agent-native interface for Mandu framework operations",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -277,6 +277,8 @@ export class ActivityMonitor {
277
277
  private summaryTimer: NodeJS.Timeout | null = null;
278
278
  private summaryCounts = { total: 0, info: 0, warn: 0, error: 0 };
279
279
  private lastToolArgs = new Map<string, Record<string, unknown> | null>();
280
+ // Phase 5-1: 에이전트 세션 식별 (MCP 클라이언트별 추적)
281
+ public sessionId: string = crypto.randomUUID();
280
282
 
281
283
  constructor(projectRoot: string) {
282
284
  this.projectRoot = projectRoot;
@@ -380,13 +382,13 @@ export class ActivityMonitor {
380
382
  fingerprint: `tool:error:${name}:${argsStr}`,
381
383
  data: { tool: name, tag, args, argsSummary: argsStr, error },
382
384
  });
383
- // Phase 1-3: MCP 도구 에러 → EventBus
385
+ // Phase 1-3: MCP 도구 에러 → EventBus (Phase 5-1: sessionId 포함)
384
386
  eventBus.emit({
385
387
  type: "mcp",
386
388
  severity: "error",
387
389
  source: "mcp",
388
390
  message: `${name} ❌ ${error}`,
389
- data: { tool: name, args, error },
391
+ data: { tool: name, args, error, sessionId: this.sessionId },
390
392
  });
391
393
  return;
392
394
  }
@@ -398,13 +400,13 @@ export class ActivityMonitor {
398
400
  source: "tool",
399
401
  data: { tool: name, tag, args, argsSummary: argsStr },
400
402
  });
401
- // Phase 1-3: MCP 도구 호출 → EventBus
403
+ // Phase 1-3: MCP 도구 호출 → EventBus (Phase 5-1: sessionId 포함)
402
404
  eventBus.emit({
403
405
  type: "mcp",
404
406
  severity: "info",
405
407
  source: "mcp",
406
408
  message: `${name} ✅`,
407
- data: { tool: name, args },
409
+ data: { tool: name, args, sessionId: this.sessionId },
408
410
  });
409
411
  }
410
412
 
@@ -8,6 +8,7 @@ import type { Resource } from "@modelcontextprotocol/sdk/types.js";
8
8
  import path from "path";
9
9
  import { readConfig, readJsonFile } from "./utils/project.js";
10
10
  import { loadManduConfig, loadManifest } from "@mandujs/core";
11
+ import { eventBus } from "@mandujs/core/observability";
11
12
  import { getDevServerState } from "./tools/project.js";
12
13
 
13
14
  export const manduResourceDefinitions: Resource[] = [
@@ -29,6 +30,12 @@ export const manduResourceDefinitions: Resource[] = [
29
30
  description: "Recent build and runtime errors",
30
31
  mimeType: "application/json",
31
32
  },
33
+ {
34
+ uri: "mandu://activity",
35
+ name: "Recent Activity",
36
+ description: "Recent observability events (HTTP, MCP, Guard) from EventBus + 5-minute stats",
37
+ mimeType: "application/json",
38
+ },
32
39
  ];
33
40
 
34
41
  type ResourceReadResult = { uri: string; mimeType: string; text: string };
@@ -81,6 +88,25 @@ export function manduResourceHandlers(projectRoot: string): Record<string, Resou
81
88
  }
82
89
  },
83
90
 
91
+ "mandu://activity": async () => {
92
+ // Phase 5-3: AI 에이전트가 EventBus 활동을 직접 조회 가능
93
+ const recent = eventBus.getRecent(20);
94
+ const stats = eventBus.getStats(5 * 60 * 1000); // last 5 minutes
95
+ return jsonResult("mandu://activity", {
96
+ recent: recent.map((e) => ({
97
+ ts: new Date(e.timestamp).toISOString(),
98
+ type: e.type,
99
+ severity: e.severity,
100
+ source: e.source,
101
+ message: e.message,
102
+ duration: e.duration,
103
+ correlationId: e.correlationId,
104
+ })),
105
+ stats,
106
+ windowMs: 5 * 60 * 1000,
107
+ });
108
+ },
109
+
84
110
  "mandu://errors": async () => {
85
111
  const errors: unknown[] = [];
86
112