Skip to main content
Glama

attackEntity

Attack a specific entity in Minecraft by targeting its unique ID. Use this tool to interact with mobs or other players through the MCP Minecraft Remote server.

Instructions

Attack a specific entity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entityIdYesID of the entity to attack

Implementation Reference

  • The handler function that implements the core logic of the attackEntity tool: validates connection, retrieves entity by ID, performs the attack using botState.bot.attack(entity), handles errors, and returns success or error responses.
    async ({ entityId }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Find the entity by ID const entity = botState.bot.entities[entityId] if (!entity) { return createSuccessResponse(`Entity with ID ${entityId} not found.`) } // Attack the entity await botState.bot.attack(entity) return createSuccessResponse( `Attacked entity: ${ entity.name || entity.username || 'Unknown entity' } (ID: ${entityId})` ) } catch (error) { return createErrorResponse(error) } }
  • Input schema using Zod for validating the entityId parameter as a number.
    { entityId: z.number().describe('ID of the entity to attack'), },
  • The server.tool call that registers the attackEntity tool, including its description, input schema, and handler function. This is invoked within the registerEntityInteractionTools function.
    'attackEntity', 'Attack a specific entity', { entityId: z.number().describe('ID of the entity to attack'), }, async ({ entityId }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Find the entity by ID const entity = botState.bot.entities[entityId] if (!entity) { return createSuccessResponse(`Entity with ID ${entityId} not found.`) } // Attack the entity await botState.bot.attack(entity) return createSuccessResponse( `Attacked entity: ${ entity.name || entity.username || 'Unknown entity' } (ID: ${entityId})` ) } catch (error) { return createErrorResponse(error) } } )

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/nacal/mcp-minecraft-remote'

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