Skip to main content
Glama
linancn

TianGong-LCA-MCP Server

by linancn

OpenLCA_Impact_Assessment_Tool

Calculate life cycle impact assessments using OpenLCA to evaluate environmental impacts of product systems with specified impact methods.

Instructions

Calculate life cycle impact assessment using OpenLCA.

Input Schema

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

Implementation Reference

  • MCP tool handler that calls the LCA impact calculation helper and returns the JSON result as text content.
    async ({ productSystem, impactMethod, serverUrl }) => { const result = await calculateLcaImpacts({ productSystem: productSystem, impactMethod: impactMethod, serverUrl: serverUrl, }); return { content: [ { type: 'text', text: result, }, ], }; },
  • Input validation schema using Zod validators for productSystem, impactMethod, and serverUrl parameters.
    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'), };
  • Registration function that sets up the MCP tool with name, description, schema, and handler.
    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, }, ], }; }, ); }
  • Core helper function implementing the OpenLCA IPC communication, LCA calculation setup, execution, and result extraction as JSON.
    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); }
  • Explicit registration of the tool during MCP 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