Skip to main content
Glama

stream_messages

Stream real-time messages from XMTP conversations to monitor incoming communications and respond promptly to decentralized messaging network activity.

Instructions

Start streaming new messages from all conversations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
callbackNoOptional callback function name for message handling

Implementation Reference

  • The handler function that executes the stream_messages tool. It starts a stream of all XMTP conversations, collects up to 10 recent messages, and returns them in the response.
    private async streamMessages(args: any) { if (!this.state.client) { throw new Error("XMTP client not connected. Use connect_xmtp tool first."); } try { // Start streaming all messages const stream = await this.state.client.conversations.streamAllMessages(); let messageCount = 0; const messages: any[] = []; // Collect first few messages for demonstration for await (const message of stream) { messages.push({ id: message.id, sender: message.senderInboxId, content: message.content, timestamp: message.sentAt?.toISOString(), conversationId: message.conversationId, }); messageCount++; if (messageCount >= 10) break; // Limit for demonstration } return { content: [ { type: "text", text: `Started streaming messages. Recent messages:\n${JSON.stringify(messages, null, 2)}`, }, ], }; } catch (error) { throw new Error(`Failed to stream messages: ${error}`); } }
  • The input schema definition for the stream_messages tool, defining an optional callback parameter.
    inputSchema: { type: "object", properties: { callback: { type: "string", description: "Optional callback function name for message handling", }, }, },
  • src/index.ts:191-203 (registration)
    Registration of the stream_messages tool in the ListTools response, including name, description, and schema.
    { name: "stream_messages", description: "Start streaming new messages from all conversations", inputSchema: { type: "object", properties: { callback: { type: "string", description: "Optional callback function name for message handling", }, }, }, },
  • src/index.ts:229-231 (registration)
    Dispatch/registration in the CallTool handler switch statement that routes to the streamMessages method.
    case "stream_messages": return await this.streamMessages(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