search_species
Find marine species by common name or partial scientific name using natural language queries. Retrieve species information, ecological data, and distribution records from FishBase database.
Instructions
Search for species by common name or partial scientific name
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of results to return (default: 20) | |
| query | Yes | Search term (common name or partial scientific name) |
Implementation Reference
- src/index.ts:49-67 (schema)Input schema definition for the 'search_species' MCP tool, specifying query (required string) and optional limit (number, default 20).{ 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/index.ts:173-185 (handler)MCP CallTool handler for 'search_species': extracts arguments, calls FishBaseAPI.searchSpecies, stringifies result as JSON text content.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/fishbase-api.ts:51-66 (helper)Core searchSpecies method in FishBaseAPI: queries 'species' table, filters by query matching scientific or common names (case-insensitive), limits results, returns SpeciesData array.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}`); } }