Created
October 15, 2025 10:21
-
-
Save kuc-arc-f/6fcd400610b5beee100b2daef7a873c4 to your computer and use it in GitHub Desktop.
node, remote MCP Server, test-code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const start = async function() { | |
try{ | |
const item = { | |
"jsonrpc": "2.0", | |
"method": "tools/list", | |
"id": 1 | |
} | |
const response = await fetch("http://localhost:3000/mcp", { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
'Authorization': 'abcdef-123456', | |
}, | |
body: JSON.stringify(item), | |
}); | |
if (!response.ok) { | |
const text = await response.text(); | |
console.log(text); | |
throw new Error('Failed to create item'); | |
}else{ | |
console.log("OK"); | |
const json = await response.json(); | |
console.log(json); | |
console.log(json.result); | |
} | |
}catch(e){console.log(e)} | |
} | |
start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const start = async function() { | |
try{ | |
const item = { | |
"jsonrpc": "2.0", | |
"method": "tools/call", | |
"params": { | |
"name": "purchase_add", | |
"arguments": {"name": "water", "price": 140} | |
}, | |
"id": 2 | |
} | |
const response = await fetch("http://localhost:3000/mcp", { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
'Authorization': 'abcdef-123456', | |
}, | |
body: JSON.stringify(item), | |
}); | |
if (!response.ok) { | |
const text = await response.text(); | |
console.log(text); | |
throw new Error('Failed to create item'); | |
}else{ | |
console.log("OK"); | |
const json = await response.json(); | |
console.log(json); | |
console.log(json.result.content[0].text); | |
} | |
}catch(e){console.log(e)} | |
} | |
start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const start = async function() { | |
try{ | |
const item = { | |
"jsonrpc": "2.0", | |
"method": "tools/call", | |
"params": { | |
"name": "purchase_list", | |
"arguments": null | |
}, | |
"id": 2 | |
} | |
const response = await fetch("http://localhost:3000/mcp", { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
'Authorization': 'abcdef-123456', | |
}, | |
body: JSON.stringify(item), | |
}); | |
if (!response.ok) { | |
const text = await response.text(); | |
console.log(text); | |
throw new Error('Failed to create item'); | |
}else{ | |
console.log("OK"); | |
const json = await response.json(); | |
console.log(json); | |
console.log(json.result.content[0].text); | |
} | |
}catch(e){console.log(e)} | |
} | |
start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment