Skip to content

Instantly share code, notes, and snippets.

@kuc-arc-f
Created October 15, 2025 10:21
Show Gist options
  • Save kuc-arc-f/6fcd400610b5beee100b2daef7a873c4 to your computer and use it in GitHub Desktop.
Save kuc-arc-f/6fcd400610b5beee100b2daef7a873c4 to your computer and use it in GitHub Desktop.
node, remote MCP Server, test-code
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();
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();
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