Repository navigation
Expand file tree
/
Copy pathtest-tools.js
More file actions
executable file
·116 lines (98 loc) · 2.93 KB
/
Copy pathtest-tools.js
File metadata and controls
executable file
·116 lines (98 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env node
/**
* OCI MCP 서버 기능 테스트
* 실제 OCI 도구 호출을 시뮬레이션
*/
import { spawn } from 'child_process';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
console.log('🔧 OCI MCP 도구 기능 테스트\n');
// 서버 실행
const serverPath = join(__dirname, 'dist', 'simple-index.js');
const server = spawn('node', [serverPath], {
stdio: ['pipe', 'pipe', 'pipe'],
env: {
...process.env,
// 테스트용 환경변수
OCI_TENANCY_ID: 'ocid1.tenancy.oc1..test',
OCI_USER_ID: 'ocid1.user.oc1..test',
OCI_KEY_FINGERPRINT: 'aa:bb:cc:dd:ee:ff:gg:hh:ii:jj:kk:ll:mm:nn:oo:pp',
OCI_PRIVATE_KEY_PATH: '/tmp/test-key.pem',
OCI_REGION: 'us-ashburn-1'
}
});
let messageId = 1;
// 서버 출력 모니터링
server.stdout.on('data', (data) => {
try {
const response = JSON.parse(data.toString().trim());
console.log('📤 서버 응답:', JSON.stringify(response, null, 2));
} catch (e) {
console.log('📤 서버 출력:', data.toString().trim());
}
});
server.stderr.on('data', (data) => {
console.log('⚠️ 서버 에러:', data.toString().trim());
});
// MCP 메시지 전송 함수
function sendMessage(method, params = {}) {
const message = {
jsonrpc: "2.0",
id: messageId++,
method: method,
params: params
};
console.log(`\n📨 요청 전송: ${method}`);
console.log(JSON.stringify(message, null, 2));
server.stdin.write(JSON.stringify(message) + '\n');
}
// 테스트 시퀀스
setTimeout(() => {
console.log('🚀 MCP 프로토콜 테스트 시작...\n');
// 1. 초기화
sendMessage("initialize", {
protocolVersion: "2024-11-05",
capabilities: { tools: {} },
clientInfo: { name: "oci-test-client", version: "1.0.0" }
});
setTimeout(() => {
// 2. 도구 목록 요청
sendMessage("tools/list");
setTimeout(() => {
// 3. OCI 도구 호출 (compute 인스턴스 목록)
sendMessage("tools/call", {
name: "oci-manage",
arguments: {
service: "compute",
action: "list",
resourceType: "instances",
compartmentId: "ocid1.compartment.oc1..test"
}
});
setTimeout(() => {
// 4. OCI 도구 호출 (storage 버킷 목록)
sendMessage("tools/call", {
name: "oci-manage",
arguments: {
service: "storage",
action: "list",
resourceType: "buckets",
compartmentId: "ocid1.compartment.oc1..test"
}
});
setTimeout(() => {
console.log('\n✅ 테스트 완료!');
server.kill();
}, 3000);
}, 3000);
}, 3000);
}, 3000);
}, 2000);
// Ctrl+C 처리
process.on('SIGINT', () => {
console.log('\n🛑 테스트 중단됨');
server.kill();
process.exit(0);
});