Skip to main content
Glama

getNearbyPlayers

Identify and list players in your immediate vicinity within Minecraft. Enhance coordination, interaction, and gameplay strategy by locating nearby users in real-time.

Instructions

Get a list of players nearby

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that retrieves nearby players by filtering the bot's players list, excluding the bot itself, calculating distances to the bot's position, and returning a formatted success response or appropriate error/not connected response.
    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) } }
  • Registers the 'getNearbyPlayers' tool with server.tool, providing the tool name, description, empty input schema, and the handler function. This occurs within the registerInfoTools function.
    server.tool( '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) } } )

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