Skip to main content
Glama
blake365

Macrostrat MCP Server

by blake365

defs

Query geologic data such as lithologies, minerals, timescales, and stratigraphic units via the Macrostrat API. Access standard fields and dictionaries for detailed analysis.

Instructions

Routes giving access to standard fields and dictionaries used in Macrostrat

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endpointYesThe endpoint to query
parametersYesparameters to pass to the endpoint

Implementation Reference

  • src/index.ts:976-999 (registration)
    Registration of the 'defs' tool, including title, description, input schema, and the handler function that proxies requests to Macrostrat /defs/{endpoint} API.
    server.registerTool( "defs", { title: "Definitions", description: "Routes giving access to standard fields and dictionaries used in Macrostrat", inputSchema: { endpoint: z.enum(["lithologies", "structures", "columns", "econs", "minerals", "timescales", "environments", "strat_names", "measurements", "intervals"]).describe("The endpoint to query"), parameters: z.string().describe("parameters to pass to the endpoint"), } }, async (request) => { const { endpoint, parameters } = request; const params = new URLSearchParams(parameters); const response = await fetch(`${getApiEndpoint("base")}/defs/${endpoint}?${params}`); const data = await response.json(); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } );
  • Handler function for 'defs' tool: extracts endpoint and parameters, constructs query to Macrostrat API defs endpoint, fetches JSON data, and returns it as formatted text content.
    async (request) => { const { endpoint, parameters } = request; const params = new URLSearchParams(parameters); const response = await fetch(`${getApiEndpoint("base")}/defs/${endpoint}?${params}`); const data = await response.json(); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; }
  • Input schema validation for the 'defs' tool using Zod: requires 'endpoint' from predefined enum of defs sub-endpoints and 'parameters' as string.
    inputSchema: { endpoint: z.enum(["lithologies", "structures", "columns", "econs", "minerals", "timescales", "environments", "strat_names", "measurements", "intervals"]).describe("The endpoint to query"), parameters: z.string().describe("parameters to pass to the endpoint"), }
  • Helper function getApiEndpoint used by defs handler to resolve the base Macrostrat API URL (https://macrostrat.org/api).
    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; }

Other Tools

Related Tools

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