fetch_summary
Retrieve detailed article information from PubMed by providing PMIDs to access scientific research data.
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)Core handler factory for fetch_summary tool. Creates an object with fetchSummary method that retrieves article summaries from 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:182-184 (schema)Input schema for the fetch_summary tool defining pmids as array of strings.inputSchema: { pmids: z.array(z.string()).describe('Array of PubMed IDs (PMIDs) to fetch') }
- src/index.ts:177-208 (registration)Registers the 'fetch_summary' MCP tool with title, description, input schema, and execution handler that delegates to fetchSummaryHandler and formats the JSON 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:80-80 (helper)Instantiates the fetchSummaryHandler using PubMed options for use in tool registration and resource handler.const fetchSummaryHandler = createFetchSummaryHandler(pubmedOptions);