Add tools call handling and translate docs

Pass the serializer and request id to ResolveToolsCall and implement a basic dispatcher that extracts params.method. Add a handler stub for "run_jsrt_script" (extracts the script argument; implementation TODO) and log unknown tool methods. Also update McpToolsList.json scriptContract notes from Korean to English to improve readability/localization.
This commit is contained in:
Namhyeon, Go 2026-03-16 21:37:16 +09:00
parent 3eea89f5a3
commit f1456e304c
2 changed files with 20 additions and 5 deletions

View File

@ -83,7 +83,7 @@ namespace WelsonJS.Launcher.ApiEndpoints
break; break;
case "tools/call": case "tools/call":
await ResolveToolsCall(ser.ExtractFrom(id, "params", "name")); await ResolveToolsCall(ser, id);
break; break;
} }
@ -93,9 +93,24 @@ namespace WelsonJS.Launcher.ApiEndpoints
} }
} }
private async Task ResolveToolsCall(string toolsName) private async Task ResolveToolsCall(JsSerializer ser, int id)
{ {
// TODO: ex) get_weather var toolsName = ser.ExtractFrom(id, "params", "method")?.Trim();
switch (toolsName)
{
case "run_jsrt_script":
{
var script = ser.ExtractFrom(id, "params", "arguments", "script")?.Trim();
// todo
}
break;
default:
_logger.Warn($"[JsonRpc2] Unknown tools method: {toolsName}");
break;
}
} }
} }
} }

View File

@ -10,8 +10,8 @@
"scriptContract": { "scriptContract": {
"requiredEntryPoint": "function main(args) { /* ... */ }; exports.main = main;", "requiredEntryPoint": "function main(args) { /* ... */ }; exports.main = main;",
"notes": [ "notes": [
"모든 실행 스크립트 결과물은 main 함수를 export해야 합니다.", "All executable script outputs must export a main function.",
"ES3 문법을 기본으로 작성하고, 필요한 경우 ES5 polyfill 범위 내에서만 확장하세요." "Write using ES3 syntax by default, and extend only within the ES5 polyfill scope if necessary."
] ]
}, },
"tools": [ "tools": [