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
| Name | Required | Description | Default |
|---|---|---|---|
| endpoint | Yes | The endpoint to query | |
| parameters | Yes | parameters 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 endpointsserver.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) }] }; } );
- src/index.ts:986-998 (handler)Handler function that extracts endpoint and parameters, constructs query to Macrostrat API /defs/{endpoint}, fetches JSON response, and returns formatted text contentasync (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) }] }; }
- src/index.ts:978-985 (schema)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"), } },
- src/index.ts:648-670 (helper)Helper function getApiEndpoint used by defs handler to resolve base API URL for defs endpointsfunction 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; }