Skip to content

Add remote config system (MCED-Remote) for server file management#7

Open
Luke1505 wants to merge 5 commits intomainfrom
claude/remote-config-system-SCdvW
Open

Add remote config system (MCED-Remote) for server file management#7
Luke1505 wants to merge 5 commits intomainfrom
claude/remote-config-system-SCdvW

Conversation

@Luke1505
Copy link
Collaborator

Summary

This PR introduces a complete remote configuration management system that allows users to connect to and edit Minecraft server configuration files from the MCED desktop application. It includes a standalone Java HTTP agent (mced-remote) that runs on the server, and corresponding UI/API integration in the Electron app.

Key Changes

Remote Agent (Java - mced-remote/)

  • MCEDRemote.java: Entry point for the standalone HTTP agent
  • AgentConfig.java: Configuration management with auto-generation of API keys and allowed file extensions
  • PathSanitizer.java: Security layer preventing path traversal attacks and restricting file access to allowed extensions
  • AuthMiddleware.java: API key-based authentication for all endpoints
  • AgentHttpServer.java & Router.java: HTTP server setup with route handling
  • StatusHandler.java: /api/v1/status endpoint returning server info and version
  • InfoHandler.java: /api/v1/info endpoint with server detection (Fabric, Forge, Paper, etc.)
  • FilesHandler.java: /api/v1/files endpoint for listing files with optional recursion
  • FileHandler.java: /api/v1/file endpoint for reading, writing, and deleting individual files
  • FileManager.java: Core file operations with size limits and extension validation

Desktop App (TypeScript/React)

  • RemoteConnectionManager.tsx: UI for managing saved connections with connect/disconnect/delete operations
  • RemoteConnectDialog.tsx: Dialog for adding/editing connections with connection testing
  • RemoteFileBrowser.tsx: Full-featured file browser with tree view, syntax-highlighted editor (Monaco), and file operations
  • RemoteConfigService.ts: Service layer handling HTTP communication with remote agents
  • remoteConnectionStore.ts: Zustand store managing connection state, auto-polling, and persistence
  • remote.types.ts: Shared TypeScript types for connections, files, and server info

Integration

  • preload.ts: Exposed IPC handlers for remote operations
  • main/index.ts: IPC handlers for connection management, file operations, and secure API key storage using Electron's safeStorage
  • App.tsx & store.ts: Added "remote" view mode to main navigation
  • Header.tsx & MainPanel.tsx: UI integration for remote view mode

Notable Implementation Details

  • Security: API keys are encrypted using Electron's safeStorage when available, with fallback to plaintext storage
  • File Access Control: Server-side path sanitization prevents directory traversal; only whitelisted file extensions are accessible
  • Connection Polling: Active connections are polled every 30 seconds to detect disconnections
  • Editor Features: Monaco editor with syntax highlighting for config formats (JSON, YAML, TOML, properties), Ctrl+S save shortcut, and dirty state tracking
  • Error Handling: Comprehensive error codes and messages for connection failures, timeouts, and file operations
  • Configuration: Server-side config file (mced-remote.properties) auto-generated on first run with sensible defaults

https://claude.ai/code/session_01JK8L3K1rDjTudkw7Et6XTm

Implements a two-component remote configuration editing system:

**MCED-Remote (Java Server Agent)**
- Standalone Java 17 JAR, platform-independent (no Fabric/Forge/Paper dependency)
- Embedded HTTP server using Java's built-in com.sun.net.httpserver
- REST API: GET/PUT/DELETE /api/v1/file, GET /api/v1/files, /status, /info
- API key authentication via X-API-Key header
- Path traversal protection via canonical path checking
- File extension whitelist (.toml, .json, .json5, .yml, .yaml, .cfg, .properties)
- Auto-generates mced-remote.properties with a UUID API key on first run
- Maven build: mvn package → mced-remote.jar

**MCED Client Integration**
- RemoteConfigService.ts: Node.js fetch-based HTTP client with timeout/error handling
- IPC handlers in index.ts: remote:connect, listFiles, readFile, writeFile, deleteFile, etc.
- API keys stored encrypted via electron.safeStorage (fallback: plaintext)
- Preload bridge extended with all remote: API methods
- Shared TypeScript types in remote.types.ts

https://claude.ai/code/session_01JK8L3K1rDjTudkw7Et6XTm
…tegration

Completes the MCED-Remote client-side UI layer:

