Skip to main content
Glama
mattjegan

eBird MCP Server

by mattjegan

get_nearby_notable_observations

Find rare bird sightings near your location using eBird data. Specify coordinates, search radius, and time frame to discover notable observations in your area.

Instructions

Get notable/rare observations near a location.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latYesLatitude
lngYesLongitude
backNoNumber of days back to fetch
detailNoLevel of detailsimple
distNoSearch radius in kilometers
hotspotNoOnly fetch from hotspots
max_resultsNoMaximum observations to return
spp_localeNoLanguage for common namesen

Implementation Reference

  • The handler function for the 'get_nearby_notable_observations' tool. It constructs parameters from input args, calls the shared makeRequest function to fetch notable observations near the given lat/lng from the eBird API, and returns the JSON-formatted result.
    async (args) => {
      const params: Record<string, string | number | boolean> = {
        lat: args.lat,
        lng: args.lng,
        back: args.back,
        detail: args.detail,
        dist: args.dist,
        hotspot: args.hotspot,
        sppLocale: args.spp_locale,
      };
      if (args.max_results) params.maxResults = args.max_results;
    
      const result = await makeRequest("/data/obs/geo/recent/notable", params);
      return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
    }
  • Zod schema defining the input parameters for the tool, including required lat/lng, optional back days, detail level, distance radius, hotspot filter, max results, and species locale.
    {
      lat: z.number().min(-90).max(90).describe("Latitude"),
      lng: z.number().min(-180).max(180).describe("Longitude"),
      back: z.number().min(1).max(30).default(14).describe("Number of days back to fetch"),
      detail: z.enum(["simple", "full"]).default("simple").describe("Level of detail"),
      dist: z.number().min(0).max(50).default(25).describe("Search radius in kilometers"),
      hotspot: z.boolean().default(false).describe("Only fetch from hotspots"),
      max_results: z.number().min(1).max(10000).optional().describe("Maximum observations to return"),
      spp_locale: z.string().default("en").describe("Language for common names"),
    },
  • src/index.ts:221-249 (registration)
    Registration of the 'get_nearby_notable_observations' tool using McpServer.tool(), including name, description, input schema, and inline handler function.
    server.tool(
      "get_nearby_notable_observations",
      "Get notable/rare observations near a location.",
      {
        lat: z.number().min(-90).max(90).describe("Latitude"),
        lng: z.number().min(-180).max(180).describe("Longitude"),
        back: z.number().min(1).max(30).default(14).describe("Number of days back to fetch"),
        detail: z.enum(["simple", "full"]).default("simple").describe("Level of detail"),
        dist: z.number().min(0).max(50).default(25).describe("Search radius in kilometers"),
        hotspot: z.boolean().default(false).describe("Only fetch from hotspots"),
        max_results: z.number().min(1).max(10000).optional().describe("Maximum observations to return"),
        spp_locale: z.string().default("en").describe("Language for common names"),
      },
      async (args) => {
        const params: Record<string, string | number | boolean> = {
          lat: args.lat,
          lng: args.lng,
          back: args.back,
          detail: args.detail,
          dist: args.dist,
          hotspot: args.hotspot,
          sppLocale: args.spp_locale,
        };
        if (args.max_results) params.maxResults = args.max_results;
    
        const result = await makeRequest("/data/obs/geo/recent/notable", params);
        return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
      }
    );
  • Shared utility function used by all tools, including this one, to construct and make authenticated GET requests to the eBird API endpoints.
    async function makeRequest(endpoint: string, params: Record<string, string | number | boolean> = {}): Promise<unknown> {
      const url = new URL(`${BASE_URL}${endpoint}`);
      Object.entries(params).forEach(([key, value]) => {
        if (value !== undefined && value !== null) {
          url.searchParams.append(key, String(value));
        }
      });
    
      const response = await fetch(url.toString(), {
        headers: { "X-eBirdApiToken": API_KEY! },
      });
    
      if (!response.ok) {
        throw new Error(`eBird API error: ${response.status} ${response.statusText}`);
      }
    
      return response.json();
    }

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/mattjegan/ebird-mcp'

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