diff --git a/src/eMCPy/Configuration/configPage.html b/src/eMCPy/Configuration/configPage.html index bb309a8..5dc1774 100644 --- a/src/eMCPy/Configuration/configPage.html +++ b/src/eMCPy/Configuration/configPage.html @@ -12,6 +12,13 @@

eMCPy Configuration

MCP-Server (Model Context Protocol) für AI-Agenten. Läuft eingebettet in Emby auf einem eigenen Port.

+
+ ℹ️ Zugriff über direkte IP (LAN)
+ Der MCP-Endpunkt wird über die direkte Server-IP im LAN erreicht, z. B.
+ http://192.168.1.2:8097/mcp
+ Nicht über den Reverse-Proxy / Domain. AI-Agenten und Clients im LAN nutzen die IP direkt – der Proxy-Port muss dafür nicht gemappt sein. +
+

MCP-Server

diff --git a/src/eMCPy/Configuration/configPage.js b/src/eMCPy/Configuration/configPage.js index 541db29..e74bdac 100644 --- a/src/eMCPy/Configuration/configPage.js +++ b/src/eMCPy/Configuration/configPage.js @@ -11,25 +11,31 @@ define(['baseView', 'loading', 'toast'], function (BaseView, loading, toast) { return ApiClient.updatePluginConfiguration(pluginId, config); } - function buildCandidateUrls(config) { + // Holt die direkte LAN-IP des Emby-Servers (funktioniert auch über Proxy, + // da /System/Info im selben Origin liegt wie das Dashboard). + function getLocalAddress() { + return ApiClient.getSystemInfo().then(info => { + // LocalAddress = primäre LAN-IP (z. B. 192.168.1.2). Fallback: erste aus LocalAddresses[]. + if (info.LocalAddress) return info.LocalAddress; + if (info.LocalAddresses && info.LocalAddresses.length > 0) return info.LocalAddresses[0]; + return null; + }).catch(() => null); + } + + function buildCandidateUrls(config, localIp) { // Kandidaten für den Status-Check, in Prioritätsreihenfolge: // 1. Explizit konfigurierte McpUrl (z. B. hinter Reverse-Proxy) - // 2. Host des Emby-Servers + MCP-Port - // 3. Host der aktuellen Seite + MCP-Port + // 2. Direkte LAN-IP + MCP-Port (empfohlen – funktioniert immer im LAN) + // 3. Host des Emby-Servers + MCP-Port + // 4. Host der aktuellen Seite + MCP-Port var urls = []; - if (config.McpUrl) { - urls.push(config.McpUrl); - } var port = config.McpPort || 8097; - try { - var serverHost = new URL(ApiClient.serverAddress()).hostname; - urls.push('http://' + serverHost + ':' + port + '/mcp'); - } catch (e) { /* ignore */ } - try { - var pageHost = window.location.hostname; - var candidate = 'http://' + pageHost + ':' + port + '/mcp'; - if (urls.indexOf(candidate) === -1) urls.push(candidate); - } catch (e) { /* ignore */ } + function push(u) { if (u && urls.indexOf(u) === -1) urls.push(u); } + + if (config.McpUrl) push(config.McpUrl); + if (localIp) push('http://' + localIp + ':' + port + '/mcp'); + try { push('http://' + new URL(ApiClient.serverAddress()).hostname + ':' + port + '/mcp'); } catch (e) {} + try { push('http://' + window.location.hostname + ':' + port + '/mcp'); } catch (e) {} return urls; } @@ -122,36 +128,40 @@ define(['baseView', 'loading', 'toast'], function (BaseView, loading, toast) { return; } - const urls = buildCandidateUrls(config); - if (urls.length === 0) { - el.className = 'emcpy-status err'; - el.textContent = 'Keine URL für Status-Check verfügbar.'; - return; - } - el.className = 'emcpy-status pending'; - el.textContent = 'Verbinde mit MCP-Server (' + urls.length + ' Kandidaten) …'; + el.textContent = 'Hole Server-Info & verbinde mit MCP-Server …'; - // Kandidaten nacheinander probieren - const tryNext = (i) => { - if (i >= urls.length) { + // Zuerst die direkte LAN-IP holen, dann Kandidaten bauen + getLocalAddress().then(localIp => { + const urls = buildCandidateUrls(config, localIp); + if (urls.length === 0) { el.className = 'emcpy-status err'; - el.innerHTML = '✗ Nicht erreichbar. Probiert: ' + urls.join(', ') + - '
Port im Docker-Template gemappt? Bei Domain/Proxy: MCP-URL oben setzen.'; + el.textContent = 'Keine URL für Status-Check verfügbar.'; return; } - probeUrl(urls[i], config.ApiKey).then(data => { - const name = data.result && data.result.serverInfo ? data.result.serverInfo.name : 'MCP-Server'; - const ver = data.result && data.result.serverInfo ? data.result.serverInfo.version : ''; - el.className = 'emcpy-status ok'; - el.innerHTML = '✓ Läuft – ' + name + ' v' + ver + ' auf ' + urls[i] + ''; - const pv = view.querySelector('#pluginVersion'); - if (pv) pv.textContent = 'v' + ver; - }).catch(err => { - tryNext(i + 1); - }); - }; - tryNext(0); + el.textContent = 'Verbinde mit MCP-Server (' + urls.length + ' Kandidaten) …'; + + const tryNext = (i) => { + if (i >= urls.length) { + el.className = 'emcpy-status err'; + el.innerHTML = '✗ Nicht erreichbar. Probiert: ' + urls.join(', ') + + '
MCP läuft über die direkte LAN-IP, nicht über den Proxy. ' + + 'Port im Docker-Template gemappt? Bei Domain-Zugriff: MCP-URL oben setzen.'; + return; + } + probeUrl(urls[i], config.ApiKey).then(data => { + const name = data.result && data.result.serverInfo ? data.result.serverInfo.name : 'MCP-Server'; + const ver = data.result && data.result.serverInfo ? data.result.serverInfo.version : ''; + el.className = 'emcpy-status ok'; + el.innerHTML = '✓ Läuft – ' + name + ' v' + ver + ' auf ' + urls[i] + ''; + const pv = view.querySelector('#pluginVersion'); + if (pv) pv.textContent = 'v' + ver; + }).catch(err => { + tryNext(i + 1); + }); + }; + tryNext(0); + }); } onResume(options) { diff --git a/src/eMCPy/eMCPy.csproj b/src/eMCPy/eMCPy.csproj index 2244782..6a4ab8f 100644 --- a/src/eMCPy/eMCPy.csproj +++ b/src/eMCPy/eMCPy.csproj @@ -3,9 +3,9 @@ net6.0 eMCPy eMCPy - 1.1.0 - 1.1.0 - 1.1.0 + 1.1.1 + 1.1.1 + 1.1.1 false CS1591