get-position
Retrieve the current in-game coordinates of a Minecraft bot controlled by the MCP Server, enabling precise tracking and navigation for AI-driven actions within the game world.
Instructions
Get the current position of the bot
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/bot.ts:158-171 (handler)The handler function that retrieves the bot's current position from bot.entity.position, floors the x, y, z coordinates, formats a response string, and returns it via createResponse. Handles errors with createErrorResponse.async (): Promise<McpResponse> => { try { const position = bot.entity.position; const pos = { x: Math.floor(position.x), y: Math.floor(position.y), z: Math.floor(position.z) }; return createResponse(`Current position: (${pos.x}, ${pos.y}, ${pos.z})`); } catch (error) { return createErrorResponse(error as Error); } }
- src/bot.ts:155-172 (registration)Registers the 'get-position' tool with the MCP server using server.tool(), providing a description, empty input schema object, and the inline handler function."get-position", "Get the current position of the bot", {}, async (): Promise<McpResponse> => { try { const position = bot.entity.position; const pos = { x: Math.floor(position.x), y: Math.floor(position.y), z: Math.floor(position.z) }; return createResponse(`Current position: (${pos.x}, ${pos.y}, ${pos.z})`); } catch (error) { return createErrorResponse(error as Error); } } );