leaveGame
Disconnect bots from Minecraft gameplay by specifying a username or removing all connected bots at once. Simplify bot management in Minecraft MCP Server environments.
Instructions
Disconnect a bot from the game
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| disconnectAll | No | If true, disconnect all bots and close all connections | |
| username | No | The username of the bot to disconnect |
Implementation Reference
- mcp-server/src/mcp-server.ts:250-291 (handler)Executes the leaveGame tool: disconnects bot(s) by username or all using BotManager.removeBot() or disconnectAll(). Returns success/error messages.if (name === "leaveGame") { try { const { username, disconnectAll } = args as { username?: string; disconnectAll?: boolean }; if (disconnectAll) { const count = botManager.getBotCount(); botManager.disconnectAll(); return { content: [{ type: "text", text: `Disconnected all ${count} bot(s) from the game.` }] }; } if (!username) { throw new Error("Either 'username' or 'disconnectAll' must be specified"); } const bot = botManager.getBotByUsername(username); if (!bot) { throw new Error(`No bot found with username '${username}'`); } botManager.removeBot(username); return { content: [{ type: "text", text: `Bot '${username}' has been disconnected from the game.` }] }; } catch (error) { return { content: [{ type: "text", text: `Failed to leave game: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } }
- mcp-server/src/mcp-server.ts:108-124 (schema)Input schema definition for the leaveGame tool, including username and optional disconnectAll parameters.{ name: "leaveGame", description: "Disconnect a bot from the game", inputSchema: { type: "object", properties: { username: { type: "string", description: "The username of the bot to disconnect" }, disconnectAll: { type: "boolean", description: "If true, disconnect all bots and close all connections" } } } }
- mcp-server/src/mcp-server.ts:84-135 (registration)Registers the leaveGame tool (along with joinGame) in the ListToolsRequest handler by including it in the static tools array.server.setRequestHandler(ListToolsRequestSchema, async () => { const tools = [ { name: "joinGame", description: "Spawn a bot into the Minecraft game", inputSchema: { type: "object", properties: { username: { type: "string", description: "The username for the bot" }, host: { type: "string", description: "Minecraft server host (defaults to 'localhost' or command line option)" }, port: { type: "number", description: "Minecraft server port (defaults to 25565 or command line option)" } }, required: ["username"] } }, { name: "leaveGame", description: "Disconnect a bot from the game", inputSchema: { type: "object", properties: { username: { type: "string", description: "The username of the bot to disconnect" }, disconnectAll: { type: "boolean", description: "If true, disconnect all bots and close all connections" } } } } ]; // Add all registered skills as tools const skillTools = skillRegistry.getAllSkills().map(skill => ({ name: skill.name, description: skill.description, inputSchema: skill.inputSchema })); return { tools: [...tools, ...skillTools] }; });