create_article
Generate and publish blog articles on Emlog by defining title, content, excerpt, tags, cover image, category, draft status, and comment settings through structured input.
Instructions
Create a new blog article
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| allow_remark | No | Whether to allow comments | |
| content | Yes | The content of the article | |
| cover | No | The cover image URL | |
| draft | No | Whether to save as draft (y) or publish (n) | |
| excerpt | No | The excerpt/summary of the article | |
| sort_id | No | The category ID for the article | |
| tags | No | Comma-separated tags for the article | |
| title | Yes | The title of the article | |
| top | No | Whether to pin to homepage |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"allow_remark": {
"description": "Whether to allow comments",
"enum": [
"y",
"n"
],
"type": "string"
},
"content": {
"description": "The content of the article",
"type": "string"
},
"cover": {
"description": "The cover image URL",
"type": "string"
},
"draft": {
"description": "Whether to save as draft (y) or publish (n)",
"enum": [
"y",
"n"
],
"type": "string"
},
"excerpt": {
"description": "The excerpt/summary of the article",
"type": "string"
},
"sort_id": {
"description": "The category ID for the article",
"type": "number"
},
"tags": {
"description": "Comma-separated tags for the article",
"type": "string"
},
"title": {
"description": "The title of the article",
"type": "string"
},
"top": {
"description": "Whether to pin to homepage",
"enum": [
"y",
"n"
],
"type": "string"
}
},
"required": [
"title",
"content"
],
"type": "object"
}
Implementation Reference
- src/index.ts:162-208 (registration)Registration of the 'create_article' MCP tool, including input schema, description, and handler function that delegates to EmlogClient.createArticleserver.registerTool( "create_article", { title: "Create Article", description: "Create a new blog article", inputSchema: { title: z.string().describe("The title of the article"), content: z.string().describe("The content of the article"), excerpt: z.string().optional().describe("The excerpt/summary of the article"), cover: z.string().optional().describe("The cover image URL"), sort_id: z.number().optional().describe("The category ID for the article"), tags: z.string().optional().describe("Comma-separated tags for the article"), draft: z.enum(["y", "n"]).optional().describe("Whether to save as draft (y) or publish (n)"), top: z.enum(["y", "n"]).optional().describe("Whether to pin to homepage"), allow_remark: z.enum(["y", "n"]).optional().describe("Whether to allow comments") } }, async ({ title, content, excerpt, cover, sort_id, tags, draft, top, allow_remark }) => { try { const result = await emlogClient.createArticle({ title, content, excerpt, cover, sort_id, tags, draft, top, allow_remark }); return { content: [{ type: "text", text: `Successfully created article: ${title} (ID: ${result.article_id || 'unknown'})` }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
- src/emlog-client.ts:249-271 (handler)Core handler in EmlogClient that executes the API POST request to create a new article via '/?rest-api=article_post' endpointasync createArticle(article: { title: string; content: string; excerpt?: string; cover?: string; author_uid?: number; sort_id?: number; tags?: string; draft?: 'y' | 'n'; post_date?: string; top?: 'y' | 'n'; sortop?: 'y' | 'n'; allow_remark?: 'y' | 'n'; password?: string; link?: string; field_keys?: string[]; field_values?: string[]; auto_cover?: 'y' | 'n'; }): Promise<{ article_id: number }> { const formData = this.buildFormData(article); const response = await this.api.post('/?rest-api=article_post', formData); return response.data.data; }
- src/index.ts:167-177 (schema)Zod input schema defining parameters for the create_article tool, including title, content, optional fields like excerpt, cover, category, tags, draft status, etc.inputSchema: { title: z.string().describe("The title of the article"), content: z.string().describe("The content of the article"), excerpt: z.string().optional().describe("The excerpt/summary of the article"), cover: z.string().optional().describe("The cover image URL"), sort_id: z.number().optional().describe("The category ID for the article"), tags: z.string().optional().describe("Comma-separated tags for the article"), draft: z.enum(["y", "n"]).optional().describe("Whether to save as draft (y) or publish (n)"), top: z.enum(["y", "n"]).optional().describe("Whether to pin to homepage"), allow_remark: z.enum(["y", "n"]).optional().describe("Whether to allow comments") }