fetch_summary
Retrieve detailed scientific article information from PubMed using PMIDs to access research data efficiently.
Instructions
Fetch detailed article information from PubMed using PMIDs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pmids | Yes | Array of PubMed IDs (PMIDs) to fetch |
Implementation Reference
- src/handlers/fetch-summary.ts:3-11 (handler)Factory function that creates the fetchSummary handler. The handler fetches PubMed articles by PMIDs using the PubMed API.export function createFetchSummaryHandler(pubmedOptions: PubMedOptions) { const pubmedApi = createPubMedAPI(pubmedOptions); return { async fetchSummary(pmids: string[]): Promise<Article[]> { return await pubmedApi.fetchArticles(pmids); } }; }
- src/index.ts:160-190 (registration)Registration of the 'fetch_summary' tool with MCP server, including title, description, input schema, and the wrapper handler function that calls the core fetchSummary and formats the response.server.registerTool( 'fetch_summary', { title: 'PubMed Article Summary', description: 'Fetch detailed article information from PubMed using PMIDs.', inputSchema: { pmids: z.array(z.string()).describe('Array of PubMed IDs (PMIDs) to fetch') } }, async ({ pmids }) => { try { const results = await fetchSummaryHandler.fetchSummary(pmids); return { content: [ { type: 'text', text: JSON.stringify(results, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching article summaries: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } }
- src/index.ts:165-167 (schema)Zod input schema defining the expected input: an array of PMIDs (strings).inputSchema: { pmids: z.array(z.string()).describe('Array of PubMed IDs (PMIDs) to fetch') }
- src/index.ts:72-80 (helper)Configuration of PubMed options and creation of the fetchSummaryHandler instance passed to the tool registration.const pubmedOptions = { email, ...(apiKey && { apiKey }), ...(cacheDir && { cacheDir }), ...(cacheTTL && { cacheTTL: parseInt(cacheTTL) }) }; const searchHandler = createSearchHandler(pubmedOptions); const fetchSummaryHandler = createFetchSummaryHandler(pubmedOptions);