OpenLCA_List_LCIA_Methods_Tool
Retrieve a comprehensive list of LCIA methods from OpenLCA. Ideal for TianGong-LCA-MCP Server users to access environmental impact assessment data efficiently.
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
- Core handler logic that connects to the OpenLCA IPC server, fetches LCIA method descriptors, processes them into a clean object array, and returns a 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, defining the optional serverUrl.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)Registration function that registers the tool on the MCP server using server.tool, specifying name, description, input schema, and execution 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)Invocation of the tool registration during general server initialization.regOpenLcaListLCIAMethodsTool(server);
- src/_shared/init_server_http_local.ts:16-16 (registration)Invocation of the tool registration during HTTP local server initialization.regOpenLcaListLCIAMethodsTool(server);