Skip to main content
Glama

send_message

Send encrypted messages to wallet addresses or ENS names through the XMTP decentralized messaging network.

Instructions

Send a message to an address via XMTP

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
recipientYesWallet address or ENS name to send message to
messageYesMessage content to send

Implementation Reference

  • The primary handler function for the 'send_message' tool. It checks if the XMTP client is connected, validates the recipient can receive messages, creates a direct message conversation, sends the message, syncs conversations, and returns a success response.
    private async sendMessage(args: any) {
      if (!this.state.client) {
        throw new Error("XMTP client not connected. Use connect_xmtp tool first.");
      }
    
      const { recipient, message } = args;
    
      try {
        // Create recipient identifier for XMTP operations
        const recipientIdentifier = {
          identifier: recipient,
          identifierKind: 0, // IdentifierKind.Ethereum
        };
        
        // Check if we can message this address (try both original and lowercase)
        const canMessage = await this.state.client.canMessage([recipientIdentifier]);
        const canMessageResult = canMessage.get(recipient) || canMessage.get(recipient.toLowerCase());
        if (!canMessageResult) {
          throw new Error(`Address ${recipient} is not on the XMTP network`);
        }
    
        // Create DM conversation with identifier (back to original method)  
        const conversation = await this.state.client.conversations.newDmWithIdentifier(recipientIdentifier);
        
        // Send message
        await conversation.send(message);
        
        // Sync to ensure message is propagated
        await this.state.client.conversations.syncAll();
    
        return {
          content: [
            {
              type: "text",
              text: `Message sent to ${recipient}: "${message}"`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to send message: ${error}`);
      }
    }
  • The input schema and metadata for the 'send_message' tool, defining the required 'recipient' and 'message' parameters as strings.
    {
      name: "send_message",
      description: "Send a message to an address via XMTP",
      inputSchema: {
        type: "object",
        properties: {
          recipient: {
            type: "string",
            description: "Wallet address or ENS name to send message to",
          },
          message: {
            type: "string",
            description: "Message content to send",
          },
        },
        required: ["recipient", "message"],
      },
    },
  • src/index.ts:217-218 (registration)
    The switch case registration in the CallToolRequestSchema handler that routes 'send_message' tool calls to the sendMessage method.
    case "send_message":
      return await this.sendMessage(args);

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/kwaude/xmtp-mcp'

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