Search_flows_Tool
Query and retrieve Life Cycle Assessment (LCA) flows data efficiently using a structured approach supported by the TianGong-LCA-MCP Server.
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)Zod input schema for the Search_Flows_Tool, requiring a 'query' string.const input_schema = { query: z.string().min(1).describe('Queries from user'), };
- Helper function that performs the hybrid search by POSTing the query to a Supabase edge function and returns JSON string of 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/tools/flow_hybrid_search.ts:40-55 (handler)Inline handler function for Search_Flows_Tool that calls the searchFlows helper and formats the result as MCP text content.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, }, ], }; });
- src/tools/flow_hybrid_search.ts:39-56 (registration)Registration function regFlowSearchTool that sets up the Search_Flows_Tool on the MCP server.export function regFlowSearchTool(server: McpServer, bearerKey?: string): void { 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, }, ], }; }); }
- src/_shared/init_server.ts:21-21 (registration)Invocation of tool registration during MCP server initialization.regFlowSearchTool(server, bearerKey);