get contents by user
Retrieve content published by a specific TabNews user, with options to filter by page, quantity, and sorting strategy.
Instructions
get contents by user from tabnews api
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | The username to get the contents | |
| page | No | The page number to get | |
| per_page | No | The number of contents per page | |
| strategy | No | The strategy to get the contents |
Implementation Reference
- src/tools/status.ts:96-120 (handler)Handler function that executes the tool logic: calls the getContentsByUser API service with provided parameters, formats the result as a JSON text response, and handles errors.handler: async (params: GetContentByUserParams): Promise<McpResponse> => { try { const result = await getContentsByUser({ username: params.username, page: params.page, per_page: params.per_page, strategy: params.strategy, }); const content: McpTextContent = { type: "text", text: `Contents:\n\n${JSON.stringify(result, null, 2)}`, }; return { content: [content], }; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get contents by user: ${error.message}`); } else { throw new Error("Failed to get contents by user"); } } },
- src/tools/status.ts:87-95 (schema)Zod-based input schema definition for the tool parameters: username (required), page, per_page, strategy (optional).parameters: { username: z.string().describe("The username to get the contents"), page: z.number().optional().describe("The page number to get"), per_page: z.number().optional().describe("The number of contents per page"), strategy: z .enum(["relevant", "new", "old"]) .optional() .describe("The strategy to get the contents"), },
- src/index.ts:38-43 (registration)Registration of the tool on the MCP server instance using the tool object's properties.server.tool( getContentsByUserTool.name, getContentsByUserTool.description, getContentsByUserTool.parameters, getContentsByUserTool.handler );