Skip to main content
Glama

get_messages

Retrieve encrypted messages from a conversation with a specific wallet address on the XMTP network. Specify the address and optionally limit the number of messages returned.

Instructions

Get messages from a conversation with an address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesWallet address to get conversation with
limitNoMaximum number of messages to retrieve

Implementation Reference

  • The main handler function that implements the get_messages tool logic: creates a DM conversation with the given address, syncs, fetches up to 'limit' messages, formats them as JSON, and returns as text content.
    private async getMessages(args: any) {
      if (!this.state.client) {
        throw new Error("XMTP client not connected. Use connect_xmtp tool first.");
      }
    
      const { address, limit = 50 } = args;
    
      try {
        // Create conversation with proper identifier (back to original method)
        const addressIdentifier = {
          identifier: address,
          identifierKind: 0, // IdentifierKind.Ethereum
        };
        const conversation = await this.state.client.conversations.newDmWithIdentifier(addressIdentifier);
        
        // Sync conversations to ensure we get latest messages
        await this.state.client.conversations.syncAll();
        
        // Add brief delay after sync
        await new Promise(resolve => setTimeout(resolve, 500));
        
        const messages = await conversation.messages({ limit });
    
        const messageList = messages.map((msg: DecodedMessage<any>) => ({
          id: msg.id,
          sender: msg.senderInboxId,
          content: msg.content,
          timestamp: msg.sentAt?.toISOString(),
        }));
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(messageList, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to get messages: ${error}`);
      }
    }
  • src/index.ts:220-221 (registration)
    Tool dispatch/registration in the CallToolRequestSchema handler switch statement, which calls the getMessages method when 'get_messages' is requested.
    case "get_messages":
      return await this.getMessages(args);
  • Tool definition including name, description, and input schema (address required, limit optional default 50) in the ListToolsRequestSchema response.
    {
      name: "get_messages",
      description: "Get messages from a conversation with an address",
      inputSchema: {
        type: "object",
        properties: {
          address: {
            type: "string",
            description: "Wallet address to get conversation with",
          },
          limit: {
            type: "number",
            description: "Maximum number of messages to retrieve",
            default: 50,
          },
        },
        required: ["address"],
      },
    },
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the action ('Get messages') but lacks behavioral details: it doesn't specify if this is a read-only operation, what permissions are needed, how messages are ordered (e.g., chronological), if there's pagination beyond the 'limit' parameter, or what happens if the address has no conversation. For a tool with no annotations, this is a significant gap in transparency.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action ('Get messages') and includes essential context ('from a conversation with an address'). Every part earns its place, making it highly concise and well-structured.

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

Completeness2/5

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

Given no annotations and no output schema, the description is incomplete for a tool with 2 parameters. It doesn't cover behavioral aspects like safety (read-only vs. mutation), error handling, or return format. For a read operation in a messaging context, more context on ordering, permissions, or response structure would improve completeness.

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?

Schema description coverage is 100%, with clear descriptions for both parameters ('address' and 'limit'). The description adds minimal value beyond the schema, mentioning 'address' but not elaborating on its format or context. It doesn't explain parameter interactions (e.g., how 'limit' affects retrieval). Baseline 3 is appropriate since the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the verb ('Get') and resource ('messages'), specifying the source ('from a conversation with an address'). It distinguishes from siblings like 'send_message' (write vs. read) and 'list_conversations' (messages vs. conversations), but doesn't explicitly differentiate from 'stream_messages' (batch vs. stream). The purpose is specific but could be more precise about sibling differentiation.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., whether the conversation must exist or be initialized), nor does it compare to siblings like 'stream_messages' for real-time updates or 'list_conversations' for overviews. Usage is implied by the name but not explicitly stated.

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

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