Skip to main content
Glama
blake365

Macrostrat MCP Server

by blake365

defs

Query standardized geologic dictionaries and fields from Macrostrat, including lithologies, structures, minerals, timescales, and stratigraphic data through API endpoints.

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 MCP tool named 'defs' which provides access to Macrostrat definitions endpoints
    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 that extracts endpoint and parameters, constructs query to Macrostrat API /defs/{endpoint}, fetches JSON response, and returns 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) }] }; }
  • Tool metadata including title, description, and Zod input schema defining 'endpoint' enum and 'parameters' string
    { 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"), } },
  • Helper function getApiEndpoint used by defs handler to resolve base API URL for defs endpoints
    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