**New Components**
- RemoteConnectDialog: Add/edit connections with name, host, port, API key
  fields; includes test-before-save and auto-connect on save
- RemoteConnectionManager: Panel listing saved connections with connect/
  disconnect/edit/delete actions, active connection status dot, server info
- RemoteFileBrowser: Two-pane layout with collapsible directory tree on the
  left and a plain-text editor on the right; Ctrl+S to save, delete with
  confirmation dialog

**State Management**
- remoteConnectionStore: Zustand store tracking UI connection state
  (idle/connecting/connected/error), active connection ID, cached server info,
  and the saved-connection list from the main process

**App Integration**
- Added "remote" view mode to useAppStore (alongside "mods" and "kubejs")
- MainPanel: renders the two-pane remote layout when viewMode === "remote"
- Header: Server button toggles remote mode; shows green dot when connected

https://claude.ai/code/session_01JK8L3K1rDjTudkw7Et6XTm
**Monaco Editor in RemoteFileBrowser**
- Replace plain textarea with @monaco-editor/react Editor component
- Language detection: JSON → json, TOML/cfg/properties → ini, YAML → yaml
- Theme follows app settings (dark/light)
- Ctrl+S bound via editor.addCommand for native feel
- Footer shows language, file size, and save hint

**30s Heartbeat Polling**
- remoteConnectionStore polls remoteGetInfo every 30 seconds
- On failure: sets connectionStatus to "error" with a "Connection lost" message
- Poll stops automatically on disconnect or connection error
- Uses module-level interval ref (startPolling/stopPolling) to avoid closure issues

**Standalone Remote Mode (no local instance required)**
- MainPanel: remote check moved before the `!currentInstance` early return
- App.tsx: renders full app shell (Header + MainPanel) when viewMode === "remote"
  even without a local instance loaded
- Landing page: "Remote Config" button added below "Open Instance" to enter
  remote mode directly from the start screen

https://claude.ai/code/session_01JK8L3K1rDjTudkw7Et6XTm
Adds automated build, release, and platform upload for the mced-remote.jar:

**mced-remote/pom.xml**
- Added maven-assembly-plugin to produce a versioned release JAR
  (mced-remote-{version}.jar) alongside the plain mced-remote.jar
- Added Implementation-Version/Title to JAR manifest
- Added explicit maven-compiler-plugin (Java 17)
- Two output artifacts: mced-remote.jar (server deploy) + mced-remote-{version}.jar (releases)

**New: .github/workflows/build-mced-remote.yml**
- Triggers on: branch pushes that touch mced-remote/**, version tags (v*), manual dispatch
- Job 1 (build): resolves version from tag/input/pom.xml, sets it via versions:set,
  builds with Maven, stores both JARs as workflow artifacts (30-day retention)
- Job 2 (github-release): publishes to GitHub Releases with setup instructions in body
- Job 3 (modrinth): uploads via Modrinth v2 API when MODRINTH_PROJECT_ID var is set
- Job 4 (curseforge): uploads via CurseForge API when CURSEFORGE_PROJECT_ID var is set
- Modrinth/CurseForge jobs are opt-in via repository variables (no secrets = skipped)

**Updated: .github/workflows/release.yml**
- New job (build-java): builds MCED-Remote JAR before the Electron release matrix
- New job (attach-jar): uploads both JARs to the same GitHub Release as the Electron apps
- JAR build only runs once (ubuntu-latest), keeping the Electron matrix unchanged

**package.json**
- build:java — runs mvn package for the Java agent
- build:all  — runs build + build:java together

### Required GitHub secrets/variables for platform uploads
| Name | Type | Purpose |
|------|------|---------|
| MODRINTH_TOKEN | Secret | Modrinth API token |
| MODRINTH_PROJECT_ID | Variable | Modrinth project slug/ID |
| CURSEFORGE_TOKEN | Secret | CurseForge API token |
| CURSEFORGE_PROJECT_ID | Variable | CurseForge project numeric ID |

https://claude.ai/code/session_01JK8L3K1rDjTudkw7Et6XTm
- Add `permissions: contents: read` to build, modrinth, and curseforge
  jobs in build-mced-remote.yml (principle of least privilege)
- Remove unused `connectionStatus` destructure in MainPanel.tsx

https://claude.ai/code/session_01JK8L3K1rDjTudkw7Et6XTm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants