@takch02/server-doctor 1.0.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/index.js +62 -0
- package/package.json +20 -0
package/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// index.js
|
|
4
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
5
|
+
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
6
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
import EventSource from "eventsource";
|
|
9
|
+
|
|
10
|
+
// ⭐ AWS 서버 주소 (포트 80이니까 포트 생략 OK)
|
|
11
|
+
// 만약 로컬 테스트 중이면 http://127.0.0.1:8080/mcp/sse
|
|
12
|
+
const SERVER_URL = "http://ec2-52-79-247-25.ap-northeast-2.compute.amazonaws.com/mcp/sse";
|
|
13
|
+
|
|
14
|
+
// SSE 전역 설정 (Node.js 환경용)
|
|
15
|
+
global.EventSource = EventSource;
|
|
16
|
+
|
|
17
|
+
async function main() {
|
|
18
|
+
// 1. AWS 서버와 연결 (Client 역할)
|
|
19
|
+
const transport = new SSEClientTransport(new URL(SERVER_URL));
|
|
20
|
+
const client = new Client(
|
|
21
|
+
{ name: "bridge-client", version: "1.0.0" },
|
|
22
|
+
{ capabilities: {} }
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
// 연결 시도
|
|
26
|
+
try {
|
|
27
|
+
await client.connect(transport);
|
|
28
|
+
} catch (err) {
|
|
29
|
+
console.error("AWS 서버 연결 실패:", err);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 2. Claude Desktop과 연결할 서버 생성 (Server 역할)
|
|
34
|
+
const server = new McpServer({
|
|
35
|
+
name: "ServerDoctor-Bridge",
|
|
36
|
+
version: "1.0.0",
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// 3. AWS 서버에 있는 도구(Tool)들을 가져와서 등록
|
|
40
|
+
const tools = await client.listTools();
|
|
41
|
+
|
|
42
|
+
for (const tool of tools.tools) {
|
|
43
|
+
// AWS 서버의 도구를 그대로 중계(Forwarding) 등록
|
|
44
|
+
server.tool(tool.name, tool.description, tool.inputSchema, async (args) => {
|
|
45
|
+
// Claude가 호출하면 -> AWS 서버로 전달
|
|
46
|
+
const result = await client.callTool({
|
|
47
|
+
name: tool.name,
|
|
48
|
+
arguments: args,
|
|
49
|
+
});
|
|
50
|
+
return result;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 4. Claude와 Stdio로 통신 시작
|
|
55
|
+
const stdioTransport = new StdioServerTransport();
|
|
56
|
+
await server.connect(stdioTransport);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
main().catch((error) => {
|
|
60
|
+
console.error("Bridge 오류 발생:", error);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@takch02/server-doctor",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"server-doctor": "./index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
18
|
+
"eventsource": "^4.1.0"
|
|
19
|
+
}
|
|
20
|
+
}
|