search_species
Find marine species by entering common names or partial scientific names to retrieve detailed biological information from FishBase data.
Instructions
Search for species by common name or partial scientific name
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search term (common name or partial scientific name) | |
| limit | No | Maximum number of results to return (default: 20) |
Implementation Reference
- src/index.ts:173-185 (handler)MCP tool handler for 'search_species': calls fishbaseAPI.searchSpecies with query and limit parameters, stringifies the result as JSON text response.case "search_species": return { content: [ { type: "text", text: JSON.stringify( await fishbaseAPI.searchSpecies(args.query as string, (args.limit as number) || 20), null, 2 ), }, ], };
- src/index.ts:49-67 (registration)Registration of the 'search_species' tool in ListToolsRequestHandler, including name, description, and input schema definition.{ name: "search_species", description: "Search for species by common name or partial scientific name", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search term (common name or partial scientific name)", }, limit: { type: "number", description: "Maximum number of results to return (default: 20)", default: 20, }, }, required: ["query"], }, },
- src/fishbase-api.ts:51-66 (helper)Core implementation of species search: filters species data from 'species' table by matching query against scientific or common names, limits results.async searchSpecies(query: string, limit: number = 20): Promise<SpeciesData[]> { try { const speciesData = await this.queryTable('species'); const lowerQuery = query.toLowerCase(); const filtered = speciesData.filter((row: any) => { const scientificName = `${row.Genus || ''} ${row.Species || ''}`.toLowerCase(); const commonName = (row.FBname || '').toLowerCase(); return scientificName.includes(lowerQuery) || commonName.includes(lowerQuery); }).slice(0, limit); return filtered; } catch (error) { throw new Error(`Failed to search species: ${error}`); } }