get-category-notes
Retrieve articles from a specific category on note.com with options to sort by newest or trending content and navigate through pages.
Instructions
カテゴリーに含まれる記事一覧を取得する
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes | カテゴリー名(例: tech) | |
| page | No | ページ番号 | |
| sort | No | ソート方法(new: 新着順, trend: 人気順) | new |
Implementation Reference
- src/tools/user-tools.ts:77-105 (handler)Handler function that fetches notes for a given category from the note.com API, formats the notes with id, title, excerpt, user info, publish date, likes, and URL, then returns a success response or handles errors.async ({ category, page, sort }) => { try { const data = await noteApiRequest(`/v1/categories/${category}?note_intro_only=true&sort=${sort}&page=${page}`); let formattedNotes: any[] = []; if (data.data && data.data.notes && Array.isArray(data.data.notes)) { formattedNotes = data.data.notes.map((note: any) => ({ id: note.id || "", title: note.name || "", excerpt: note.body ? (note.body.length > 100 ? note.body.substring(0, 100) + '...' : note.body) : '本文なし', user: { nickname: note.user?.nickname || "", urlname: note.user?.urlname || "" }, publishedAt: note.publishAt || '日付不明', likesCount: note.likeCount || 0, url: `https://note.com/${note.user?.urlname || ''}/n/${note.key || ''}` })); } return createSuccessResponse({ category, page, notes: formattedNotes }); } catch (error) { return handleApiError(error, "カテゴリー記事取得"); } }
- src/tools/user-tools.ts:72-76 (schema)Zod input schema for the get-category-notes tool defining parameters: category (string), page (number default 1), sort (enum ["new","trend"] default "new").{ category: z.string().describe("カテゴリー名(例: tech)"), page: z.number().default(1).describe("ページ番号"), sort: z.enum(["new", "trend"]).default("new").describe("ソート方法(new: 新着順, trend: 人気順)"), },
- src/tools/user-tools.ts:69-106 (registration)Registration of the get-category-notes tool via server.tool() including name, Japanese description, input schema, and inline handler function.server.tool( "get-category-notes", "カテゴリーに含まれる記事一覧を取得する", { category: z.string().describe("カテゴリー名(例: tech)"), page: z.number().default(1).describe("ページ番号"), sort: z.enum(["new", "trend"]).default("new").describe("ソート方法(new: 新着順, trend: 人気順)"), }, async ({ category, page, sort }) => { try { const data = await noteApiRequest(`/v1/categories/${category}?note_intro_only=true&sort=${sort}&page=${page}`); let formattedNotes: any[] = []; if (data.data && data.data.notes && Array.isArray(data.data.notes)) { formattedNotes = data.data.notes.map((note: any) => ({ id: note.id || "", title: note.name || "", excerpt: note.body ? (note.body.length > 100 ? note.body.substring(0, 100) + '...' : note.body) : '本文なし', user: { nickname: note.user?.nickname || "", urlname: note.user?.urlname || "" }, publishedAt: note.publishAt || '日付不明', likesCount: note.likeCount || 0, url: `https://note.com/${note.user?.urlname || ''}/n/${note.key || ''}` })); } return createSuccessResponse({ category, page, notes: formattedNotes }); } catch (error) { return handleApiError(error, "カテゴリー記事取得"); } } );