get_hierarchy
Retrieve the full taxonomic hierarchy for a specific Taxonomic Serial Number (TSN) using the ITIS MCP Server, enabling detailed classification and navigation of species relationships.
Instructions
Get the complete taxonomic hierarchy for a given TSN.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tsn | Yes | Taxonomic Serial Number (TSN) to get hierarchy for |
Implementation Reference
- src/tools.ts:360-374 (handler)The main MCP tool handler for 'get_hierarchy'. Extracts the 'tsn' parameter, calls itisClient.getHierarchy(tsn), formats the hierarchy from response.docs, and returns as JSON text content.case 'get_hierarchy': { const { tsn } = args as any; const result = await itisClient.getHierarchy(tsn); return { content: [ { type: 'text', text: JSON.stringify({ tsn, hierarchy: result.response.docs, }, null, 2), }, ], }; }
- src/tools.ts:130-139 (schema)Input schema definition for the get_hierarchy tool, requiring a 'tsn' string parameter.inputSchema: { type: 'object', properties: { tsn: { type: 'string', description: 'Taxonomic Serial Number (TSN) to get hierarchy for', }, }, required: ['tsn'], },
- src/tools.ts:261-265 (registration)Registration of the tool list handler that exposes the get_hierarchy tool (among others) via MCP listTools request.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools, }; });
- src/itis-client.ts:187-192 (helper)Helper method in ITISClient that performs the actual ITIS API search for hierarchy by TSN, selecting relevant taxonomic fields.async getHierarchy(tsn: string): Promise<ITISResponse> { return this.search({ query: `tsn:${tsn}`, fields: ['tsn', 'nameWInd', 'kingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species', 'rank', 'phyloSort'] }); }
- src/index.ts:22-23 (registration)Final server registration call that sets up all tool handlers including get_hierarchy via setupToolHandlers.setupToolHandlers(server, itisClient); setupPromptHandlers(server);