Skip to main content
Glama

create-draft

Save messages as drafts for later editing or sending in Zulip. Specify message type, recipients, topic, and content. Use user or channel IDs for recipients, allowing easy retrieval and continuation of unfinished messages.

Instructions

📝 CREATE DRAFT: Save a message as draft for later editing or sending. For user IDs in the 'to' field, use search-users or get-users tool to discover available users and their IDs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesDraft message content with Markdown formatting
timestampNoUnix timestamp for draft creation (optional, defaults to current time)
toYesArray of user IDs for private messages, or single channel ID for stream messages
topicYesTopic for stream messages (required even for private messages in API)
typeYesDraft message type: 'stream' for channels, 'private' for direct messages

Implementation Reference

  • The MCP tool handler function that destructures input parameters, calls ZulipClient.createDraft, formats the success response with draft IDs or error message.
    async ({ type, to, topic, content, timestamp }) => { try { const result = await zulipClient.createDraft({ type, to, topic, content, timestamp }); return createSuccessResponse(JSON.stringify({ success: true, draft_ids: result.ids, message: `Draft created successfully! IDs: ${result.ids.join(', ')}` }, null, 2)); } catch (error) { return createErrorResponse(`Error creating draft: ${error instanceof Error ? error.message : 'Unknown error'}`); } }
  • src/server.ts:688-710 (registration)
    Registration of the 'create-draft' MCP tool with server.tool, including name, description, input schema, and inline handler function.
    server.tool( "create-draft", "📝 CREATE DRAFT: Save a message as draft for later editing or sending. For user IDs in the 'to' field, use search-users or get-users tool to discover available users and their IDs.", CreateDraftSchema.shape, async ({ type, to, topic, content, timestamp }) => { try { const result = await zulipClient.createDraft({ type, to, topic, content, timestamp }); return createSuccessResponse(JSON.stringify({ success: true, draft_ids: result.ids, message: `Draft created successfully! IDs: ${result.ids.join(', ')}` }, null, 2)); } catch (error) { return createErrorResponse(`Error creating draft: ${error instanceof Error ? error.message : 'Unknown error'}`); } } );
  • Zod schema defining input parameters and validation for the create-draft tool, including descriptions for LLM usage.
    export const CreateDraftSchema = z.object({ type: z.enum(["stream", "private"]).describe("Draft message type: 'stream' for channels, 'private' for direct messages"), to: z.array(z.number()).describe("Array of user IDs for private messages, or single channel ID for stream messages"), topic: z.string().describe("Topic for stream messages (required even for private messages in API)"), content: z.string().describe("Draft message content with Markdown formatting"), timestamp: z.number().optional().describe("Unix timestamp for draft creation (optional, defaults to current time)") });
  • ZulipClient.createDraft method: constructs the draft object, formats as form-urlencoded POST to /drafts endpoint, handles optional timestamp.
    async createDraft(params: { type: 'stream' | 'private'; to: number[]; topic: string; content: string; timestamp?: number; }): Promise<{ ids: number[] }> { const draftObject: any = { type: params.type, to: params.to, topic: params.topic, content: params.content }; // Only include timestamp if provided, otherwise let server set it if (params.timestamp !== undefined) { draftObject.timestamp = params.timestamp; } const payload = [draftObject]; const response = await this.client.post('/drafts', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, transformRequest: [() => { const params = new URLSearchParams(); params.append('drafts', JSON.stringify(payload)); return params.toString(); }] }); return response.data; }

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/avisekrath/zulip-mcp-server'

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