get-comments
Retrieve all comments for a specific article on note.com using the article ID to view user feedback and discussions.
Instructions
記事へのコメント一覧を取得する
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| noteId | Yes | 記事ID |
Implementation Reference
- src/tools/note-tools.ts:58-73 (handler)The core execution logic for the 'get-comments' tool. Fetches comments from the note.com API endpoint `/v1/note/${noteId}/comments`, formats each comment using the `formatComment` helper, handles errors with `handleApiError`, and returns a formatted success response.async ({ noteId }) => { try { const data = await noteApiRequest(`/v1/note/${noteId}/comments`); let formattedComments: any[] = []; if (data.comments) { formattedComments = data.comments.map(formatComment); } return createSuccessResponse({ comments: formattedComments }); } catch (error) { return handleApiError(error, "コメント取得"); } }
- src/tools/note-tools.ts:52-74 (registration)Registers the 'get-comments' tool on the MCP server inside `registerNoteTools`. Specifies the tool name, Japanese description, Zod input schema (requiring `noteId`), and the handler function.server.tool( "get-comments", "記事へのコメント一覧を取得する", { noteId: z.string().describe("記事ID"), }, async ({ noteId }) => { try { const data = await noteApiRequest(`/v1/note/${noteId}/comments`); let formattedComments: any[] = []; if (data.comments) { formattedComments = data.comments.map(formatComment); } return createSuccessResponse({ comments: formattedComments }); } catch (error) { return handleApiError(error, "コメント取得"); } } );
- src/note-mcp-server-http.ts:146-155 (schema)JSON Schema definition for the 'get-comments' tool input, used in the tools/list MCP response. Includes optional 'size' parameter unlike the Zod schema.name: "get-comments", description: "記事のコメント一覧を取得", inputSchema: { type: "object", properties: { noteId: { type: "string", description: "記事ID" }, size: { type: "number", description: "取得件数", default: 10 } }, required: ["noteId"] }
- src/utils/formatters.ts:117-136 (helper)Helper function to format raw comment data into a standardized FormattedComment object, used by the get-comments handler.export function formatComment(comment: Comment): FormattedComment { return { id: comment.id || "", body: comment.body || "", user: comment.user?.nickname || "匿名ユーザー", publishedAt: comment.publishAt || "" }; } // いいねデータのフォーマット export function formatLike(like: Like): FormattedLike { return { id: like.id || "", user: like.user?.nickname || "匿名ユーザー", createdAt: like.createdAt || "" }; } // マガジンデータのフォーマット export function formatMagazine(magazine: Magazine): FormattedMagazine {
- src/tools/index.ts:12-19 (registration)Top-level registration aggregator that calls registerNoteTools(server), indirectly registering get-comments among other tools.export function registerAllTools(server: McpServer): void { // 各カテゴリのツールを登録 registerSearchTools(server); registerNoteTools(server); registerUserTools(server); registerMembershipTools(server); registerMagazineTools(server); }