Skip to main content
Glama

get_pubnub_presence

Retrieve real-time presence data for PubNub channels or groups to monitor active users, occupancy counts, and subscriber UUIDs. Input channel or group names to receive JSON-formatted presence information.

Instructions

Retrieves real-time presence information for specified PubNub channels and channel groups. Call this tool when you need to monitor active users, occupancy counts, and subscriber UUIDs. Provide channel names and/or channel group names. Returns presence data in JSON format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelGroupsNoList of channel group names (strings) to query presence data for
channelsNoList of channel names (strings) to query presence data for

Implementation Reference

  • The core handler function for the 'get_pubnub_presence' tool. It calls PubNub's hereNow method to retrieve real-time presence information for specified channels and/or channel groups, returning the JSON result or an error.
    toolHandlers['get_pubnub_presence'] = async ({ channels, channelGroups }) => { try { const result = await pubnub.hereNow({ channels, channelGroups }); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ], }; } catch (err) { return { content: [ { type: 'text', text: `Error fetching presence information: ${err}` } ], isError: true, }; } };
  • The schema definition for the 'get_pubnub_presence' tool, including name, description, and Zod-parameter validation for input channels and channelGroups.
    toolDefinitions['get_pubnub_presence'] = { name: 'get_pubnub_presence', description: 'Retrieves real-time presence information for specified PubNub channels and channel groups. Call this tool when you need to monitor active users, occupancy counts, and subscriber UUIDs. Provide channel names and/or channel group names. Returns presence data in JSON format.', parameters: { channels: z.array(z.string()).default([]).describe('List of channel names (strings) to query presence data for'), channelGroups: z.array(z.string()).default([]).describe('List of channel group names (strings) to query presence data for'), } };
  • index.js:1397-1397 (registration)
    The call to registerAllTools which registers the 'get_pubnub_presence' tool (among others) to the main MCP server, using the handler and schema defined above. The registration logic conditionally includes/excludes tools based on --chat-sdk mode.
    registerAllTools(server, isChatSdkMode);
  • index.js:1363-1394 (registration)
    The registerAllTools function that iterates over all toolDefinitions and registers each tool on the MCP server instance using serverInstance.tool(), including 'get_pubnub_presence' unless excluded in chat-sdk mode.
    function registerAllTools(serverInstance, chatSdkMode = false) { // Tools to exclude when in chat SDK mode const chatSdkExcludedTools = [ 'read_pubnub_sdk_docs', 'write_pubnub_app', 'read_pubnub_resources', 'manage_pubnub_account' ]; for (const toolName in toolDefinitions) { if (toolHandlers[toolName]) { // Skip excluded tools when in chat SDK mode if (chatSdkMode && chatSdkExcludedTools.includes(toolName)) { continue; } // Special handling for chat SDK docs tool if (toolName === 'read_pubnub_chat_sdk_docs' && (chatSdkLanguages.length === 0 || chatSdkTopics.length === 0)) { continue; // Skip this tool if chat SDK data isn't loaded } const toolDef = toolDefinitions[toolName]; serverInstance.tool( toolDef.name, toolDef.description, toolDef.parameters, wrapToolHandler(toolHandlers[toolName], toolName) ); } } }

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/pubnub/pubnub-mcp-server'

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