get_species
Retrieve detailed species information from FishBase with 'get_species'. Input the scientific name to access data on ecology, distribution, morphology, and more, or specify fields for tailored results.
Instructions
Get species information from FishBase
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fields | No | Optional list of specific fields to return | |
| species_name | Yes | Scientific name of the species (e.g., 'Salmo trutta') |
Implementation Reference
- src/index.ts:30-48 (schema)Input schema and description for the get_species MCP tool, registered in ListToolsRequestHandler{ name: "get_species", description: "Get species information from FishBase", inputSchema: { type: "object", properties: { species_name: { type: "string", description: "Scientific name of the species (e.g., 'Salmo trutta')", }, fields: { type: "array", items: { type: "string" }, description: "Optional list of specific fields to return", }, }, required: ["species_name"], }, },
- src/index.ts:159-171 (handler)Handler for the get_species tool in CallToolRequestHandler: extracts arguments, calls fishbaseAPI.getSpecies, stringifies and returns as text contentcase "get_species": return { content: [ { type: "text", text: JSON.stringify( await fishbaseAPI.getSpecies(args.species_name as string, args.fields as string[]), null, 2 ), }, ], };
- src/fishbase-api.ts:23-49 (helper)Main logic for retrieving species data: loads species table, filters by exact genus+species match (case-insensitive), optionally projects specific fieldsasync getSpecies(speciesName: string, fields?: string[]): Promise<SpeciesData[]> { try { const speciesData = await this.queryTable('species'); const [genus, species] = speciesName.split(' '); const filtered = speciesData.filter((row: any) => row.Genus?.toLowerCase() === genus?.toLowerCase() && row.Species?.toLowerCase() === species?.toLowerCase() ); if (fields && fields.length > 0) { return filtered.map((row: any) => { const result: any = {}; fields.forEach(field => { if (row[field] !== undefined) { result[field] = row[field]; } }); return result; }); } return filtered; } catch (error) { throw new Error(`Failed to get species data: ${error}`); } }