Refactor: PHP-Built-in-Server durch TypeScript-Binary (Bun Runtime) ersetzt

- src/*.ts: Port von mcp/*.php (helpers, tools, server)
- Bun.serve() statt php -S — production-grade HTTP, POST funktioniert
- dist/mua-1.0.0-x86_64-1.txz: Slackware-Paket (Binary + rc.mua + mua.page + PHP-Helper)
- plugin/mua.plg: .txz-Installation via upgradepkg
- scripts/rc.mua: Binary statt php -S
- scripts/mua.page: Binary-Info statt PHP-Version
- scripts/package.sh: .txz-Builder

Fix: MCP-POST-Endpunkt lieferte leeren Body (php -S Limitation).
Bun.serve() löst das Problem.
This commit is contained in:
Mikei386
2026-08-18 08:02:39 +02:00
parent 3de8cb055a
commit 7e925153fc
12 changed files with 1305 additions and 69 deletions
+31 -56
View File
@@ -7,6 +7,8 @@
<!ENTITY pluginURL "http://192.168.1.2:4000/michael/MUA-Mikes-Unraid-Agent/raw/branch/main/plugin/mua.plg">
<!ENTITY pluginLOC "/boot/config/plugins/&name;">
<!ENTITY emhttpLOC "/usr/local/emhttp/plugins/&name;">
<!ENTITY txzURL "http://192.168.1.2:4000/michael/MUA-Mikes-Unraid-Agent/raw/branch/main/dist/mua-1.0.0-x86_64-1.txz">
<!ENTITY txzSHA256 "5ba2080852e7decc7f9ffd147773ca294826b5279d8a3ffa79182f1292dc85d3">
]>
<PLUGIN name="&name;"
@@ -23,6 +25,7 @@
<CHANGES>
### 1.0.0
- Initial release: 21 Docker, network, and system tools as MCP server over HTTP (Streamable HTTP, port 3002).
- Runtime: TypeScript (Bun Runtime, compiled binary) — no PHP built-in server.
</CHANGES>
<!--
@@ -42,8 +45,7 @@ echo "===================================================="
echo ""
# Verzeichnisse
mkdir -p &emhttpLOC;/mcp
mkdir -p &emhttpLOC;/scripts
mkdir -p &emhttpLOC;
mkdir -p &pluginLOC;
mkdir -p /var/log/plugins
touch /var/log/plugins/mua.log
@@ -53,73 +55,41 @@ touch /var/log/plugins/mua.log
<!--
===========================================
GIT-CLONE + DATEIEN INSTALLIEREN
SLACKWARE-PACKET INSTALLIEREN
===========================================
Das .txz enthält:
usr/local/bin/mua (kompiliertes Binary)
usr/local/bin/unraid-docker-mcp-helper.php (PHP-Helper)
etc/rc.d/rc.mua (SysVinit-Service)
usr/local/emhttp/plugins/mua/mua.page (WebGUI-Tab)
install/doinst.sh (läuft nach Installation)
===========================================
-->
<FILE Run="/bin/bash">
<INLINE>
set -e
GIT_REPO="http://192.168.1.2:4000/michael/MUA-Mikes-Unraid-Agent.git"
TMP_DIR="/tmp/mua-install-$$"
echo " Kloniere Repo..."
git clone --depth 1 "$GIT_REPO" "$TMP_DIR" 2&gt;&amp;1 | sed 's/^/ /'
# MCP-Server (PHP)
echo " Installiere MCP-Server..."
cp "$TMP_DIR/mcp/server.php" &emhttpLOC;/mcp/
cp "$TMP_DIR/mcp/helpers.php" &emhttpLOC;/mcp/
cp "$TMP_DIR/mcp/tools.php" &emhttpLOC;/mcp/
cp "$TMP_DIR/mcp/selftest.php" &emhttpLOC;/mcp/
chmod 644 &emhttpLOC;/mcp/*.php
# PHP-Helper (Write-Operationen)
echo " Installiere PHP-Helper..."
cp "$TMP_DIR/scripts/unraid-docker-mcp-helper.php" /usr/local/bin/
chmod 755 /usr/local/bin/unraid-docker-mcp-helper.php
# WebGUI-Tab (.page-Format)
echo " Installiere WebGUI-Tab..."
cp "$TMP_DIR/scripts/mua.page" &emhttpLOC;/mua.page
chmod 644 &emhttpLOC;/mua.page
# SysVinit-Service
echo " Installiere Service..."
cp "$TMP_DIR/scripts/rc.mua" /etc/rc.d/rc.mua
chmod 755 /etc/rc.d/rc.mua
# Cleanup
rm -rf "$TMP_DIR"
</INLINE>
<FILE Name="mua-1.0.0-x86_64-1.txz" Run="upgradepkg --install-new" Mode="755" Min="7.0.0">
<URL>&txzURL;</URL>
<SHA256>&txzSHA256;</SHA256>
</FILE>
<!--
===========================================
POST-INSTALL: Selftest + Service starten
POST-INSTALL: Health-Check
===========================================
-->
<FILE Run="/bin/bash">
<INLINE>
set +e
echo " Führe Selftest aus..."
php &emhttpLOC;/mcp/selftest.php 2&gt;&amp;1 | sed 's/^/ /'
echo " Starte MCP-Server..."
/etc/rc.d/rc.mua start
# Health-Check
echo ""
echo " Führe Health-Check aus..."
sleep 2
if curl -sf "http://127.0.0.1:3002/health" &gt; /dev/null 2&gt;&amp;1; then
if curl -sf "http://127.0.0.1:3002/health" > /dev/null 2&gt;&amp;1; then
echo ""
echo " Health-Check: OK"
echo ""
echo "===================================================="
echo " MUA installiert und läuft auf Port 3002"
echo " Endpunkt: http://$(hostname -I | awk '{print $1}'):3002/mcp"
echo " WebGUI: Settings &gt; MUA"
echo " WebGUI: Settings > MUA"
echo "===================================================="
else
echo ""
@@ -140,10 +110,12 @@ UPDATE: Alte Dateien bereinigen
-->
<FILE Run="/bin/bash" Method="update">
<INLINE>
# Alte Dateien entfernen vor Reinstall
# Service stoppen vor Update
/etc/rc.d/rc.mua stop 2>/dev/null || true
# Alte PHP-Dateien entfernen (falls vorhanden)
rm -rf &emhttpLOC;/mcp
rm -rf &emhttpLOC;/scripts
rm -f &emhttpLOC;/mua.page
rm -f &emhttpLOC;/plugin.php
</INLINE>
@@ -169,16 +141,19 @@ echo ""
# 2. Service-Datei entfernen
rm -f /etc/rc.d/rc.mua
# 3. PHP-Helper entfernen
# 3. Binary entfernen
rm -f /usr/local/bin/mua
# 4. PHP-Helper entfernen
rm -f /usr/local/bin/unraid-docker-mcp-helper.php
# 4. Plugin-Verzeichnis entfernen
# 5. Plugin-Verzeichnis entfernen
rm -rf &emhttpLOC;
# 5. Config entfernen
# 6. Config entfernen
rm -rf &pluginLOC;
# 6. Logs entfernen
# 7. Logs entfernen
rm -f /var/log/plugins/mua.log
rm -f /var/run/mua.pid