@nine-lab/nine-mu 0.1.105 → 0.1.107

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": "@nine-lab/nine-mu",
3
- "version": "0.1.105",
3
+ "version": "0.1.107",
4
4
  "description": "AI-Driven Full-Stack Code Fabrication Engine",
5
5
  "type": "module",
6
6
  "main": "./dist/nine-mu.umd.js",
@@ -46,5 +46,8 @@
46
46
  "spring-react"
47
47
  ],
48
48
  "author": "nine-mu",
49
- "license": "MIT"
49
+ "license": "MIT",
50
+ "dependencies": {
51
+ "@modelcontextprotocol/sdk": "^1.29.0"
52
+ }
50
53
  }
@@ -1,5 +1,7 @@
1
1
  import { nine, trace, api } from '@nine-lab/nine-util';
2
2
  import { NineMuService } from '../services/NineMuService.js';
3
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
4
+ import { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/websocket.js";
3
5
 
4
6
  export class NineChat extends HTMLElement {
5
7
  #service = null;
@@ -8,6 +10,7 @@ export class NineChat extends HTMLElement {
8
10
  #packageName;
9
11
  #routesPath;
10
12
  #connectorUrl;
13
+ #mcpClient;
11
14
 
12
15
  constructor() {
13
16
  super();
@@ -26,7 +29,7 @@ export class NineChat extends HTMLElement {
26
29
  this.#render();
27
30
  this.#initInteractions(); // UI 토글 로직
28
31
  this.#initActions(); // 엔터 시 실행 로직
29
-
32
+ this.#initMcp();
30
33
 
31
34
  const res = await api.post("/nine-mu/config/get", {});
32
35
  this.#routesPath = res?.userDir + "/" + this.#packageName + "/public/prompts/data/routes.json";
@@ -34,8 +37,6 @@ export class NineChat extends HTMLElement {
34
37
 
35
38
  // 경로 데이터 로드
36
39
  this.#routes = await this.#service.fetchRoutes(this.getAttribute('route-url'));
37
-
38
-
39
40
  }
40
41
 
41
42
  // --- [그룹 1: Interaction] 화면 토글 및 메뉴 클릭 ---
@@ -96,6 +97,28 @@ export class NineChat extends HTMLElement {
96
97
  });
97
98
  }
98
99
 
100
+ #initMcp = async () => {
101
+ // 중복 연결 방지
102
+ if (this.#mcpClient) return;
103
+
104
+ try {
105
+ // [변경] WebSocket 트랜스포트 설정 (서버 주소와 프로토콜 확인)
106
+ const transport = new WebSocketClientTransport(new URL(this.#connectorUrl));
107
+
108
+ this.#mcpClient = new Client({
109
+ name: "nine-mcp-client",
110
+ version: "1.0.0"
111
+ }, { capabilities: { tools: {} } });
112
+
113
+ trace.log("Connecting to MCP via WebSocket...");
114
+ await this.#mcpClient.connect(transport);
115
+
116
+ trace.log("✅ Nine MCP Connected (WebSocket)");
117
+ } catch (err) {
118
+ trace.error("❌ MCP 초기화 에러:", err);
119
+ }
120
+ };
121
+
99
122
  #render() {
100
123
  const placeholder = this.getAttribute("placeholder") || "나에게 무엇이든 물어봐...";
101
124
  const customImport = this.getAttribute("css-path") ? `@import "${this.getAttribute("css-path")}";` : "";
@@ -163,20 +186,6 @@ export class NineChat extends HTMLElement {
163
186
  //trace.log("분석 완료. 생성할 태스크:", res2?.tasks);
164
187
 
165
188
  if (res2.success && res2?.tasks) {
166
- /**
167
- // 2. 이미 만들어두신 자바 컨트롤러의 saveRoutes 호출
168
- const saveRes = await api.post("/nine-mu/source/generateTmplFile", {
169
- //basePath: "/Users/nandoo/nine-edu/nine-edu-web/nine-edu-be/tmpl",
170
- fileNm: "routes.json",
171
- contents: JSON.stringify(res.tasks, null, 2),
172
- //routes: res.tasks,
173
- //feProjectName: "nine-edu-fe-admin" // 현재 프로젝트명
174
- });
175
-
176
- trace.log(saveRes);
177
- */
178
- //trace.log(res2?.tasks);
179
- //this.#showDiff(jsonRoutes, JSON.stringify(res2?.tasks, null, 2), "json");
180
189
  this.#showDiff(jsonRoutes, res2?.tasks, "json");
181
190
  }
182
191
  }