get_user_stocks
Retrieve articles bookmarked by a specific Qiita user. Use this tool to access saved content by providing a user ID and optional pagination parameters.
Instructions
Get articles that a user has stocked (bookmarked).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_id | Yes | User ID | |
| page | No | Page number (1-100, default: 1) | |
| per_page | No | Items per page (1-100, default: 20) |
Implementation Reference
- src/index.ts:383-395 (handler)Handler code in the CallToolRequestSchema that executes the get_user_stocks tool by validating the user_id argument and calling the QiitaClient's getUserStocks method.case "get_user_stocks": { if (!args?.user_id) { throw new Error("user_id is required"); } const result = await qiitaClient.getUserStocks( args.user_id as string, args?.page as number | undefined, args?.per_page as number | undefined ); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
- src/index.ts:258-283 (schema)Schema definition for the get_user_stocks tool, including input schema with properties for user_id (required), page, and per_page.{ name: "get_user_stocks", description: "Get articles that a user has stocked (bookmarked).", inputSchema: { type: "object", properties: { user_id: { type: "string", description: "User ID", }, page: { type: "number", description: "Page number (1-100, default: 1)", minimum: 1, maximum: 100, }, per_page: { type: "number", description: "Items per page (1-100, default: 20)", minimum: 1, maximum: 100, }, }, required: ["user_id"], }, },
- src/index.ts:110-121 (helper)Helper method in QiitaClient class that implements the core logic of fetching a user's stocked articles from the Qiita API endpoint /users/{userId}/stocks.async getUserStocks( userId: string, page: number = 1, perPage: number = 20 ): Promise<any[]> { const params = new URLSearchParams({ page: page.toString(), per_page: perPage.toString(), }); return this.fetch(`/users/${userId}/stocks?${params.toString()}`); }
- src/index.ts:303-305 (registration)Registration of the list_tools capability where the tools array (including get_user_stocks) is returned.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });