get_user_followers
Retrieve a user's followers list from Qiita community platform. Specify user ID to get follower data with pagination support for managing user relationships.
Instructions
指定されたユーザーのフォロワー一覧を取得します
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | ページ番号(1-100) | |
| perPage | No | 1ページあたりの件数(1-100) | |
| userId | Yes | ユーザーID |
Implementation Reference
- src/tools/handlers.ts:75-79 (handler)The handler definition for the 'get_user_followers' tool. It defines the input schema (merging userId and pagination schemas) and the execute function that calls the QiitaApiClient's getUserFollowers method.get_user_followers: { schema: userIdSchema.merge(paginationSchema), execute: async ({ userId, page, perPage }, client) => client.getUserFollowers(userId, page, perPage), },
- src/tools/definitions.ts:95-118 (schema)The MCP tool schema definition for 'get_user_followers', including name, description, and detailed input schema for listing user followers.{ name: 'get_user_followers', description: '指定されたユーザーのフォロワー一覧を取得します', inputSchema: { type: 'object', properties: { userId: { type: 'string', description: 'ユーザーID', }, page: { type: 'number', description: 'ページ番号(1-100)', default: 1, }, perPage: { type: 'number', description: '1ページあたりの件数(1-100)', default: 20, }, }, required: ['userId'], }, },
- src/qiitaApiClient.ts:50-55 (helper)The Qiita API client helper method that performs the HTTP GET request to retrieve the followers of a specific user from the Qiita API.async getUserFollowers(userId: string, page = 1, perPage = 20) { const response = await this.client.get(`/users/${userId}/followers`, { params: { page, per_page: perPage }, }); return response.data; }
- src/tools/handlers.ts:15-17 (schema)Zod schema definition for userId input used in get_user_followers handler.const userIdSchema = z.object({ userId: z.string(), });
- src/tools/handlers.ts:10-13 (schema)Zod schema definition for pagination parameters used in get_user_followers handler.const paginationSchema = z.object({ page: z.number().int().min(1).max(100).default(1), perPage: z.number().int().min(1).max(100).default(20), });
- src/index.ts:30-65 (registration)The server request handler for CallToolRequestSchema that registers and dispatches all tools, including 'get_user_followers', by looking up in toolHandlers by name and executing it.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; const accessToken = process.env.QIITA_ACCESS_TOKEN; const qiita = new QiitaApiClient(accessToken); const handler = toolHandlers[name]; try { if (!handler) { throw new Error(`未知のツール: ${name}`); } const parsedArgs = handler.schema.parse(args ?? {}); const result = await handler.execute(parsedArgs, qiita); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error: any) { const message = error?.message ?? String(error); return { content: [ { type: 'text', text: `エラーが発生しました: ${message}`, }, ], isError: true, }; } });