OpenLCA_List_LCIA_Methods_Tool
Retrieve available life cycle impact assessment methods from an OpenLCA server to support environmental impact analysis in LCA studies.
Instructions
List all LCIA methods using OpenLCA.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| serverUrl | No | OpenLCA IPC server URL | http://localhost:8080 |
Implementation Reference
- Main handler logic: Connects to OpenLCA IPC server, retrieves LCIA method descriptors, formats them into objects (removing undefined fields), and returns JSON string.async function listLCIAMethods({ serverUrl = 'http://localhost:8080', }: { serverUrl?: string; }): Promise<string> { const client = o.IpcClient.on(serverUrl); const impactMethods = await client.getDescriptors(o.RefType.ImpactMethod); if (impactMethods.length === 0) { throw new Error('No LICA methods found'); } console.log(impactMethods); const resultsObj = impactMethods.map((sys) => { // Create full object const result: Record<string, any> = { id: sys.id, category: sys.category, description: sys.description, flowType: sys.flowType, location: sys.location, name: sys.name, processType: sys.processType, refUnit: sys.refUnit, refType: sys.refType, }; // Remove undefined properties Object.keys(result).forEach((key) => { if (result[key] === undefined) { delete result[key]; } }); return result; }); return JSON.stringify(resultsObj); }
- Zod schema for tool input parameters, specifically the OpenLCA server URL.const input_schema = { serverUrl: z.string().default('http://localhost:8080').describe('OpenLCA IPC server URL'), };
- src/tools/openlca_ipc_lcia_methods_list.ts:48-68 (registration)Exports the registration function that calls server.tool() to register 'OpenLCA_List_LCIA_Methods_Tool' with its description, input schema, and thin wrapper handler.export function regOpenLcaListLCIAMethodsTool(server: McpServer) { server.tool( 'OpenLCA_List_LCIA_Methods_Tool', 'List all LCIA methods using OpenLCA.', input_schema, async ({ serverUrl }) => { const result = await listLCIAMethods({ serverUrl: serverUrl, }); return { content: [ { type: 'text', text: result, }, ], }; }, ); }
- src/_shared/init_server.ts:26-26 (registration)Calls the tool registration function during MCP server initialization.regOpenLcaListLCIAMethodsTool(server);
- src/_shared/init_server_http_local.ts:16-16 (registration)Calls the tool registration function in local HTTP server initialization.regOpenLcaListLCIAMethodsTool(server);