esa_create_comment
Add a Markdown-formatted comment to a specific article using the post number, enabling collaborative discussions and feedback through the esa API integration.
Instructions
Post a comment to an article
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body_md | Yes | Comment body (Markdown format) | |
| post_number | Yes | Post number to comment on | |
| user | No | Poster's screen_name (only team owners can specify) |
Implementation Reference
- index.ts:412-425 (handler)Core handler function in EsaClient that executes the POST request to create a comment on the specified post using the Esa API.async createComment(post_number: number, body_md: string, user?: string): Promise<any> { const url = `${this.baseUrl}/posts/${post_number}/comments`; const commentData: { body_md: string; user?: string } = { body_md }; if (user) commentData.user = user; const response = await fetch(url, { method: "POST", headers: this.headers, body: JSON.stringify({ comment: commentData }), }); return response.json(); }
- index.ts:270-291 (schema)Tool definition for 'esa_create_comment' including name, description, and input schema.const createCommentTool: Tool = { name: "esa_create_comment", description: "Post a comment to an article", inputSchema: { type: "object", properties: { post_number: { type: "number", description: "Post number to comment on", }, body_md: { type: "string", description: "Comment body (Markdown format)", }, user: { type: "string", description: "Poster's screen_name (only team owners can specify)", }, }, required: ["post_number", "body_md"], }, };
- index.ts:551-564 (handler)Switch case in CallToolRequest handler that validates input arguments and invokes the EsaClient.createComment method.case "esa_create_comment": { const args = request.params.arguments as unknown as CreateCommentArgs; if (!args.post_number || !args.body_md) { throw new Error("post_number and body_md are required"); } const response = await esaClient.createComment( args.post_number, args.body_md, args.user ); return { content: [{ type: "text", text: JSON.stringify(response) }], }; }
- index.ts:60-64 (schema)TypeScript interface defining the arguments for creating a comment, used for type safety in the handler.interface CreateCommentArgs { post_number: number; body_md: string; user?: string; }
- index.ts:607-617 (registration)Registration of the esa_create_comment tool (via createCommentTool) in the list of tools returned by ListToolsRequest handler.tools: [ listPostsTool, getPostTool, createPostTool, updatePostTool, listCommentsTool, getCommentTool, createCommentTool, getMembersTool, getMemberTool, ],