Skip to main content
Glama
blake365

Macrostrat MCP Server

by blake365

defs-autocomplete

Retrieve geological definitions by entering search terms to access comprehensive geologic data from the Macrostrat API.

Instructions

Quickly retrieve all definitions matching a query. Limited to 100 results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesthe search term

Implementation Reference

  • src/index.ts:1001-1024 (registration)
    Registration of the 'defs-autocomplete' tool, including title, description, input schema, and inline handler function that fetches autocomplete results from the Macrostrat /defs/autocomplete endpoint.
    server.registerTool(
      "defs-autocomplete",
      {
        title: "Definitions Autocomplete",
        description: "Quickly retrieve all definitions matching a query. Limited to 100 results",
        inputSchema: {
          query: z.string().describe("the search term"),
        }
      },
      async (request) => {
        const { query } = request;
        const params = new URLSearchParams({ query });
        const response = await fetch(`${getApiEndpoint("base")}/defs/autocomplete?${params}`);
        const data = await response.json();
    
        return {
          content: [{
            type: "text" as const,
            text: JSON.stringify(data, null, 2)
          }]
        };
      }
    );
  • Handler function for 'defs-autocomplete' tool: extracts query param, fetches from Macrostrat API /defs/autocomplete endpoint, returns JSON response as text content.
    async (request) => {
      const { query } = request;
      const params = new URLSearchParams({ query });
      const response = await fetch(`${getApiEndpoint("base")}/defs/autocomplete?${params}`);
      const data = await response.json();
    
      return {
        content: [{
          type: "text" as const,
          text: JSON.stringify(data, null, 2)
        }]
      };
    }
  • Input schema for 'defs-autocomplete' tool using Zod: requires a 'query' string parameter.
      inputSchema: {
        query: z.string().describe("the search term"),
      }
    },
  • Helper function getApiEndpoint used by the tool handler to resolve the base Macrostrat API URL ('base' type).
    function getApiEndpoint(type: "mapUnits" | "units" | "columns" | "base"): string {
      const endpoint = ROOTS.find((root) => {
        if (root.type !== "api") return false;
        switch (type) {
          case "mapUnits":
            return root.uri === "https://macrostrat.org/api/geologic_units/map";
          case "units":
            return root.uri === "https://macrostrat.org/api/units";
          case "columns":
            return root.uri === "https://macrostrat.org/api/columns";
          case "base":
            return root.uri === "https://macrostrat.org/api";
          default:
            return false;
        }
      });
    
      if (!endpoint) {
        throw new Error(`API endpoint not found for type: ${type}`);
      }
    
      return endpoint.uri;
    }

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/blake365/macrostrat-mcp'

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