UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

65 lines (64 loc) 2.95 kB
/** * ServerCommand - Manage Bedrock Dedicated Server lifecycle * * ARCHITECTURE DOCUMENTATION * ========================== * * Provides subcommands for starting, stopping, and querying the status of * a Bedrock Dedicated Server (BDS) instance via the MCT ToolCommand system. * * WORKFLOW: * /server start → Starts BDS with default settings * /server start --project . → Starts BDS and deploys the current project * /server start --slot 1 → Starts on a specific slot (port offset) * /server stop → Stops the running BDS instance * /server status → Reports current BDS status * * INFRASTRUCTURE: * - Uses ServerManager.ensureActiveServer() to orchestrate BDS lifecycle * - ServerManager handles downloading BDS, provisioning slot folders, * deploying the creator_tools_ingame addon, and managing the process * - Each slot maps to a port via getBasePortForSlot (19132 + slot * 32) * - The creator_tools_ingame addon is always deployed, providing action set * execution and scripting infrastructure inside the running server * * RELATED FILES: * - src/local/ServerManager.ts — BDS download, provisioning, and lifecycle * - src/local/DedicatedServer.ts — Single BDS process management * - src/local/ServerMinecraft.ts — IMinecraft wrapper for DedicatedServer * - src/app/toolcommands/commands/ScriptCommand.ts — Injects code into running BDS * - src/app/IMinecraftStartMessage.ts — Start configuration * * SCOPES: * - ui: Electron app, where DedicatedServerCommandHandler manages BDS * - serveTerminal: `mct serve` mode with direct ServerManager access * - mcp: MCP server sessions with serverManager in context * - serverApi: HTTP API endpoints * * SLOT SYSTEM: * ServerManager supports multiple concurrent BDS instances via slots (0-79). * Each slot gets its own port range and runtime folder. Typical prefixes: * - "mcp" for MCP sessions * - "serve" for serve mode * - "vscode" for VS Code extension */ import type { IToolCommandMetadata, IToolCommandResult } from "../IToolCommand"; import { ToolCommandBase, ToolCommandExitCode } from "../IToolCommand"; import type { IToolCommandContext } from "../IToolCommandContext"; export declare class ServerCommand extends ToolCommandBase { readonly metadata: IToolCommandMetadata; execute(context: IToolCommandContext, args: string[], flags: Record<string, string | boolean | string[]>): Promise<IToolCommandResult>; private _startServer; private _stopServer; private _getStatus; /** * Categorize an error message into a standard exit code. */ _categorizeError(message: string): ToolCommandExitCode; /** * Get the ServerManager from whichever context is available. * Priority: session.serverManager > minecraft (if it wraps a server) > undefined */ private _getServerManager; } export declare const serverCommand: ServerCommand;