mineral-info
Query detailed mineral data by name, type, or elemental composition using the Macrostrat API. Access comprehensive geologic information for analysis or research purposes.
Instructions
Get information about a mineral, use one property
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| element | No | An element that the mineral is made of | |
| mineral | No | The name of the mineral | |
| mineral_type | No | The type of mineral |
Implementation Reference
- src/index.ts:1036-1051 (handler)The asynchronous handler function for the 'mineral-info' tool. It destructures input parameters, constructs query parameters, fetches data from the Macrostrat API endpoint '/defs/minerals', parses the JSON response, and returns it formatted as text content.async (request) => { const { mineral, mineral_type, element } = request; const params = new URLSearchParams(); if (mineral) params.append("mineral", mineral); if (mineral_type) params.append("mineral_type", mineral_type); if (element) params.append("element", element); const response = await fetch(`${getApiEndpoint("base")}/defs/minerals?${params}`); const data = await response.json(); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; }
- src/index.ts:1027-1035 (schema)The schema object passed to registerTool, defining the tool's title, description, and inputSchema using Zod validators for optional string parameters: mineral, mineral_type, and element.{ title: "Mineral Information", description: "Get information about a mineral, use one property", inputSchema: { mineral: z.string().optional().describe("The name of the mineral"), mineral_type: z.string().optional().describe("The type of mineral"), element: z.string().optional().describe("An element that the mineral is made of"), } },
- src/index.ts:1025-1052 (registration)The server.registerTool call that registers the 'mineral-info' tool, specifying the name, schema, and handler function.server.registerTool( "mineral-info", { title: "Mineral Information", description: "Get information about a mineral, use one property", inputSchema: { mineral: z.string().optional().describe("The name of the mineral"), mineral_type: z.string().optional().describe("The type of mineral"), element: z.string().optional().describe("An element that the mineral is made of"), } }, async (request) => { const { mineral, mineral_type, element } = request; const params = new URLSearchParams(); if (mineral) params.append("mineral", mineral); if (mineral_type) params.append("mineral_type", mineral_type); if (element) params.append("element", element); const response = await fetch(`${getApiEndpoint("base")}/defs/minerals?${params}`); const data = await response.json(); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } );