create_comment
Add comments to Qiita articles using Markdown formatting. Specify the article ID and comment body to contribute to developer discussions.
Instructions
指定された記事にコメントを作成します
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| itemId | Yes | 記事ID | |
| body | Yes | コメントの本文(Markdown形式) |
Implementation Reference
- src/tools/handlers.ts:169-175 (handler)The handler definition for the 'create_comment' tool, including Zod input schema validation and execution logic that delegates to the QiitaApiClient.create_comment: { schema: z.object({ itemId: z.string(), body: z.string(), }), execute: async ({ itemId, body }, client) => client.createComment(itemId, body), },
- src/tools/definitions.ts:520-537 (schema)The MCP Tool definition for 'create_comment', providing the JSON input schema, description, and metadata used for tool listing.{ name: 'create_comment', description: '指定された記事にコメントを作成します', inputSchema: { type: 'object', properties: { itemId: { type: 'string', description: '記事ID', }, body: { type: 'string', description: 'コメントの本文(Markdown形式)', }, }, required: ['itemId', 'body'], }, },
- src/qiitaApiClient.ts:211-215 (helper)The QiitaApiClient method implementing the core logic to create a comment via HTTP POST to the Qiita API.async createComment(itemId: string, body: string) { this.assertAuthenticated(); const response = await this.client.post(`/items/${itemId}/comments`, { body }); return response.data; }
- src/index.ts:30-65 (registration)The generic tool execution handler registration in the MCP server, which dispatches to specific tool handlers based on name, including 'create_comment' via toolHandlers[name].server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; const accessToken = process.env.QIITA_ACCESS_TOKEN; const qiita = new QiitaApiClient(accessToken); const handler = toolHandlers[name]; try { if (!handler) { throw new Error(`未知のツール: ${name}`); } const parsedArgs = handler.schema.parse(args ?? {}); const result = await handler.execute(parsedArgs, qiita); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error: any) { const message = error?.message ?? String(error); return { content: [ { type: 'text', text: `エラーが発生しました: ${message}`, }, ], isError: true, }; } });