getUserSubmissions
Retrieve a Hacker News user's submitted stories and comments to analyze their contributions and activity history on the platform.
Instructions
Get a user's submissions
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the user |
Implementation Reference
- src/index.ts:491-515 (handler)The core handler logic for the 'getUserSubmissions' tool. Validates the input user ID using UserRequestSchema, queries Algolia API for user's submissions using author tag, formats the hit results into a numbered list with details, and returns as text content.case "getUserSubmissions": { const validatedArgs = validateInput(UserRequestSchema, args); const { id } = validatedArgs; const results = await algoliaApi.search("", { tags: `author_${id}`, hitsPerPage: 50, }); const hits = results.hits || []; const text = `Submissions by ${id}:\n\n` + hits .map( (hit: any, index: number) => `${index + 1}. ${hit.title || hit.comment_text}\n` + ` ID: ${hit.objectID}\n` + ` Points: ${hit.points || 0} | Posted: ${hit.created_at}\n\n` ) .join(""); return { content: [{ type: "text", text: text.trim() }], }; }
- src/index.ts:161-171 (registration)Tool registration entry in the ListTools handler, defining the tool name, description, and input schema (object with required 'id' string).{ name: "getUserSubmissions", description: "Get a user's submissions", inputSchema: { type: "object", properties: { id: { type: "string", description: "The ID of the user" }, }, required: ["id"], }, },
- src/schemas/index.ts:62-64 (schema)Zod schema (UserRequestSchema) used for input validation in the getUserSubmissions handler, requiring a string 'id' for the user.export const UserRequestSchema = z.object({ id: z.string(), });