getUserSubmissions
Retrieve a user's submissions on Hacker News by providing their unique ID. This tool enables access to stories and comments shared by the user, integrating with the Hacker News MCP Server for streamlined data retrieval.
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 handler function that executes the getUserSubmissions tool. It validates the input using UserRequestSchema, queries Algolia API for the user's submissions using author tag, formats the 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/schemas/index.ts:62-64 (schema)Zod schema used for input validation of the getUserSubmissions tool, defining the required 'id' as a string.export const UserRequestSchema = z.object({ id: z.string(), });
- src/index.ts:161-171 (registration)Tool registration in the ListTools handler, specifying name, description, and input schema matching UserRequestSchema.{ name: "getUserSubmissions", description: "Get a user's submissions", inputSchema: { type: "object", properties: { id: { type: "string", description: "The ID of the user" }, }, required: ["id"], }, },