get_species
Retrieve detailed species information from FishBase marine biology database using scientific names. Access ecological data, distribution records, morphological details, and validate species names.
Instructions
Get species information from FishBase
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| species_name | Yes | Scientific name of the species (e.g., 'Salmo trutta') | |
| fields | No | Optional list of specific fields to return |
Implementation Reference
- src/fishbase-api.ts:23-49 (handler)Core implementation of get_species tool: queries the species table, matches by scientific name (genus + species), filters optional fields, and returns matching SpeciesData.async 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}`); } }
- src/index.ts:159-171 (handler)MCP CallToolRequest handler dispatches 'get_species' calls to FishBaseAPI.getSpecies and returns JSON-formatted response.case "get_species": return { content: [ { type: "text", text: JSON.stringify( await fishbaseAPI.getSpecies(args.species_name as string, args.fields as string[]), null, 2 ), }, ], };
- src/index.ts:30-48 (schema)Registration and input schema definition for the 'get_species' tool in ListTools response.{ 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/fishbase-api.ts:8-18 (schema)TypeScript interface defining the structure of species data returned by getSpecies.interface SpeciesData { SpecCode?: number; Genus?: string; Species?: string; FBname?: string; Length?: number; CommonLength?: number; MaxLengthRef?: number; Weight?: number; [key: string]: any; }