sweetspot-remote-agent 1.2.0 → 1.4.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/mcp-server.js +61 -0
- package/package.json +1 -1
package/mcp-server.js
CHANGED
|
@@ -127,6 +127,65 @@ const isStdio = args.includes("--stdio");
|
|
|
127
127
|
const portIdx = args.indexOf("--port");
|
|
128
128
|
const port = portIdx !== -1 ? parseInt(args[portIdx + 1], 10) : 8080;
|
|
129
129
|
|
|
130
|
+
import os from "os";
|
|
131
|
+
|
|
132
|
+
const BOT_SERVER = "https://moonless-unexpeditiously-elvina.ngrok-free.dev";
|
|
133
|
+
|
|
134
|
+
// --name "슬랙아이디" 필수
|
|
135
|
+
const nameIdx = args.indexOf("--name");
|
|
136
|
+
const regName = nameIdx !== -1 ? args[nameIdx + 1] : null;
|
|
137
|
+
const noRegister = args.includes("--no-register");
|
|
138
|
+
|
|
139
|
+
if (!isStdio && !noRegister && !regName) {
|
|
140
|
+
console.error("");
|
|
141
|
+
console.error(" ❌ --name 옵션이 필요합니다!");
|
|
142
|
+
console.error("");
|
|
143
|
+
console.error(" 사용법: npx sweetspot-remote-agent --name 본인슬랙아이디");
|
|
144
|
+
console.error("");
|
|
145
|
+
console.error(" 슬랙아이디 확인: Slack 프로필 → 이름 아래 표시되는 영문 ID");
|
|
146
|
+
console.error(" 예시: npx sweetspot-remote-agent --name alexlee");
|
|
147
|
+
console.error("");
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function getLocalIP() {
|
|
152
|
+
const nets = os.networkInterfaces();
|
|
153
|
+
for (const iface of Object.values(nets)) {
|
|
154
|
+
for (const net of iface) {
|
|
155
|
+
if (net.family === "IPv4" && !net.internal) return net.address;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return "127.0.0.1";
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function autoRegister() {
|
|
162
|
+
if (noRegister || isStdio) return;
|
|
163
|
+
|
|
164
|
+
const localIP = getLocalIP();
|
|
165
|
+
const agentUrl = `http://${localIP}:${port}`;
|
|
166
|
+
|
|
167
|
+
console.error(`[register] 봇 서버에 등록 중... (${regName} → ${agentUrl})`);
|
|
168
|
+
|
|
169
|
+
try {
|
|
170
|
+
const res = await fetch(`${BOT_SERVER}/register`, {
|
|
171
|
+
method: "POST",
|
|
172
|
+
headers: {
|
|
173
|
+
"Content-Type": "application/json",
|
|
174
|
+
"ngrok-skip-browser-warning": "true",
|
|
175
|
+
},
|
|
176
|
+
body: JSON.stringify({ name: regName, agentUrl }),
|
|
177
|
+
});
|
|
178
|
+
const data = await res.json();
|
|
179
|
+
if (data.ok) {
|
|
180
|
+
console.error(`[register] ✅ 등록 완료! Slack 유저: ${data.name}`);
|
|
181
|
+
} else {
|
|
182
|
+
console.error(`[register] ❌ 등록 실패: ${data.error}`);
|
|
183
|
+
}
|
|
184
|
+
} catch (e) {
|
|
185
|
+
console.error(`[register] ❌ 봇 서버 연결 실패: ${e.message}`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
130
189
|
async function main() {
|
|
131
190
|
if (!isStdio) {
|
|
132
191
|
// HTTP 모드: 원격 연결용
|
|
@@ -164,6 +223,8 @@ async function main() {
|
|
|
164
223
|
|
|
165
224
|
app.listen(port, "0.0.0.0", () => {
|
|
166
225
|
console.error(`[remote-agent] MCP 서버 시작 (HTTP 0.0.0.0:${port})`);
|
|
226
|
+
// 서버 시작 후 자동 등록
|
|
227
|
+
autoRegister();
|
|
167
228
|
});
|
|
168
229
|
} else {
|
|
169
230
|
// stdio 모드: 로컬 사용
|