| 45 | // Aufruf serverseitig an den C-Server weiter (dessen Origin-Prüfung |
| 46 | // lässt eine fremde Seite nicht direkt an /rpc). |
| 47 | function callTool(name, args) { |
| 48 | return fetch('/rpc', { |
| 49 | method: 'POST', |
| 50 | headers: { 'Content-Type': 'application/json' }, |
| 51 | body: JSON.stringify({ |
| 52 | jsonrpc: '2.0', |
| 53 | id: 1, |
| 54 | method: 'tools/call', |
| 55 | params: { name: name, arguments: args } |
| 56 | }) |
| 57 | }).then(function (res) { |
| 58 | if (!res.ok) { |
| 59 | throw new Error('/rpc antwortete mit HTTP ' + res.status); |
| 60 | } |
| 61 | return res.json(); |
| 62 | }).then(function (body) { |
| 63 | if (body.error) { |
| 64 | throw new Error('/rpc-Fehler: ' + JSON.stringify(body.error)); |
| 65 | } |
| 66 | var content = body.result && body.result.content; |
| 67 | if (!content || !content.length || typeof content[0].text !== 'string') { |
| 68 | throw new Error('/rpc lieferte kein content[0].text'); |
| 69 | } |
| 70 | return JSON.parse(content[0].text); |
| 71 | }); |
| 72 | } |
| 73 | |
| 74 | // Die Call-Site suchen: die Zeile, die validateUser( aufruft, nicht der |
| 75 | // Import und nicht die Deklaration selbst. |