get_draft_list
Retrieve a list of draft articles from the Emlog blog system using specified count, enabling efficient draft management and content planning.
Instructions
Get list of draft articles
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | Number of drafts to retrieve |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"count": {
"description": "Number of drafts to retrieve",
"type": "number"
}
},
"type": "object"
}
Implementation Reference
- src/index.ts:573-605 (registration)MCP tool registration for 'get_draft_list', including schema definition and handler function.server.registerTool( "get_draft_list", { title: "Get Draft List", description: "Get list of draft articles", inputSchema: { count: z.number().optional().describe("Number of drafts to retrieve") } }, async ({ count }) => { try { const result = await emlogClient.getDraftList({ count }); const drafts = result.drafts; const draftList = drafts.map((draft: any) => `- ID: ${draft.id}, Title: ${draft.title || 'Untitled'}, Date: ${draft.date}` ).join('\n'); return { content: [{ type: "text", text: `Draft articles (${drafts.length} found):\n\n${draftList || 'No drafts found'}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
- src/emlog-client.ts:318-324 (handler)Core handler function in EmlogClient that executes the API request to retrieve the list of draft posts.async getDraftList(params: { count?: number; } = {}): Promise<{ drafts: EmlogPost[] }> { const queryParams = this.buildParams(params); const response = await this.api.get(`/?rest-api=draft_list&${queryParams.toString()}`); return response.data.data; }
- src/index.ts:575-581 (schema)Input schema definition using Zod for the get_draft_list tool, specifying optional 'count' parameter.{ title: "Get Draft List", description: "Get list of draft articles", inputSchema: { count: z.number().optional().describe("Number of drafts to retrieve") } },
- src/index.ts:582-604 (handler)MCP tool execution handler that wraps the client call, processes the drafts list, and returns formatted text response.async ({ count }) => { try { const result = await emlogClient.getDraftList({ count }); const drafts = result.drafts; const draftList = drafts.map((draft: any) => `- ID: ${draft.id}, Title: ${draft.title || 'Untitled'}, Date: ${draft.date}` ).join('\n'); return { content: [{ type: "text", text: `Draft articles (${drafts.length} found):\n\n${draftList || 'No drafts found'}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } }