const fetch = require('node-fetch');
const MCP_URL = 'https://hrfco-mcp-functions.netlify.app/.netlify/functions/mcp';
async function testMCPServer() {
console.log('๐งช MCP ์๋ฒ ํ
์คํธ ์์...\n');
// 1. Initialize ํ
์คํธ
console.log('1๏ธโฃ Initialize ํ
์คํธ');
try {
const initResponse = await fetch(MCP_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "initialize",
params: {}
})
});
const initResult = await initResponse.json();
console.log('โ
Initialize ์ฑ๊ณต:', JSON.stringify(initResult, null, 2));
} catch (error) {
console.log('โ Initialize ์คํจ:', error.message);
}
console.log('\n' + '='.repeat(50) + '\n');
// 2. Tools List ํ
์คํธ
console.log('2๏ธโฃ Tools List ํ
์คํธ');
try {
const toolsResponse = await fetch(MCP_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: "2.0",
id: 2,
method: "tools/list",
params: {}
})
});
const toolsResult = await toolsResponse.json();
console.log('โ
Tools List ์ฑ๊ณต:');
console.log(`๐ ์ด ${toolsResult.result?.tools?.length || 0}๊ฐ ๋๊ตฌ ๋ฐ๊ฒฌ:`);
toolsResult.result?.tools?.forEach((tool, index) => {
console.log(` ${index + 1}. ${tool.name}: ${tool.description}`);
});
} catch (error) {
console.log('โ Tools List ์คํจ:', error.message);
}
console.log('\n' + '='.repeat(50) + '\n');
// 3. Tools Call ํ
์คํธ - ํ๊ฐ ์์ ๊ฒ์
console.log('3๏ธโฃ Tools Call ํ
์คํธ - ํ๊ฐ ์์ ๊ฒ์');
try {
const callResponse = await fetch(MCP_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: "2.0",
id: 3,
method: "tools/call",
params: {
name: "get_water_info_by_location",
arguments: {
query: "ํ๊ฐ ์์",
limit: 3
}
}
})
});
const callResult = await callResponse.json();
console.log('โ
Tools Call ์ฑ๊ณต:');
console.log(JSON.stringify(callResult, null, 2));
} catch (error) {
console.log('โ Tools Call ์คํจ:', error.message);
}
console.log('\n' + '='.repeat(50) + '\n');
// 4. ์ง์ญ๋ช
๊ฒ์ ํ
์คํธ
console.log('4๏ธโฃ ์ง์ญ๋ช
๊ฒ์ ํ
์คํธ - ์์ธ');
try {
const searchResponse = await fetch(MCP_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: "2.0",
id: 4,
method: "tools/call",
params: {
name: "search_water_station_by_name",
arguments: {
location_name: "์์ธ",
limit: 3
}
}
})
});
const searchResult = await searchResponse.json();
console.log('โ
์ง์ญ๋ช
๊ฒ์ ์ฑ๊ณต:');
console.log(JSON.stringify(searchResult, null, 2));
} catch (error) {
console.log('โ ์ง์ญ๋ช
๊ฒ์ ์คํจ:', error.message);
}
console.log('\n' + '='.repeat(50) + '\n');
// 5. ์ฃผ๋ณ ๊ด์ธก์ ์ถ์ฒ ํ
์คํธ
console.log('5๏ธโฃ ์ฃผ๋ณ ๊ด์ธก์ ์ถ์ฒ ํ
์คํธ');
try {
const recommendResponse = await fetch(MCP_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: "2.0",
id: 5,
method: "tools/call",
params: {
name: "recommend_nearby_stations",
arguments: {
location: "๋ถ์ฐ",
radius: 30
}
}
})
});
const recommendResult = await recommendResponse.json();
console.log('โ
์ฃผ๋ณ ๊ด์ธก์ ์ถ์ฒ ์ฑ๊ณต:');
console.log(JSON.stringify(recommendResult, null, 2));
} catch (error) {
console.log('โ ์ฃผ๋ณ ๊ด์ธก์ ์ถ์ฒ ์คํจ:', error.message);
}
console.log('\n๐ MCP ์๋ฒ ํ
์คํธ ์๋ฃ!');
}
// ํ
์คํธ ์คํ
testMCPServer().catch(console.error);