v1.1.1: Status-Check bevorzugt direkte LAN-IP (aus /System/Info), Hinweis 'Zugriff über direkte IP, nicht Proxy'
This commit is contained in:
1 parent
fb53aac329
commit
179945bfe8
3 files changed
+60
-43
No files matched your search
@@ -12,6 +12,13 @@
|
||||
<h1 class="pageTitle">eMCPy Configuration <span id="pluginVersion" style="font-size:0.6em;color:#888;font-weight:normal;"></span></h1>
|
||||
<p style="color: #999; margin-top: -0.5em; margin-bottom: 1.5em;">MCP-Server (Model Context Protocol) für AI-Agenten. Läuft eingebettet in Emby auf einem eigenen Port.</p>
|
||||
|
||||
<div style="margin-top: 1em; padding: 0.9em 1.1em; border-radius: 6px; background: rgba(33,150,243,0.08); border-left: 4px solid #2196F3; color: #cfd8dc; font-size: 0.95em; line-height: 1.5;">
|
||||
<b style="color: #64B5F6;">ℹ️ Zugriff über direkte IP (LAN)</b><br>
|
||||
Der MCP-Endpunkt wird über die <b>direkte Server-IP</b> im LAN erreicht, z. B.<br>
|
||||
<code style="background:#263238;padding:0.15em 0.5em;border-radius:3px;">http://192.168.1.2:8097/mcp</code><br>
|
||||
<span style="color:#90a4ae;">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.</span>
|
||||
</div>
|
||||
|
||||
<form id="emcpyConfigForm" class="emcpyConfigForm">
|
||||
<div class="paper-card" style="padding: 1.5em; margin-top: 2em;">
|
||||
<h2 style="margin-top:0;">MCP-Server</h2>
|
||||
|
||||
@@ -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(', ') +
|
||||
'<br><small>Port im Docker-Template gemappt? Bei Domain/Proxy: MCP-URL oben setzen.</small>';
|
||||
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 <code>' + urls[i] + '</code>';
|
||||
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(', ') +
|
||||
'<br><small>MCP läuft über die <b>direkte LAN-IP</b>, nicht über den Proxy. ' +
|
||||
'Port im Docker-Template gemappt? Bei Domain-Zugriff: MCP-URL oben setzen.</small>';
|
||||
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 <code>' + urls[i] + '</code>';
|
||||
const pv = view.querySelector('#pluginVersion');
|
||||
if (pv) pv.textContent = 'v' + ver;
|
||||
}).catch(err => {
|
||||
tryNext(i + 1);
|
||||
});
|
||||
};
|
||||
tryNext(0);
|
||||
});
|
||||
}
|
||||
|
||||
onResume(options) {
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<AssemblyName>eMCPy</AssemblyName>
|
||||
<RootNamespace>eMCPy</RootNamespace>
|
||||
<Version>1.1.0</Version>
|
||||
<AssemblyVersion>1.1.0</AssemblyVersion>
|
||||
<FileVersion>1.1.0</FileVersion>
|
||||
<Version>1.1.1</Version>
|
||||
<AssemblyVersion>1.1.1</AssemblyVersion>
|
||||
<FileVersion>1.1.1</FileVersion>
|
||||
<GenerateDocumentationFile>false</GenerateDocumentationFile>
|
||||
<NoWarn>CS1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
Reference in new issue
Block a user