validate_species_name
Verify and correct scientific species names using FishBase marine biology data to ensure accurate species identification and data consistency.
Instructions
Validate and correct species scientific names
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| species_name | Yes | Scientific name to validate |
Implementation Reference
- src/fishbase-api.ts:116-135 (handler)The core handler function implementing the validation logic: checks for exact species match using getSpecies, falls back to search for suggestions.
async validateSpeciesName(speciesName: string): Promise<{ valid: boolean; suggestions?: string[]; match?: SpeciesData }> { try { const exactMatch = await this.getSpecies(speciesName); if (exactMatch.length > 0) { return { valid: true, match: exactMatch[0] }; } const searchResults = await this.searchSpecies(speciesName, 5); return { valid: false, suggestions: searchResults.map(s => `${s.Genus} ${s.Species}`), }; } catch (error) { throw new Error(`Failed to validate species name: ${error}`); } } - src/index.ts:110-123 (registration)Tool registration in the MCP ListTools response, defining name, description, and input schema.
{ name: "validate_species_name", description: "Validate and correct species scientific names", inputSchema: { type: "object", properties: { species_name: { type: "string", description: "Scientific name to validate", }, }, required: ["species_name"], }, }, - src/index.ts:113-122 (schema)JSON schema defining the input parameters for the tool.
inputSchema: { type: "object", properties: { species_name: { type: "string", description: "Scientific name to validate", }, }, required: ["species_name"], }, - src/index.ts:229-241 (helper)Dispatch handler in MCP CallToolRequestHandler that calls the validateSpeciesName method with parsed arguments and formats response.
case "validate_species_name": return { content: [ { type: "text", text: JSON.stringify( await fishbaseAPI.validateSpeciesName(args.species_name as string), null, 2 ), }, ], };