Skip to main content
Glama

attackEntity

Target and attack a specific entity in Minecraft using its entity ID with the MCP Minecraft Remote server, enabling precise control for AI-assisted gameplay.

Instructions

Attack a specific entity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entityIdYesID of the entity to attack

Implementation Reference

  • Executes the attackEntity tool: validates connection, locates entity by ID, performs bot.attack(entity), returns success with entity info or error response.
    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) } }
  • Zod input schema defining entityId as a required number parameter.
    { entityId: z.number().describe('ID of the entity to attack'), },
  • Registers the attackEntity tool on the MCP server with name, description, input schema, and handler function.
    server.tool( '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) } } )
  • Invocation of registerEntityInteractionTools() within registerAllTools(), which includes the attackEntity tool registration.
    registerEntityInteractionTools()
  • src/index.ts:7-7 (registration)
    Top-level call to registerAllTools() during server initialization, indirectly registering attackEntity.
    registerAllTools()

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