mirror of
https://github.com/RunLit/Bambu-Run.git
synced 2026-10-21 15:37:38 +01:00
Compare commits
3 Commits
fb1c3fb834
...
4cf7d0114d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cf7d0114d | ||
|
|
6c16e66add | ||
|
|
6f681f8083 |
10
README.md
10
README.md
@@ -304,7 +304,15 @@ Bambu-Run exposes printer status, print history, and filament inventory as
|
|||||||
read-only [MCP](https://modelcontextprotocol.io/) tools, so an AI agent (e.g.
|
read-only [MCP](https://modelcontextprotocol.io/) tools, so an AI agent (e.g.
|
||||||
Claude Desktop, Claude Code) can query your printer directly.
|
Claude Desktop, Claude Code) can query your printer directly.
|
||||||
|
|
||||||
Install the extra:
|
**Native install (`setup.sh`):** if you declined MCP during setup (or ran
|
||||||
|
`setup.sh` before MCP support existed), enable it any time with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./native/bambu-run.sh enable-mcp # install deps, create + start the systemd service
|
||||||
|
./native/bambu-run.sh disable-mcp # stop and remove it
|
||||||
|
```
|
||||||
|
|
||||||
|
**Manual / library install:** install the extra:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install 'bambu-run[mcp]'
|
pip install 'bambu-run[mcp]'
|
||||||
|
|||||||
@@ -37,6 +37,38 @@ case "${1:-help}" in
|
|||||||
fi
|
fi
|
||||||
journalctl --user $JOURNAL_UNITS -f --no-hostname
|
journalctl --user $JOURNAL_UNITS -f --no-hostname
|
||||||
;;
|
;;
|
||||||
|
enable-mcp)
|
||||||
|
if [ -f "$SERVICE_DIR/bambu-run-mcp.service" ]; then
|
||||||
|
echo "MCP server already enabled."
|
||||||
|
else
|
||||||
|
echo "Installing MCP dependencies..."
|
||||||
|
"$VENV_DIR/bin/pip" install --quiet ".[mcp]"
|
||||||
|
|
||||||
|
sed "s|{{REPO_DIR}}|$REPO_DIR|g; s|{{VENV_DIR}}|$VENV_DIR|g" \
|
||||||
|
"$REPO_DIR/native/bambu-run-mcp.service" > "$SERVICE_DIR/bambu-run-mcp.service"
|
||||||
|
|
||||||
|
systemctl --user daemon-reload
|
||||||
|
systemctl --user enable bambu-run-mcp.service
|
||||||
|
systemctl --user start bambu-run-mcp.service
|
||||||
|
|
||||||
|
PI_IP=$(hostname -I 2>/dev/null | awk '{print $1}')
|
||||||
|
echo "MCP server enabled on port 8808."
|
||||||
|
echo
|
||||||
|
echo " Claude Desktop config:"
|
||||||
|
echo " {\"mcpServers\":{\"bambu-run\":{\"url\":\"http://${PI_IP:-localhost}:8808/sse\"}}}"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
disable-mcp)
|
||||||
|
if [ ! -f "$SERVICE_DIR/bambu-run-mcp.service" ]; then
|
||||||
|
echo "MCP server is not enabled."
|
||||||
|
else
|
||||||
|
systemctl --user stop bambu-run-mcp.service 2>/dev/null || true
|
||||||
|
systemctl --user disable bambu-run-mcp.service 2>/dev/null || true
|
||||||
|
rm -f "$SERVICE_DIR/bambu-run-mcp.service"
|
||||||
|
systemctl --user daemon-reload
|
||||||
|
echo "MCP server disabled."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
update)
|
update)
|
||||||
echo "Pulling latest code..."
|
echo "Pulling latest code..."
|
||||||
cd "$REPO_DIR" && git pull
|
cd "$REPO_DIR" && git pull
|
||||||
@@ -60,13 +92,15 @@ case "${1:-help}" in
|
|||||||
echo "Update complete."
|
echo "Update complete."
|
||||||
;;
|
;;
|
||||||
help|*)
|
help|*)
|
||||||
echo "Usage: $0 {start|stop|restart|status|logs|update}"
|
echo "Usage: $0 {start|stop|restart|status|logs|update|enable-mcp|disable-mcp}"
|
||||||
echo
|
echo
|
||||||
echo " start Start web + collector services"
|
echo " start Start web + collector services"
|
||||||
echo " stop Stop web + collector services"
|
echo " stop Stop web + collector services"
|
||||||
echo " restart Restart web + collector services"
|
echo " restart Restart web + collector services"
|
||||||
echo " status Show service status"
|
echo " status Show service status"
|
||||||
echo " logs Tail live logs (Ctrl+C to stop)"
|
echo " logs Tail live logs (Ctrl+C to stop)"
|
||||||
echo " update Pull latest code, install deps, migrate, restart"
|
echo " update Pull latest code, install deps, migrate, restart"
|
||||||
|
echo " enable-mcp Install and start the MCP server for AI agent access"
|
||||||
|
echo " disable-mcp Stop and remove the MCP server service"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
21
setup.sh
21
setup.sh
@@ -1,8 +1,21 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Bambu-Run Native Setup — single entry point for Raspberry Pi (or any Linux)
|
# Bambu-Run Native Setup — single entry point for Raspberry Pi (or any Linux)
|
||||||
# Usage: git clone ... && cd Bambu-Run && bash setup.sh
|
# Usage: git clone ... && cd Bambu-Run && bash setup.sh [-v|--verbose]
|
||||||
|
# -v, --verbose show full pip install output instead of --quiet
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
VERBOSE=0
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
-v|--verbose) VERBOSE=1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
PIP_QUIET_FLAG="--quiet"
|
||||||
|
if [ "$VERBOSE" -eq 1 ]; then
|
||||||
|
PIP_QUIET_FLAG=""
|
||||||
|
fi
|
||||||
|
|
||||||
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
|
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
VENV_DIR="$REPO_DIR/.venv"
|
VENV_DIR="$REPO_DIR/.venv"
|
||||||
ENV_FILE="$REPO_DIR/.env"
|
ENV_FILE="$REPO_DIR/.env"
|
||||||
@@ -98,8 +111,8 @@ else:
|
|||||||
print(' opencv stub already exists')
|
print(' opencv stub already exists')
|
||||||
"
|
"
|
||||||
|
|
||||||
"$VENV_DIR/bin/pip" install --quiet --upgrade pip
|
"$VENV_DIR/bin/pip" install $PIP_QUIET_FLAG --upgrade pip
|
||||||
"$VENV_DIR/bin/pip" install --quiet ".[standalone]"
|
"$VENV_DIR/bin/pip" install $PIP_QUIET_FLAG ".[standalone]"
|
||||||
|
|
||||||
# ── 3. Interactive .env ───────────────────────────────────────────────────────
|
# ── 3. Interactive .env ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -208,7 +221,7 @@ MCP_ENABLED=false
|
|||||||
read -rp "Enable MCP server for AI agent access (Claude Desktop, Claude Code, etc.)? [y/N] " ENABLE_MCP
|
read -rp "Enable MCP server for AI agent access (Claude Desktop, Claude Code, etc.)? [y/N] " ENABLE_MCP
|
||||||
if [[ "$ENABLE_MCP" =~ ^[Yy] ]]; then
|
if [[ "$ENABLE_MCP" =~ ^[Yy] ]]; then
|
||||||
green "Installing MCP dependencies..."
|
green "Installing MCP dependencies..."
|
||||||
"$VENV_DIR/bin/pip" install --quiet ".[mcp]"
|
"$VENV_DIR/bin/pip" install $PIP_QUIET_FLAG ".[mcp]"
|
||||||
|
|
||||||
sed "s|{{REPO_DIR}}|$REPO_DIR|g; s|{{VENV_DIR}}|$VENV_DIR|g" \
|
sed "s|{{REPO_DIR}}|$REPO_DIR|g; s|{{VENV_DIR}}|$VENV_DIR|g" \
|
||||||
"$REPO_DIR/native/bambu-run-mcp.service" > "$SERVICE_DIR/bambu-run-mcp.service"
|
"$REPO_DIR/native/bambu-run-mcp.service" > "$SERVICE_DIR/bambu-run-mcp.service"
|
||||||
|
|||||||
@@ -124,7 +124,9 @@ PRINTER_IP = os.environ.get("PRINTER_IP", "")
|
|||||||
ACCESS_TOKEN = os.environ.get("ACCESS_TOKEN", "")
|
ACCESS_TOKEN = os.environ.get("ACCESS_TOKEN", "")
|
||||||
PRINTER_SERIAL = os.environ.get("PRINTER_SERIAL", "")
|
PRINTER_SERIAL = os.environ.get("PRINTER_SERIAL", "")
|
||||||
|
|
||||||
CSRF_TRUSTED_ORIGINS = os.environ.get("CSRF_TRUSTED_ORIGINS", "").split(",")
|
CSRF_TRUSTED_ORIGINS = [
|
||||||
|
origin for origin in os.environ.get("CSRF_TRUSTED_ORIGINS", "").split(",") if origin
|
||||||
|
]
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
|
|||||||
Reference in New Issue
Block a user