@mandujs/mcp 0.19.2 → 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.2",
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",
@@ -8,6 +8,7 @@
8
8
  import fs from "fs";
9
9
  import path from "path";
10
10
  import type { Subprocess } from "bun";
11
+ import { eventBus } from "@mandujs/core/observability";
11
12
 
12
13
  const TOOL_ICONS: Record<string, string> = {
13
14
  // Spec
@@ -276,6 +277,8 @@ export class ActivityMonitor {
276
277
  private summaryTimer: NodeJS.Timeout | null = null;
277
278
  private summaryCounts = { total: 0, info: 0, warn: 0, error: 0 };
278
279
  private lastToolArgs = new Map<string, Record<string, unknown> | null>();
280
+ // Phase 5-1: 에이전트 세션 식별 (MCP 클라이언트별 추적)
281
+ public sessionId: string = crypto.randomUUID();
279
282
 
280
283
  constructor(projectRoot: string) {
281
284
  this.projectRoot = projectRoot;
@@ -379,6 +382,14 @@ export class ActivityMonitor {
379
382
  fingerprint: `tool:error:${name}:${argsStr}`,
380
383
  data: { tool: name, tag, args, argsSummary: argsStr, error },
381
384
  });
385
+ // Phase 1-3: MCP 도구 에러 → EventBus (Phase 5-1: sessionId 포함)
386
+ eventBus.emit({
387
+ type: "mcp",
388
+ severity: "error",
389
+ source: "mcp",
390
+ message: `${name} ❌ ${error}`,
391
+ data: { tool: name, args, error, sessionId: this.sessionId },
392
+ });
382
393
  return;
383
394
  }
384
395
 
@@ -389,6 +400,14 @@ export class ActivityMonitor {
389
400
  source: "tool",
390
401
  data: { tool: name, tag, args, argsSummary: argsStr },
391
402
  });
403
+ // Phase 1-3: MCP 도구 호출 → EventBus (Phase 5-1: sessionId 포함)
404
+ eventBus.emit({
405
+ type: "mcp",
406
+ severity: "info",
407
+ source: "mcp",
408
+ message: `${name} ✅`,
409
+ data: { tool: name, args, sessionId: this.sessionId },
410
+ });
392
411
  }
393
412
 
394
413
  /**
@@ -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