Skip to main content
Glama

getNearbyPlayers

Retrieve a list of players currently in proximity to your Minecraft character for coordination, interaction, or safety monitoring.

Instructions

Get a list of players nearby

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration of the 'getNearbyPlayers' tool using server.tool, including description, empty schema, and inline handler function.
    'getNearbyPlayers', 'Get a list of players nearby', {}, async () => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { const players = Object.values(botState.bot.players) .filter( (player) => player.entity && player.username !== botState.bot?.username ) .map((player) => { if (!botState.bot) return '' const pos = player.entity!.position const distance = pos.distanceTo(botState.bot.entity.position) return `${player.username} (${distance.toFixed(2)} blocks away)` }) if (players.length === 0) { return createSuccessResponse('No other players nearby.') } return createSuccessResponse(`Nearby players: ${players.join(', ')}`) } catch (error) { return createErrorResponse(error) } } )
  • The handler function that executes the getNearbyPlayers tool logic: checks connection, retrieves nearby players from botState.bot.players, filters out self, calculates distances, and returns formatted success response or error.
    if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { const players = Object.values(botState.bot.players) .filter( (player) => player.entity && player.username !== botState.bot?.username ) .map((player) => { if (!botState.bot) return '' const pos = player.entity!.position const distance = pos.distanceTo(botState.bot.entity.position) return `${player.username} (${distance.toFixed(2)} blocks away)` }) if (players.length === 0) { return createSuccessResponse('No other players nearby.') } return createSuccessResponse(`Nearby players: ${players.join(', ')}`) } 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