like_article
Enable users to like specific articles on Emlog blogs by submitting the article ID, liker’s name, and avatar URL via the Emlog MCP Server interface.
Instructions
Like an article
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| avatar | No | Avatar URL of the person liking | |
| gid | Yes | The ID of the article to like | |
| name | No | Name of the person liking |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"avatar": {
"description": "Avatar URL of the person liking",
"type": "string"
},
"gid": {
"description": "The ID of the article to like",
"type": "number"
},
"name": {
"description": "Name of the person liking",
"type": "string"
}
},
"required": [
"gid"
],
"type": "object"
}
Implementation Reference
- src/index.ts:368-386 (handler)MCP tool handler: destructures input params, calls emlogClient.likeArticle(), returns success message or error.async ({ gid, name, avatar }) => { try { await emlogClient.likeArticle(gid, name, avatar); return { content: [{ type: "text", text: `Successfully liked article with ID: ${gid}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } }
- src/index.ts:362-366 (schema)Input schema using Zod: gid (number, required), name/avatar (string, optional).inputSchema: { gid: z.number().describe("The ID of the article to like"), name: z.string().optional().describe("Name of the person liking"), avatar: z.string().optional().describe("Avatar URL of the person liking") }
- src/index.ts:357-387 (registration)Registration of the 'like_article' tool with McpServer using title, description, inputSchema, and handler function.server.registerTool( "like_article", { title: "Like Article", description: "Like an article", inputSchema: { gid: z.number().describe("The ID of the article to like"), name: z.string().optional().describe("Name of the person liking"), avatar: z.string().optional().describe("Avatar URL of the person liking") } }, async ({ gid, name, avatar }) => { try { await emlogClient.likeArticle(gid, name, avatar); return { content: [{ type: "text", text: `Successfully liked article with ID: ${gid}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
- src/emlog-client.ts:291-298 (helper)EmlogClient helper method: sends POST to /index.php?action=addlike with gid, optional name/avatar, returns like id.async likeArticle(gid: number, name?: string, avatar?: string): Promise<{ id: number }> { const formData = new URLSearchParams(); formData.append('gid', String(gid)); if (name) formData.append('name', name); if (avatar) formData.append('avatar', avatar); const response = await this.api.post('/index.php?action=addlike', formData); return response.data.data; }