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
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | the 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) }] }; } );
- src/index.ts:1010-1022 (handler)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) }] }; }
- src/index.ts:1006-1009 (schema)Input schema for 'defs-autocomplete' tool using Zod: requires a 'query' string parameter.inputSchema: { query: z.string().describe("the search term"), } },
- src/index.ts:648-670 (helper)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; }