Skip to main content
Glama

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
NameRequiredDescriptionDefault
disconnectAllNoIf true, disconnect all bots and close all connections
usernameNoThe username of the bot to disconnect

Implementation Reference

  • 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 }; } }
  • 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" } } } }
  • 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] }; });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/leo4life2/minecraft-mcp-http'

If you have feedback or need assistance with the MCP directory API, please join our Discord server