Search_Flows_Tool
Search Life Cycle Assessment (LCA) flows data to find environmental impact information for materials and processes.
Instructions
Search LCA flows data.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Queries from user |
Implementation Reference
- src/tools/flow_hybrid_search.ts:6-8 (schema)Input schema for Search_Flows_Tool defining the required 'query' string parameter using Zod.const input_schema = { query: z.string().min(1).describe('Queries from user'), };
- src/tools/flow_hybrid_search.ts:40-55 (handler)The handler function (inline in registration) that executes the tool: invokes searchFlows helper with query and bearerKey, formats result as MCP content block.server.tool('Search_Flows_Tool', 'Search LCA flows data.', input_schema, async ({ query }) => { const result = await searchFlows( { query, }, bearerKey, ); return { content: [ { type: 'text', text: result, }, ], }; });
- Core helper implementing the search logic: POSTs query to Supabase edge function /flow_hybrid_search and returns JSON-stringified results.async function searchFlows({ query }: { query: string }, bearerKey?: string): Promise<string> { const url = `${supabase_base_url}/functions/v1/flow_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; } }
- src/_shared/init_server_http.ts:17-17 (registration)Registers the tool during MCP server initialization for HTTP transport by calling the regFlowSearchTool function.regFlowSearchTool(server, bearerKey);
- src/_shared/init_server.ts:21-21 (registration)Registers the tool during MCP server initialization by calling the regFlowSearchTool function.regFlowSearchTool(server, bearerKey);