Skip to main content
Glama

publish_pubnub_message

Send data to a specified PubNub channel by providing the channel name and message payload. Returns a timetoken confirming successful message publication.

Instructions

Publishes a message to a specified PubNub channel. Call this tool whenever you need to send data through PubNub. Provide the channel name and message payload. Returns a timetoken confirming successful publication.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelYesName of the PubNub channel (string) to publish the message to
messageYesMessage payload as a string

Implementation Reference

  • The handler function that executes the 'publish_pubnub_message' tool logic. It uses the PubNub SDK to publish a message to the specified channel and returns the timetoken on success or an error message.
    toolHandlers['publish_pubnub_message'] = async ({ channel, message }) => {
        try {
          const result = await pubnub.publish({
            channel,
            message,
          });
          return {
            content: [
              {
                type: 'text',
                text: `Message published successfully. Timetoken: ${result.timetoken}`,
              },
            ],
          };
        } catch (err) {
          return {
            content: [
              {
                type: 'text',
                text: `Error publishing message: ${err}`,
              },
            ],
            isError: true,
          };
        }
    };
  • The tool definition including name, description, and Zod schema for input parameters (channel and message).
    toolDefinitions['publish_pubnub_message'] = {
      name: 'publish_pubnub_message',
      description: 'Publishes a message to a specified PubNub channel. Call this tool whenever you need to send data through PubNub. Provide the channel name and message payload. Returns a timetoken confirming successful publication.',
      parameters: {
        channel: z.string().describe('Name of the PubNub channel (string) to publish the message to'),
        message: z.string().describe('Message payload as a string'),
      }
    };
  • index.js:1363-1394 (registration)
    The registerAllTools function that registers the 'publish_pubnub_message' tool (along with others) by calling server.tool() with the definition and wrapped handler. Called for main server and HTTP sessions.
    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)
          );
        }
      }
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the core action (publishing) and the successful outcome (returns a timetoken), but lacks details about error conditions, rate limits, authentication requirements, or whether the operation is idempotent. It provides basic behavioral context but misses important operational details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise with three focused sentences: purpose statement, usage guidance, and return value. Every sentence earns its place by providing essential information without redundancy. The structure is front-loaded with the core functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 2-parameter mutation tool with no annotations and no output schema, the description provides adequate basic information but lacks depth. It covers what the tool does and what it returns, but doesn't address error handling, security considerations, or integration patterns with other PubNub tools. Given the complexity of messaging systems, more operational context would be beneficial.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with both parameters clearly documented. The description adds minimal value beyond the schema, only mentioning that users should 'Provide the channel name and message payload' without explaining format constraints, size limits, or special considerations. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Publishes a message') and target resource ('to a specified PubNub channel'), distinguishing it from siblings like get_pubnub_messages (read) or signal_pubnub_message (different operation). It uses precise terminology that aligns with PubNub's messaging paradigm.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage context ('Call this tool whenever you need to send data through PubNub'), which clearly indicates when to use this tool. However, it doesn't specify when NOT to use it or mention alternatives like signal_pubnub_message for different message types, leaving some ambiguity in sibling differentiation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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