Skip to main content
Glama

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
NameRequiredDescriptionDefault
user_idYesUser ID
pageNoPage number (1-100, default: 1)
per_pageNoItems per page (1-100, default: 20)

Implementation Reference

  • 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) }],
      };
    }
  • 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"],
      },
    },
  • 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 };
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ningen/qiita-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server