get_paper
Retrieve scientific paper details from WormBase, including authors, abstract, and associated genes, using a paper or PubMed ID.
Instructions
Get information about a scientific paper/publication including authors, abstract, and associated genes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Paper identifier - WormBase paper ID (e.g., 'WBPaper00000001') or PubMed ID |
Implementation Reference
- src/index.ts:270-289 (registration)Registers the 'get_paper' MCP tool with name, description, input schema (id: string), and an inline async handler that fetches paper data using WormBaseClient.getEntity and returns JSON-formatted response or error.server.tool( "get_paper", "Get information about a scientific paper/publication including authors, abstract, and associated genes.", { id: z.string().describe("Paper identifier - WormBase paper ID (e.g., 'WBPaper00000001') or PubMed ID"), }, async ({ id }) => { try { const data = await client.getEntity("paper", id, ["overview", "referenced_genes"]); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } catch (error) { return { content: [{ type: "text", text: `Error fetching paper: ${error}` }], isError: true, }; } } );
- src/index.ts:276-288 (handler)Inline handler function for the get_paper tool. Calls WormBaseClient.getEntity for type 'paper' with widgets ['overview', 'referenced_genes'], serializes to JSON text response.async ({ id }) => { try { const data = await client.getEntity("paper", id, ["overview", "referenced_genes"]); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } catch (error) { return { content: [{ type: "text", text: `Error fetching paper: ${error}` }], isError: true, }; } }
- src/index.ts:273-275 (schema)Zod input schema for get_paper tool: requires 'id' string parameter (WormBase paper ID or PubMed ID).{ id: z.string().describe("Paper identifier - WormBase paper ID (e.g., 'WBPaper00000001') or PubMed ID"), },
- src/client.ts:111-132 (helper)WormBaseClient.getEntity generic helper method implementing the core API fetch logic for any WormBase entity (including 'paper'), retrieving specified widgets from REST API and cleaning the data.async getEntity( type: EntityType, id: string, widgets?: string[] ): Promise<Record<string, unknown>> { const defaultWidgets = ["overview"]; const requestedWidgets = widgets || defaultWidgets; const result: Record<string, unknown> = { id, type }; for (const widget of requestedWidgets) { try { const url = `${this.baseUrl}/rest/widget/${type}/${encodeURIComponent(id)}/${widget}`; const data = await this.fetch<any>(url); result[widget] = this.cleanWidgetData(data); } catch (error) { result[widget] = { error: `Failed to fetch ${widget}` }; } } return result; }