{"library":"minecraft-bedrock-server","title":"Minecraft Bedrock Server Wrapper","description":"The `minecraft-bedrock-server` package provides a robust JavaScript API and a command-line interface (CLI) for programmatically managing Minecraft Bedrock Edition servers. It simplifies the process of downloading, starting, stopping, and configuring a Bedrock Dedicated Server instance. The package automatically fetches official server binaries directly from minecraft.net, supporting both Windows and Linux versions. As of its latest stable release, 1.5.2, the project demonstrates an active development cadence with frequent patch updates. Key differentiators include its dual CLI/API approach, direct integration with Minecraft's official download channels for server binaries, and flexible configuration options for `server.properties` directly via code or CLI arguments, making it suitable for automated server deployments or custom game launchers.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install minecraft-bedrock-server"],"cli":{"name":"bedrock-server","version":null}},"imports":["import { startServer } from 'minecraft-bedrock-server';","import { getLatestVersions } from 'minecraft-bedrock-server';","npx minecraft-bedrock-server --version latest --online --path ./my-bedrock-server"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { startServer, getLatestVersions } from 'minecraft-bedrock-server';\nimport * as path from 'path';\nimport * as fs from 'fs';\n\nasync function runBedrockServerExample() {\n  // Define a dedicated path for the server files\n  const serverInstancePath = path.join(__dirname, 'bedrock_server_instance');\n\n  // Ensure the server directory exists\n  if (!fs.existsSync(serverInstancePath)) {\n    fs.mkdirSync(serverInstancePath, { recursive: true });\n    console.log(`Created server instance directory: ${serverInstancePath}`);\n  }\n\n  console.log('Fetching latest Minecraft Bedrock server versions...');\n  const versions = await getLatestVersions();\n  const latestLinuxVersion = versions.linux?.version3; // Using version3 for common display\n\n  if (!latestLinuxVersion) {\n    console.error('Could not determine latest Linux server version from minecraft.net.');\n    return;\n  }\n\n  console.log(`Attempting to start Minecraft Bedrock Server version ${latestLinuxVersion} in ${serverInstancePath}...`);\n\n  const onServerStart = () => {\n    console.log('Minecraft Bedrock Server started successfully!');\n    console.log(`Server is listening. Connect to localhost:${process.env.BEDROCK_PORT ?? 19132}`);\n  };\n\n  const serverOptions = {\n    'server-port': process.env.BEDROCK_PORT ?? 19132,\n    'online-mode': true,\n    path: serverInstancePath,\n    'level-name': 'myAwesomeWorld',\n    'max-players': 10\n    // Any other server.properties options can be passed here\n  };\n\n  // The startServer function handles downloading the server binary if not present\n  const serverProcess = await startServer(latestLinuxVersion, onServerStart, serverOptions);\n\n  console.log(`Server process PID: ${serverProcess.pid}`);\n\n  // In a real application, you would manage the serverProcess (e.g., stdin/stdout, graceful shutdown).\n  // For this quickstart, the server will run until the Node.js process exits.\n}\n\nrunBedrockServerExample().catch(console.error);","lang":"typescript","description":"This quickstart demonstrates how to programmatically fetch the latest Minecraft Bedrock server version, create a dedicated server instance directory, and start the server with custom `server.properties` options. It uses environment variables for port configuration and logs the server's process ID upon successful startup.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}