get_distribution
Retrieve species distribution and occurrence data by entering the scientific name. Access accurate marine biology information through the MCP FishBase Server.
Instructions
Get distribution/occurrence information for a species
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| species_name | Yes | Scientific name of the species |
Implementation Reference
- src/fishbase-api.ts:84-98 (handler)Core handler function that implements the get_distribution tool logic by retrieving the species SpecCode and filtering the 'occurrence' table for distribution data.async getDistribution(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 distData = await this.queryTable('occurrence'); return distData.filter((row: any) => row.SpecCode === specCode); } catch (error) { throw new Error(`Failed to get distribution data: ${error}`); } }
- src/index.ts:82-95 (registration)Registration of the 'get_distribution' tool, including name, description, and input schema, in the MCP server's list of tools.{ name: "get_distribution", description: "Get distribution/occurrence information for a species", inputSchema: { type: "object", properties: { species_name: { type: "string", description: "Scientific name of the species", }, }, required: ["species_name"], }, },
- src/index.ts:201-213 (handler)MCP server dispatch handler for the 'get_distribution' tool call, which invokes fishbaseAPI.getDistribution and formats the response.case "get_distribution": return { content: [ { type: "text", text: JSON.stringify( await fishbaseAPI.getDistribution(args.species_name as string), null, 2 ), }, ], };
- src/index.ts:85-94 (schema)Input schema definition for the 'get_distribution' tool, specifying the required 'species_name' parameter.inputSchema: { type: "object", properties: { species_name: { type: "string", description: "Scientific name of the species", }, }, required: ["species_name"], },