OpenLCA_List_System_Processes_Tool
Retrieve and list all system processes from an OpenLCA IPC server to support Life Cycle Assessment (LCA) applications within the TianGong-LCA-MCP Server environment.
Instructions
List all system processes using OpenLCA.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| serverUrl | No | OpenLCA IPC server URL | http://localhost:8080 |
Implementation Reference
- Core handler function that connects to OpenLCA IPC server, fetches process descriptors, filters system processes (LCI_RESULT), constructs result objects, and returns JSON string.async function listSystemProcesses({ serverUrl = 'http://localhost:8080', }: { serverUrl?: string; }): Promise<string> { const client = o.IpcClient.on(serverUrl); const processes = await client.getDescriptors(o.RefType.Process); const systemProcesses = processes.filter((proc) => proc.processType === o.ProcessType.LCI_RESULT); if (systemProcesses.length === 0) { throw new Error('No system processes found'); } const resultsObj = systemProcesses.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 input schema defining the serverUrl parameter with default value.const input_schema = { serverUrl: z.string().default('http://localhost:8080').describe('OpenLCA IPC server URL'), };
- src/tools/openlca_ipc_system_processes_list.ts:49-69 (registration)Registers the MCP tool 'OpenLCA_List_System_Processes_Tool' with the server, providing name, description, input schema, and thin wrapper handler that calls the core logic and formats MCP response.export function regOpenLcaListSystemProcessesTool(server: McpServer) { server.tool( 'OpenLCA_List_System_Processes_Tool', 'List all system processes using OpenLCA.', input_schema, async ({ serverUrl }) => { const result = await listSystemProcesses({ serverUrl: serverUrl, }); return { content: [ { type: 'text', text: result, }, ], }; }, ); }