get-my-notes
Retrieve your article list including drafts from note.com with pagination and status filtering options.
Instructions
自分の記事一覧(下書きを含む)を取得する
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | ページ番号(デフォルト: 1) | |
| perPage | No | 1ページあたりの表示件数(デフォルト: 20) | |
| status | No | 記事の状態フィルター(all:すべて, draft:下書きのみ, public:公開済みのみ) | all |
Implementation Reference
- src/tools/note-tools.ts:701-806 (handler)The server.tool registration for 'get-my-notes', which includes the inline Zod schema for parameters (page, perPage, status) and the complete asynchronous handler function. The handler fetches the user's note list from the Note.com API (/v2/note_list/contents), supports pagination and status filtering (all/draft/public), formats each note with details like ID, title, excerpt, status, URLs, and returns a structured paginated response using createSuccessResponse.server.tool( "get-my-notes", "自分の記事一覧(下書きを含む)を取得する", { page: z.number().default(1).describe("ページ番号(デフォルト: 1)"), perPage: z.number().default(20).describe("1ページあたりの表示件数(デフォルト: 20)"), status: z.enum(["all", "draft", "public"]).default("all").describe("記事の状態フィルター(all:すべて, draft:下書きのみ, public:公開済みのみ)"), }, async ({ page, perPage, status }) => { try { if (!env.NOTE_USER_ID) { return createErrorResponse("環境変数 NOTE_USER_ID が設定されていません。.envファイルを確認してください。"); } const params = new URLSearchParams({ page: page.toString(), per_page: perPage.toString(), draft: "true", draft_reedit: "false", ts: Date.now().toString() }); if (status === "draft") { params.set("status", "draft"); } else if (status === "public") { params.set("status", "public"); } const data = await noteApiRequest( `/v2/note_list/contents?${params.toString()}`, "GET", null, true ); if (env.DEBUG) { console.error(`API Response: ${JSON.stringify(data, null, 2)}`); } let formattedNotes: any[] = []; let totalCount = 0; if (data.data && data.data.notes && Array.isArray(data.data.notes)) { formattedNotes = data.data.notes.map((note: any) => { const isDraft = note.status === "draft"; const noteKey = note.key || ""; const noteId = note.id || ""; const draftTitle = note.noteDraft?.name || ""; const title = note.name || draftTitle || "(無題)"; let excerpt = ""; if (note.body) { excerpt = note.body.length > 100 ? note.body.substring(0, 100) + '...' : note.body; } else if (note.peekBody) { excerpt = note.peekBody; } else if (note.noteDraft?.body) { const textContent = note.noteDraft.body.replace(/<[^>]*>/g, ''); excerpt = textContent.length > 100 ? textContent.substring(0, 100) + '...' : textContent; } const publishedAt = note.publishAt || note.publish_at || note.displayDate || note.createdAt || '日付不明'; return { id: noteId, key: noteKey, title: title, excerpt: excerpt, publishedAt: publishedAt, likesCount: note.likeCount || 0, commentsCount: note.commentsCount || 0, status: note.status || "unknown", isDraft: isDraft, format: note.format || "", url: `https://note.com/${env.NOTE_USER_ID}/n/${noteKey}`, editUrl: `https://editor.note.com/notes/${noteId}/edit/`, hasDraftContent: note.noteDraft ? true : false, lastUpdated: note.noteDraft?.updatedAt || note.createdAt || "", user: { id: note.user?.id || env.NOTE_USER_ID, name: note.user?.name || note.user?.nickname || "", urlname: note.user?.urlname || env.NOTE_USER_ID } }; }); } totalCount = data.data?.totalCount || 0; return createSuccessResponse({ total: totalCount, page: page, perPage: perPage, status: status, totalPages: Math.ceil(totalCount / perPage), hasNextPage: page * perPage < totalCount, hasPreviousPage: page > 1, draftCount: formattedNotes.filter((note: any) => note.isDraft).length, publicCount: formattedNotes.filter((note: any) => !note.isDraft).length, notes: formattedNotes }); } catch (error) { return handleApiError(error, "記事一覧取得"); } } );