Skip to main content
Glama
lundgrenalex

MCP FishBase Server

by lundgrenalex

get_ecology

Retrieve ecological data for marine species from FishBase, including habitat, diet, and environmental requirements, using scientific names.

Instructions

Get ecological information for a species

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
species_nameYesScientific name of the species

Implementation Reference

  • MCP CallToolRequest handler for the 'get_ecology' tool. It calls fishbaseAPI.getEcology with the species_name argument and returns the result as JSON-formatted text content.
    case "get_ecology":
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              await fishbaseAPI.getEcology(args.species_name as string),
              null,
              2
            ),
          },
        ],
      };
  • src/index.ts:68-81 (registration)
    Registration of the 'get_ecology' tool in the ListTools response, including its name, description, and input schema definition.
    {
      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"],
      },
    },
  • Core logic for retrieving ecology data: fetches species to get SpecCode, queries the 'ecology' table, and filters rows matching the species.
    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}`);
      }
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lundgrenalex/mcp-fishbase'

If you have feedback or need assistance with the MCP directory API, please join our Discord server