get-topics-in-stream
Retrieve all recent topics (conversation threads) in a specific stream to browse what's being discussed.
Instructions
💬 STREAM TOPICS: Get all recent topics (conversation threads) in a specific stream (channel). Use this to browse what's being discussed in a stream.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stream_id | Yes | Unique stream ID to get topics for |
Implementation Reference
- src/server.ts:585-601 (handler)Handler function for 'get-topics-in-stream'. Calls zulipClient.getStreamTopics(stream_id) and returns a formatted JSON response with stream_id, topic_count, and topics array (each with name and max_id).
async ({ stream_id }) => { try { const result = await zulipClient.getStreamTopics(stream_id); return createSuccessResponse(JSON.stringify({ stream_id, topic_count: result.topics.length, topics: result.topics.map(topic => ({ name: topic.name, max_id: topic.max_id })) }, null, 2)); } catch (error) { return createErrorResponse(`Error getting stream topics: ${error instanceof Error ? error.message : 'Unknown error'}`); } } ); - src/server.ts:581-601 (registration)Registration of the 'get-topics-in-stream' tool via server.tool() with description and schema.
server.tool( "get-topics-in-stream", "💬 STREAM TOPICS: Get all recent topics (conversation threads) in a specific stream (channel). Use this to browse what's being discussed in a stream.", GetStreamTopicsSchema.shape, async ({ stream_id }) => { try { const result = await zulipClient.getStreamTopics(stream_id); return createSuccessResponse(JSON.stringify({ stream_id, topic_count: result.topics.length, topics: result.topics.map(topic => ({ name: topic.name, max_id: topic.max_id })) }, null, 2)); } catch (error) { return createErrorResponse(`Error getting stream topics: ${error instanceof Error ? error.message : 'Unknown error'}`); } } ); - src/types.ts:212-214 (schema)Zod schema GetStreamTopicsSchema defining the input: stream_id (number).
export const GetStreamTopicsSchema = z.object({ stream_id: z.number().describe("Unique stream ID to get topics for") }); - src/types.ts:266-266 (schema)Type alias GetStreamTopicsParams inferred from the schema.
export type GetStreamTopicsParams = z.infer<typeof GetStreamTopicsSchema>; - src/zulip/client.ts:368-371 (helper)Helper method getStreamTopics in the ZulipClient class. Calls GET /users/me/{streamId}/topics API endpoint and returns topics.
async getStreamTopics(streamId: number): Promise<{ topics: ZulipTopic[] }> { const response = await this.client.get(`/users/me/${streamId}/topics`); return response.data; }