pocket_get_articles
Retrieve unread articles from Pocket API, providing article ID, title, URL, and excerpt. Specify the number of articles to fetch (1-20) and integrate them into Claude via MCP server.
Instructions
Fetches the latest unread articles from Pocket API. Returns up to 20 articles by default. You can specify the number of articles to fetch (1-20) using the count parameter. Returns the article ID, title, URL, and excerpt for each article.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No |
Implementation Reference
- index.ts:84-126 (handler)Main execution logic for the 'pocket_get_articles' tool: validates input, calls getPocketList helper, formats and returns article list or error.case "pocket_get_articles": { if (!config.pocket) { throw new Error("Pocket API configuration is not available"); } const parsed = GetPocketArticlesSchema.safeParse(args); if (!parsed.success) { throw new Error( `Invalid arguments for pocket_get_articles: ${parsed.error}`, ); } try { const articles = await getPocketList( config.pocket, parsed.data.count, ); return { content: [ { type: "text", text: articles .map( (article) => `ID: ${article.id}\nTitle: ${article.title}\nURL: ${article.url}\nExcerpt: ${article.excerpt}\n`, ) .join("\n---\n"), }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Pocket API Error: ${errorMessage}`, }, ], isError: true, }; } }
- index.ts:33-35 (schema)Zod schema for input validation of pocket_get_articles tool (optional count parameter, default 20).const GetPocketArticlesSchema = z.object({ count: z.number().optional().default(20), });
- index.ts:61-67 (registration)Tool registration definition: name, description, and input schema for listTools response.name: "pocket_get_articles", description: "Fetches the latest unread articles from Pocket API. Returns up to 20 articles by default. " + "You can specify the number of articles to fetch (1-20) using the count parameter. " + "Returns the article ID, title, URL, and excerpt for each article.", inputSchema: zodToJsonSchema(GetPocketArticlesSchema) as ToolInput, },
- pocket.ts:26-56 (helper)Core helper function that makes API call to Pocket to retrieve unread articles, processes response into simplified format.export async function getPocketList(config: PocketConfig, count = 20) { const response = await fetch("https://getpocket.com/v3/get", { method: "POST", headers: { "Content-Type": "application/json; charset=UTF-8", "X-Accept": "application/json", }, body: JSON.stringify({ consumer_key: config.consumerKey, access_token: config.accessToken, count: Math.min(count, 20), sort: "newest", detailType: "complete", state: "unread", // 未読の記事のみを取得 }), }); if (!response.ok) { throw new Error(`Pocket API request failed: ${response.statusText}`); } const data = (await response.json()) as PocketResponse; const filteredList = Object.values(data.list).map((item) => ({ id: item.item_id, title: item.resolved_title || item.given_title || "", url: item.resolved_url || "", excerpt: item.excerpt || "", })); return filteredList; }