From 35c77f544f61e97003b3e14567e7bf71f939212b Mon Sep 17 00:00:00 2001 From: Daniel Nouri Date: Sat, 27 Dec 2025 14:24:33 +0100 Subject: [PATCH] feat: Add Linux build support - Conditionally compile install module for Windows/macOS only - Show helpful message on Linux when run without flags - Add build-linux job to GitHub Actions workflow - Include Linux binary in release artifacts - Add --http-only flag for standalone HTTP server mode (no MCP stdio) --- .github/workflows/build.yml | 20 +++++++++++++++++- src/main.rs | 42 +++++++++++++++++++++++++++++++++---- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 63254ee..91cdd31 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,10 +60,28 @@ jobs: name: Windows-rbx-studio-mcp path: output/rbx-studio-mcp.exe + build-linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build + run: | + cargo install cargo-edit + cargo set-version --workspace "$CARGO_PKG_VERSION" + cargo build --release + mkdir -p output + cp target/release/rbx-studio-mcp output/ + cd output && zip rbx-studio-mcp-linux.zip rbx-studio-mcp + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: Linux-rbx-studio-mcp + path: output/rbx-studio-mcp-linux.zip + release: runs-on: ubuntu-latest if: ${{ github.ref_name == github.event.repository.default_branch }} - needs: [build-macos, build-windows] + needs: [build-macos, build-windows, build-linux] steps: - run: mkdir -p output - uses: actions/download-artifact@v4 diff --git a/src/main.rs b/src/main.rs index 97d5a66..6973d8c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ use std::sync::Arc; use tokio::sync::Mutex; use tracing_subscriber::{self, EnvFilter}; mod error; +#[cfg(any(target_os = "windows", target_os = "macos"))] mod install; mod rbx_studio_server; @@ -20,6 +21,10 @@ struct Args { /// Run as MCP server on stdio #[arg(short, long)] stdio: bool, + + /// Run HTTP server only (no MCP stdio, for use with /proxy endpoint) + #[arg(long)] + http_only: bool, } #[tokio::main] @@ -33,19 +38,48 @@ async fn main() -> Result<()> { .init(); let args = Args::parse(); - if !args.stdio { - return install::install().await; + if !args.stdio && !args.http_only { + #[cfg(any(target_os = "windows", target_os = "macos"))] + { + return install::install().await; + } + #[cfg(not(any(target_os = "windows", target_os = "macos")))] + { + eprintln!("Auto-install not supported on Linux."); + eprintln!("Use --stdio for MCP mode or --http-only for HTTP server mode."); + std::process::exit(1); + } } tracing::debug!("Debug MCP tracing enabled"); let server_state = Arc::new(Mutex::new(AppState::new())); - let (close_tx, close_rx) = tokio::sync::oneshot::channel(); - let listener = tokio::net::TcpListener::bind((Ipv4Addr::new(127, 0, 0, 1), STUDIO_PLUGIN_PORT)).await; + if args.http_only { + // HTTP-only mode: just run the HTTP server without MCP stdio + if let Ok(listener) = listener { + let app = axum::Router::new() + .route("/request", get(request_handler)) + .route("/response", post(response_handler)) + .route("/proxy", post(proxy_handler)) + .with_state(server_state); + tracing::info!("HTTP-only server listening on port {STUDIO_PLUGIN_PORT}"); + eprintln!("MCP HTTP server running on http://127.0.0.1:{STUDIO_PLUGIN_PORT}"); + eprintln!("Press Ctrl+C to stop"); + axum::serve(listener, app).await.unwrap(); + } else { + eprintln!("Error: Port {STUDIO_PLUGIN_PORT} already in use"); + std::process::exit(1); + } + return Ok(()); + } + + // Standard MCP mode with stdio + let (close_tx, close_rx) = tokio::sync::oneshot::channel(); + let server_state_clone = Arc::clone(&server_state); let server_handle = if let Ok(listener) = listener { let app = axum::Router::new()