Skip to main content
Glama
linancn

TianGong-LCA-MCP Server

by linancn

OpenLCA_Impact_Assessment_Tool

Perform life cycle impact assessments by analyzing product systems and impact methods using OpenLCA within the TianGong-LCA-MCP Server environment.

Instructions

Calculate life cycle impact assessment using OpenLCA.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
impactMethodYesOpenLCA impact method ID
serverUrlNoOpenLCA IPC server URLhttp://localhost:8080
systemProcessYesOpenLCA product system ID

Implementation Reference

  • Defines the Zod input schema for the OpenLCA_Impact_Assessment_Tool, specifying parameters for product system ID, impact method ID, and optional server URL.
    const input_schema = { productSystem: z.string().min(1).describe('OpenLCA product system ID'), impactMethod: z.string().min(1).describe('OpenLCA impact method ID'), serverUrl: z.string().default('http://localhost:8080').describe('OpenLCA IPC server URL'), };
  • Core handler function that executes the LCA impact assessment by connecting to OpenLCA IPC server, fetching product system and impact method, performing calculation, and returning JSON results.
    async function calculateLcaImpacts({ productSystem, impactMethod, serverUrl = 'http://localhost:8080', }: { productSystem: string; impactMethod: string; serverUrl?: string; }): Promise<string> { if (!productSystem) { throw new Error('No productSystem provided'); } if (!impactMethod) { throw new Error('No impactMethod provided'); } const client = o.IpcClient.on(serverUrl); const selectedProductSystem = await client.get(o.RefType.ProductSystem, productSystem); if (!selectedProductSystem) throw new Error('Product system not found'); // Get impact method const selectedMethod = await client.get(o.RefType.ImpactMethod, impactMethod); if (!selectedMethod) throw new Error('Impact method not found'); // Calculate the system console.log('Calculating LCA impacts...'); const setup = o.CalculationSetup.of({ target: selectedProductSystem as o.Ref, impactMethod: selectedMethod as o.Ref, }); const result = await client.calculate(setup); const state = await result.untilReady(); if (state.error) { throw new Error(`Calculation failed: ${state.error}`); } // Query the result const impacts = await result.getTotalImpacts(); const resultsObj = impacts.map((impact) => ({ name: impact.impactCategory?.name, value: impact.amount, unit: impact.impactCategory?.refUnit, })); // Dispose the result result.dispose(); return JSON.stringify(resultsObj); }
  • Registers the 'OpenLCA_Impact_Assessment_Tool' with the MCP server, providing name, description, input schema, and handler wrapper that calls the core calculateLcaImpacts function.
    export function regOpenLcaLciaTool(server: McpServer) { server.tool( 'OpenLCA_Impact_Assessment_Tool', 'Calculate life cycle impact assessment using OpenLCA.', input_schema, async ({ productSystem, impactMethod, serverUrl }) => { const result = await calculateLcaImpacts({ productSystem: productSystem, impactMethod: impactMethod, serverUrl: serverUrl, }); return { content: [ { type: 'text', text: result, }, ], }; }, ); }
  • Top-level call to register the OpenLCA_Impact_Assessment_Tool during server initialization.
    regOpenLcaLciaTool(server);
  • Top-level call to register the OpenLCA_Impact_Assessment_Tool in local HTTP server initialization.
    regOpenLcaLciaTool(server);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/linancn/tiangong-lca-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server