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
| 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 '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) }] }; } );
- src/index.ts:986-998 (handler)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) }] }; }
- src/index.ts:981-984 (schema)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"), }
- src/index.ts:648-670 (helper)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; }