Search_Life_Cycle_Models_Tool
Search life cycle assessment (LCA) models data to find environmental impact models for sustainability analysis and decision-making.
Instructions
Search LCA life cycle models data.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Queries from user |
Implementation Reference
- The tool handler function passed to server.tool. It calls the searchLifecycleModels helper with the query and bearerKey, then returns the JSON result as text content in the MCP response format.
async ({ query }) => { const result = await searchLifecycleModels( { query, }, bearerKey, ); return { content: [ { type: 'text', text: result, }, ], }; }, - Zod input schema defining the 'query' parameter as a non-empty string.
const input_schema = { query: z.string().min(1).describe('Queries from user'), }; - src/tools/life_cycle_model_hybrid_search.ts:42-64 (registration)The registration function that calls server.tool to register 'Search_Life_Cycle_Models_Tool' with its name, description, input schema, and handler. This function is called during server initialization.
export function regLifecycleModelSearchTool(server: McpServer, bearerKey?: string): void { server.tool( 'Search_Life_Cycle_Models_Tool', 'Search LCA life cycle models data.', input_schema, async ({ query }) => { const result = await searchLifecycleModels( { query, }, bearerKey, ); return { content: [ { type: 'text', text: result, }, ], }; }, ); } - Core helper function that performs a POST request to the Supabase edge function '/functions/v1/lifecyclemodel_hybrid_search' with the query, using bearerKey for auth, and returns the JSON-stringified response.
async function searchLifecycleModels( { query }: { query: string }, bearerKey?: string, ): Promise<string> { const url = `${supabase_base_url}/functions/v1/lifecyclemodel_hybrid_search`; // console.error('Headers:', headers); try { const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${bearerKey}`, 'x-region': x_region, }, body: JSON.stringify( cleanObject({ query, }), ), }); if (!response.ok) { throw new Error(`HTTP error: ${response.status} ${response.statusText}`); } const data = await response.json(); return JSON.stringify(data); } catch (error) { console.error('Error making the request:', error); throw error; } }