sweetspot-remote-agent 1.2.0 → 1.3.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 +58 -0
- package/package.json +1 -1
package/mcp-server.js
CHANGED
|
@@ -127,6 +127,62 @@ 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: { "Content-Type": "application/json" },
|
|
173
|
+
body: JSON.stringify({ name: regName, agentUrl }),
|
|
174
|
+
});
|
|
175
|
+
const data = await res.json();
|
|
176
|
+
if (data.ok) {
|
|
177
|
+
console.error(`[register] ✅ 등록 완료! Slack 유저: ${data.name}`);
|
|
178
|
+
} else {
|
|
179
|
+
console.error(`[register] ❌ 등록 실패: ${data.error}`);
|
|
180
|
+
}
|
|
181
|
+
} catch (e) {
|
|
182
|
+
console.error(`[register] ❌ 봇 서버 연결 실패: ${e.message}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
130
186
|
async function main() {
|
|
131
187
|
if (!isStdio) {
|
|
132
188
|
// HTTP 모드: 원격 연결용
|
|
@@ -164,6 +220,8 @@ async function main() {
|
|
|
164
220
|
|
|
165
221
|
app.listen(port, "0.0.0.0", () => {
|
|
166
222
|
console.error(`[remote-agent] MCP 서버 시작 (HTTP 0.0.0.0:${port})`);
|
|
223
|
+
// 서버 시작 후 자동 등록
|
|
224
|
+
autoRegister();
|
|
167
225
|
});
|
|
168
226
|
} else {
|
|
169
227
|
// stdio 모드: 로컬 사용
|