get_ecology
Retrieve detailed ecological data for a species by submitting its scientific name. Access species-specific information to support marine biology research and analysis via the MCP FishBase Server.
Instructions
Get ecological information for a species
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| species_name | Yes | Scientific name of the species |
Implementation Reference
- src/index.ts:187-199 (handler)MCP tool handler for 'get_ecology': calls FishBaseAPI.getEcology and returns JSON-formatted response.case "get_ecology": return { content: [ { type: "text", text: JSON.stringify( await fishbaseAPI.getEcology(args.species_name as string), null, 2 ), }, ], };
- src/index.ts:71-80 (schema)Input schema definition for the get_ecology tool, specifying required 'species_name' parameter.inputSchema: { type: "object", properties: { species_name: { type: "string", description: "Scientific name of the species", }, }, required: ["species_name"], },
- src/index.ts:68-81 (registration)Registration of the 'get_ecology' tool in the MCP server's tool list, including description and schema.{ name: "get_ecology", description: "Get ecological information for a species", inputSchema: { type: "object", properties: { species_name: { type: "string", description: "Scientific name of the species", }, }, required: ["species_name"], }, },
- src/fishbase-api.ts:68-82 (helper)Core implementation of getEcology: retrieves species code then filters ecology table data.async getEcology(speciesName: string): Promise<any[]> { try { const speciesData = await this.getSpecies(speciesName); if (speciesData.length === 0) { throw new Error(`Species not found: ${speciesName}`); } const specCode = speciesData[0].SpecCode; const ecoData = await this.queryTable('ecology'); return ecoData.filter((row: any) => row.SpecCode === specCode); } catch (error) { throw new Error(`Failed to get ecology data: ${error}`); } }