get_draft_detail
Retrieve detailed information about a specific draft by providing its ID. This tool is used for accessing and managing draft content in the Emlog blog system via the MCP server.
Instructions
Get details of a specific draft
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the draft to retrieve |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"id": {
"description": "The ID of the draft to retrieve",
"type": "number"
}
},
"required": [
"id"
],
"type": "object"
}
Implementation Reference
- src/index.ts:616-635 (handler)The MCP tool handler function for 'get_draft_detail' that fetches the draft using emlogClient.getDraftDetail and returns formatted text output.async ({ id }) => { try { const result = await emlogClient.getDraftDetail(id); const draft = result.draft; return { content: [{ type: "text", text: `Draft Details:\n\nTitle: ${draft.title}\nID: ${draft.id}\nDate: ${draft.date}\nAuthor: ${draft.author_name}\nCategory: ${draft.sort_name || 'Uncategorized'}\nExcerpt: ${draft.excerpt || 'No excerpt'}\n\n--- Content ---\n${draft.content}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } }
- src/index.ts:609-615 (schema)Input schema definition for the 'get_draft_detail' tool, specifying the required 'id' parameter.{ title: "Get Draft Detail", description: "Get details of a specific draft", inputSchema: { id: z.number().describe("The ID of the draft to retrieve") } },
- src/index.ts:607-636 (registration)Registration of the 'get_draft_detail' tool on the MCP server using server.registerTool.server.registerTool( "get_draft_detail", { title: "Get Draft Detail", description: "Get details of a specific draft", inputSchema: { id: z.number().describe("The ID of the draft to retrieve") } }, async ({ id }) => { try { const result = await emlogClient.getDraftDetail(id); const draft = result.draft; return { content: [{ type: "text", text: `Draft Details:\n\nTitle: ${draft.title}\nID: ${draft.id}\nDate: ${draft.date}\nAuthor: ${draft.author_name}\nCategory: ${draft.sort_name || 'Uncategorized'}\nExcerpt: ${draft.excerpt || 'No excerpt'}\n\n--- Content ---\n${draft.content}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
- src/emlog-client.ts:327-331 (helper)Core helper method in EmlogClient that makes the REST API call to retrieve draft details by ID.async getDraftDetail(id: number): Promise<{ draft: EmlogPost }> { const queryParams = this.buildParams({ id }); const response = await this.api.get(`/?rest-api=draft_detail&${queryParams.toString()}`); return response.data.data; }