diff --git a/integrations/librechat-unraid/mcp/README.md b/integrations/librechat-unraid/mcp/README.md index 9eaf829..124ab7d 100644 --- a/integrations/librechat-unraid/mcp/README.md +++ b/integrations/librechat-unraid/mcp/README.md @@ -79,3 +79,26 @@ echten Werte. Neue LibreChat-Deployments müssen die Basis wie übergeordnet beschrieben eingerichtet haben. Frischer vollständiger Restore nicht getestet. Quellen: [MCP-Server-Konfiguration](https://www.librechat.ai/docs/configuration/librechat_yaml/object_structure/mcp_servers). + +## Echte Schlüssel übertragen (12.10.2026, nach Nutzerfreigabe) + +Die sieben bestehenden Bearer-Keys anschließend direkt auf Unraid aus der +OpenWebUI-Konfiguration in die geschützten LibreChat-XML-/Env-Felder übertragen. +Kein Schlüsselwert in Toolausgaben, lokalen Testdateien, Modellkontext oder Git. +`transfer-keys.php` verarbeitet Werte ausschließlich intern; berichtet nur IDs, +Anzahl und geschützten Backup-Pfad. Erfolgreiche Übertragung: 7/7. +Schreibsicherung vor Transfer: librechat/install-backups/mcp-keys-20261012-172749. +Container mit erhaltenen bisherigen Env/Volumes kurz neu angelegt. + +Authentifizierte initialize/listTools-Prüfung aus LibreChat bestätigt: +HomeServer 40, navidrome 39, HomeAssistant 32, unifi 106, +casadeprompt 4, syncthing-blade 38 Werkzeuge. Keine Geräteaktionen ausgeführt. +SpliceKit-Verbindung scheitert vor erfolgreicher MCP-Anmeldung (TypeError); +TCP-Verbindung zu 192.168.1.179:9877 liefert ECONNREFUSED: der +Dienst/Port ist nicht erreichbar, unabhängig vom Key. Schlüsselübertragung nicht mit einer +funktionierenden Verbindung gleichsetzen. Der alte Bahn-MCP bleibt ebenfalls +nicht erreichbar. Somit 17 von 19 Servern in bisherigen Verbindungstests +bestätigt; 2 nicht als funktionsfähig ausgeben. +Geschützte Server bleiben on-demand (startup false); in LibreChat auswählen, +bei Bedarf im MCP-Bereich verbinden. Vorherige Fake-Key-Tabelle ist historisch; +die Felder enthalten nun echte Werte und müssen verschlüsselt gesichert werden. diff --git a/integrations/librechat-unraid/mcp/check-keys.js b/integrations/librechat-unraid/mcp/check-keys.js new file mode 100644 index 0000000..9ffdde0 --- /dev/null +++ b/integrations/librechat-unraid/mcp/check-keys.js @@ -0,0 +1,2 @@ +const fs=require('fs'); +(async()=>{const {Client}=await import('@modelcontextprotocol/sdk/client/index.js');const {StreamableHTTPClientTransport}=await import('@modelcontextprotocol/sdk/client/streamableHttp.js');const rows=JSON.parse(fs.readFileSync('/tmp/librechat-mcp-servers.json','utf8'));const results=await Promise.all(rows.filter(s=>s.auth==='bearer').map(async s=>{const client=new Client({name:'librechat-auth-check',version:'1.0.0'});try{const env='MCP_KEY_'+s.id.replace(/[^a-zA-Z0-9]/g,'_').toUpperCase();const key=process.env[env];if(!key||key.startsWith('FAKE_KEY_'))return {id:s.id,connected:false,error:'key-not-transferred'};await client.connect(new StreamableHTTPClientTransport(new URL(s.url),{requestInit:{headers:{Authorization:'Bearer '+key}}}),{timeout:10000});let count=0,cursor;do{const r=await client.listTools(cursor?{cursor}:undefined,{timeout:10000});count+=r.tools.length;cursor=r.nextCursor;}while(cursor);return {id:s.id,connected:true,tools:count};}catch(e){return {id:s.id,connected:false,error:e.name,code:typeof e.code==='number'?e.code:undefined}}finally{await client.close().catch(()=>{});}}));console.log(JSON.stringify(results));process.exit(0)})().catch(()=>{console.log('Verification failed; details suppressed');process.exit(1)}); diff --git a/integrations/librechat-unraid/mcp/transfer-keys.php b/integrations/librechat-unraid/mcp/transfer-keys.php new file mode 100644 index 0000000..860561a --- /dev/null +++ b/integrations/librechat-unraid/mcp/transfer-keys.php @@ -0,0 +1,9 @@ +['pipe','w'],2=>['pipe','w']],$ps);$o=stream_get_contents($ps[1]);$e=stream_get_contents($ps[2]);foreach($ps as$s)fclose($s);$c=proc_close($p);if($c)throw new Exception('Operation failed; output suppressed');return $o;} +$root='/mnt/nvme-storage/appdata/librechat';$path='/boot/config/plugins/dockerMan/templates-user/my-LibreChat.xml';$x=simplexml_load_file($path); +$raw=run(['docker','exec','Open-WebUI','python','-c',"import sqlite3;c=sqlite3.connect('file:/app/backend/data/webui.db?mode=ro',uri=True);print(c.execute('select value from config where key=?',('tool_server.connections',)).fetchone()[0])"]);$rows=json_decode($raw,true);$updated=[]; +$back=$root.'/install-backups/mcp-keys-'.gmdate('Ymd-His');mkdir($back,0700,true);copy($path,$back.'/my-LibreChat.xml');chmod($back.'/my-LibreChat.xml',0600); +foreach($rows as$s){if(($s['type']??'')!=='mcp'||($s['auth_type']??'')!=='bearer')continue;$id=$s['info']['id'];$key=$s['key']??'';$var='MCP_KEY_'.strtoupper(preg_replace('/[^a-zA-Z0-9]/','_',$id));$found=false;foreach($x->Config as$c)if((string)$c['Type']==='Variable'&&(string)$c['Target']===$var){if(!$key)throw new Exception('Source key missing for '.$id);$c[0]=$key;$found=true;}if(!$found)throw new Exception('Target missing for '.$id);$updated[]=$id;} +if(count($updated)!==7)throw new Exception('Unexpected key count');$x->asXML($path);chmod($path,0600); +$a=['docker','create','--name','LibreChat','--network','bridge','--restart','unless-stopped','--pids-limit','2048','-l','net.unraid.docker.managed=dockerman'];foreach(['WebUI'=>'net.unraid.docker.webui','Icon'=>'net.unraid.docker.icon']as$k=>$v)if((string)$x->$k!='')array_push($a,'-l',$v.'='.(string)$x->$k);foreach($x->Config as$c){$v=(string)$c;$target=(string)$c['Target'];$type=(string)$c['Type'];if($type==='Variable')array_push($a,'-e',$target.'='.$v);elseif($type==='Port')array_push($a,'-p',$v.':'.$target.'/'.(string)$c['Mode']);elseif($type==='Path')array_push($a,'-v',$v.':'.$target.':'.(string)$c['Mode']);else throw new Exception('Unknown config type');}$a[]=(string)$x->Repository; +run(['docker','stop','--time','30','LibreChat']);run(['docker','rm','LibreChat']);run($a);run(['docker','start','LibreChat']);echo json_encode(['transferred'=>count($updated),'servers'=>$updated,'backup'=>$back,'key_values_printed'=>false])."\n";