Skip to main content
Glama

zulip_get_channel_history

Retrieve recent messages from a Zulip channel and topic to access conversation history for review or analysis.

Instructions

Get recent messages from a channel (stream) and topic

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channel_nameYesThe name of the stream
topicYesThe topic name
limitNoNumber of messages to retrieve (default 20)
anchorNoMessage ID to start from (default 'newest')newest

Implementation Reference

  • MCP CallTool request handler case for 'zulip_get_channel_history'. Validates arguments and calls the ZulipClient.getMessages method to fetch channel history.
    case "zulip_get_channel_history": { const args = request.params.arguments as unknown as GetChannelHistoryArgs; if (!args.channel_name || !args.topic) { throw new Error( "Missing required arguments: channel_name and topic" ); } const response = await zulipClient.getMessages( args.channel_name, args.topic, args.limit, args.anchor ); return { content: [{ type: "text", text: JSON.stringify(response) }], }; }
  • Defines the Tool metadata, name, description, and input schema for 'zulip_get_channel_history'.
    const getChannelHistoryTool: Tool = { name: "zulip_get_channel_history", description: "Get recent messages from a channel (stream) and topic", inputSchema: { type: "object", properties: { channel_name: { type: "string", description: "The name of the stream", }, topic: { type: "string", description: "The topic name", }, limit: { type: "number", description: "Number of messages to retrieve (default 20)", default: 20, }, anchor: { type: "string", description: "Message ID to start from (default 'newest')", default: "newest", }, }, required: ["channel_name", "topic"], }, };
  • ZulipClient method implementing the core logic to retrieve messages from a specific stream and topic using narrow parameters.
    async getMessages(streamName: string, topic: string, limit = 20, anchor = "newest") { try { // First, need to find the stream ID const streamsResponse = await this.getStreams(true, true, true); const stream = streamsResponse.streams.find((s: any) => s.name === streamName); if (!stream) { throw new Error(`Stream "${streamName}" not found`); } // Construct narrow to filter by stream and topic const narrow = [ { operator: "stream", operand: streamName }, { operator: "topic", operand: topic }, ]; const params = { narrow: JSON.stringify(narrow), num_before: Math.floor(limit / 2), num_after: Math.floor(limit / 2), anchor: anchor, }; return await this.client.messages.retrieve(params); } catch (error) { console.error("Error getting messages:", error); throw error; } }
  • index.ts:539-547 (registration)
    Registers 'zulip_get_channel_history' (via getChannelHistoryTool) in the ListTools response.
    listChannelsTool, postMessageTool, sendDirectMessageTool, addReactionTool, getChannelHistoryTool, getTopicsTool, subscribeToChannelTool, getUsersTool, ],
  • TypeScript interface defining the argument types for the tool handler.
    interface GetChannelHistoryArgs { channel_name: string; topic: string; limit?: number; anchor?: string; }

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/Monadical-SAS/zulip-mcp'

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