@tiangong-lca/mcp-server 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiangong-lca/mcp-server",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "TianGong LCA MCP Server",
5
5
  "license": "MIT",
6
6
  "author": "Nan LI",
@@ -16,27 +16,28 @@
16
16
  "access": "public"
17
17
  },
18
18
  "scripts": {
19
- "build": "tsc && shx chmod +x dist/src/*.js",
19
+ "build": "shx rm -rf dist && tsc && shx cp -r public dist/ && shx chmod +x dist/src/*.js",
20
+ "build:clean": "shx rm -rf dist",
20
21
  "start": "npm run build && npx dotenv -e .env -- npx @modelcontextprotocol/inspector node dist/src/index.js",
21
- "start:server": "npm run build && concurrently \"npx dotenv -e .env -- node dist/src/index_server.js\" \"npx @modelcontextprotocol/inspector\"",
22
+ "start:server": "npm run build && concurrently \"npx dotenv -e .env -- node dist/src/index_server.js\" \"DANGEROUSLY_OMIT_AUTH=true npx @modelcontextprotocol/inspector\"",
22
23
  "lint": "prettier -c --write \"**/**.{js,jsx,tsx,ts,less,md,json}\""
23
24
  },
24
25
  "dependencies": {
25
- "olca-ipc": "^2.2.1",
26
+ "@modelcontextprotocol/sdk": "^1.15.1",
27
+ "@supabase/supabase-js": "^2.51.0",
26
28
  "@types/express": "^5.0.3",
27
- "@modelcontextprotocol/sdk": "^1.12.1",
28
- "@supabase/supabase-js": "^2.50.0",
29
- "@upstash/redis": "^1.35.0",
30
- "zod": "^3.25.57"
29
+ "@upstash/redis": "^1.35.1",
30
+ "aws-jwt-verify": "^5.1.0",
31
+ "olca-ipc": "^2.2.1",
32
+ "zod": "^3.25.76"
31
33
  },
32
34
  "devDependencies": {
33
- "@modelcontextprotocol/inspector": "^0.14.0",
35
+ "@modelcontextprotocol/inspector": "^0.16.1",
34
36
  "dotenv-cli": "^8.0.0",
35
- "prettier": "^3.5.3",
37
+ "prettier": "^3.6.2",
36
38
  "prettier-plugin-organize-imports": "^4.1.0",
37
39
  "shx": "^0.4.0",
38
- "supergateway": "^3.1.0",
39
- "tsx": "^4.19.4",
40
+ "tsx": "^4.20.3",
40
41
  "typescript": "^5.8.3"
41
42
  }
42
43
  }
@@ -1,22 +0,0 @@
1
- const cleanObject = (obj) => {
2
- if (Array.isArray(obj)) {
3
- return obj
4
- .map((v) => (typeof v === 'object' ? cleanObject(v) : v))
5
- .filter((v) => v !== undefined && v !== null);
6
- }
7
- else if (typeof obj === 'object' && obj !== null) {
8
- const cleanedObj = Object.entries(obj)
9
- .map(([k, v]) => [k, cleanObject(v)])
10
- .reduce((acc, [k, v]) => {
11
- if (v !== undefined &&
12
- v !== null &&
13
- (typeof v !== 'object' || (typeof v === 'object' && Object.keys(v).length > 0))) {
14
- acc[k] = v;
15
- }
16
- return acc;
17
- }, {});
18
- return cleanedObj;
19
- }
20
- return obj;
21
- };
22
- export default cleanObject;
@@ -1,4 +0,0 @@
1
- export const base_url = process.env.BASE_URL ?? '';
2
- export const supabase_anon_key = process.env.SUPABASE_ANON_KEY ?? '';
3
- export const x_api_key = process.env.X_API_KEY ?? '';
4
- export const x_region = process.env.X_REGION ?? '';
@@ -1 +0,0 @@
1
- export {};
@@ -1,57 +0,0 @@
1
- import * as o from 'olca-ipc';
2
- import { z } from 'zod';
3
- const input_schema = {
4
- systemProcess: z.string().min(1).describe('OpenLCA product system ID'),
5
- impactMethod: z.string().min(1).describe('OpenLCA impact method ID'),
6
- serverUrl: z.string().default('http://localhost:8080').describe('OpenLCA IPC server URL'),
7
- };
8
- async function calculateLcaImpacts({ systemProcess, impactMethod, serverUrl = 'http://localhost:8080', }) {
9
- if (!systemProcess) {
10
- throw new Error('No systemProcess provided');
11
- }
12
- if (!impactMethod) {
13
- throw new Error('No impactMethod provided');
14
- }
15
- const client = o.IpcClient.on(serverUrl);
16
- const selectedSystemProcess = await client.get(o.RefType.ProductSystem, systemProcess);
17
- if (!selectedSystemProcess)
18
- throw new Error('Product system not found');
19
- const selectedMethod = await client.get(o.RefType.ImpactMethod, impactMethod);
20
- if (!selectedMethod)
21
- throw new Error('Impact method not found');
22
- console.log('Calculating LCA impacts...');
23
- const setup = o.CalculationSetup.of({
24
- target: selectedSystemProcess,
25
- impactMethod: selectedMethod,
26
- });
27
- const result = await client.calculate(setup);
28
- const state = await result.untilReady();
29
- if (state.error) {
30
- throw new Error(`Calculation failed: ${state.error}`);
31
- }
32
- const impacts = await result.getTotalImpacts();
33
- const resultsObj = impacts.map((impact) => ({
34
- name: impact.impactCategory?.name,
35
- value: impact.amount,
36
- unit: impact.impactCategory?.refUnit,
37
- }));
38
- result.dispose();
39
- return JSON.stringify(resultsObj);
40
- }
41
- export function regOpenLcaTool(server) {
42
- server.tool('OpenLCA_Impact_Assessment_Tool', 'Calculate life cycle impact assessment using OpenLCA.', input_schema, async ({ systemProcess, impactMethod, serverUrl }) => {
43
- const result = await calculateLcaImpacts({
44
- systemProcess: systemProcess,
45
- impactMethod: impactMethod,
46
- serverUrl: serverUrl,
47
- });
48
- return {
49
- content: [
50
- {
51
- type: 'text',
52
- text: result,
53
- },
54
- ],
55
- };
56
- });
57
- }