@tiangong-lca/mcp-server 0.0.12 → 0.0.14
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/README.md
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { regOpenLcaPrompts } from '../prompts/lca_calculation.js';
|
|
3
|
+
import { regOpenLcaResources } from '../resources/lca_calculation.js';
|
|
4
|
+
import { regOpenLcaLciaTool } from '../tools/openlca_ipc_lcia.js';
|
|
5
|
+
import { regOpenLcaListLCIAMethodsTool } from '../tools/openlca_ipc_lcia_methods_list.js';
|
|
6
|
+
import { regOpenLcaListSystemProcessTool } from '../tools/openlca_ipc_process_list.js';
|
|
7
|
+
export function initializeServer() {
|
|
8
|
+
const server = new McpServer({
|
|
9
|
+
name: 'TianGong-LCA-MCP-Server',
|
|
10
|
+
version: '1.0.0',
|
|
11
|
+
});
|
|
12
|
+
regOpenLcaLciaTool(server);
|
|
13
|
+
regOpenLcaListLCIAMethodsTool(server);
|
|
14
|
+
regOpenLcaListSystemProcessTool(server);
|
|
15
|
+
regOpenLcaPrompts(server);
|
|
16
|
+
regOpenLcaResources(server);
|
|
17
|
+
return server;
|
|
18
|
+
}
|
|
19
|
+
export function getServer() {
|
|
20
|
+
return initializeServer();
|
|
21
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
3
|
+
import express from 'express';
|
|
4
|
+
import { getServer } from './_shared/init_server_http_local.js';
|
|
5
|
+
const app = express();
|
|
6
|
+
app.use((req, res, next) => {
|
|
7
|
+
res.header('Access-Control-Allow-Origin', '*');
|
|
8
|
+
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
|
9
|
+
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
|
10
|
+
if (req.method === 'OPTIONS') {
|
|
11
|
+
res.sendStatus(200);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
next();
|
|
15
|
+
});
|
|
16
|
+
app.post('/mcp', async (req, res) => {
|
|
17
|
+
try {
|
|
18
|
+
const server = getServer();
|
|
19
|
+
const transport = new StreamableHTTPServerTransport({
|
|
20
|
+
sessionIdGenerator: undefined,
|
|
21
|
+
});
|
|
22
|
+
await server.connect(transport);
|
|
23
|
+
await transport.handleRequest(req, res, req.body);
|
|
24
|
+
res.on('close', () => {
|
|
25
|
+
console.log('Request closed');
|
|
26
|
+
transport.close();
|
|
27
|
+
server.close();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.error('Error handling MCP request:', error);
|
|
32
|
+
if (!res.headersSent) {
|
|
33
|
+
res.status(500).json({
|
|
34
|
+
jsonrpc: '2.0',
|
|
35
|
+
error: {
|
|
36
|
+
code: -32603,
|
|
37
|
+
message: 'Internal server error',
|
|
38
|
+
},
|
|
39
|
+
id: null,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
app.get('/mcp', async (req, res) => {
|
|
45
|
+
console.log('Received GET MCP request');
|
|
46
|
+
res.writeHead(405).end(JSON.stringify({
|
|
47
|
+
jsonrpc: '2.0',
|
|
48
|
+
error: {
|
|
49
|
+
code: -32000,
|
|
50
|
+
message: 'Method not allowed.',
|
|
51
|
+
},
|
|
52
|
+
id: null,
|
|
53
|
+
}));
|
|
54
|
+
});
|
|
55
|
+
app.delete('/mcp', async (req, res) => {
|
|
56
|
+
console.log('Received DELETE MCP request');
|
|
57
|
+
res.writeHead(405).end(JSON.stringify({
|
|
58
|
+
jsonrpc: '2.0',
|
|
59
|
+
error: {
|
|
60
|
+
code: -32000,
|
|
61
|
+
message: 'Method not allowed.',
|
|
62
|
+
},
|
|
63
|
+
id: null,
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
66
|
+
app.get('/health', async (req, res) => {
|
|
67
|
+
console.log('Health check requested');
|
|
68
|
+
res.status(200).json({
|
|
69
|
+
status: 'ok',
|
|
70
|
+
timestamp: new Date().toISOString(),
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
const PORT = Number(process.env.PORT ?? 9278);
|
|
74
|
+
const HOST = process.env.HOST ?? '0.0.0.0';
|
|
75
|
+
app.listen(PORT, HOST, () => {
|
|
76
|
+
console.log(`MCP Stateless Streamable HTTP Server listening on port ${PORT}`);
|
|
77
|
+
});
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiangong-lca/mcp-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "TianGong LCA MCP Server",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Nan LI",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|
|
9
9
|
"tiangong-lca-mcp-stdio": "dist/src/index.js",
|
|
10
|
-
"tiangong-lca-mcp-http": "dist/src/index_server.js"
|
|
10
|
+
"tiangong-lca-mcp-http": "dist/src/index_server.js",
|
|
11
|
+
"tiangong-lca-mcp-http-local": "dist/src/index_server_local.js"
|
|
11
12
|
},
|
|
12
13
|
"files": [
|
|
13
14
|
"dist"
|
|
@@ -20,19 +21,20 @@
|
|
|
20
21
|
"build:clean": "shx rm -rf dist",
|
|
21
22
|
"start": "npm run build && npx dotenv -e .env -- npx @modelcontextprotocol/inspector node dist/src/index.js",
|
|
22
23
|
"start:server": "npm run build && concurrently \"npx dotenv -e .env -- node dist/src/index_server.js\" \"DANGEROUSLY_OMIT_AUTH=true npx @modelcontextprotocol/inspector\"",
|
|
24
|
+
"start:server-local": "npm run build && concurrently \"npx dotenv -e .env -- node dist/src/index_server_local.js\" \"DANGEROUSLY_OMIT_AUTH=true npx @modelcontextprotocol/inspector\"",
|
|
23
25
|
"lint": "prettier -c --write \"**/**.{js,jsx,tsx,ts,less,md,json}\""
|
|
24
26
|
},
|
|
25
27
|
"dependencies": {
|
|
26
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
27
|
-
"@supabase/supabase-js": "^2.
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.17.1",
|
|
29
|
+
"@supabase/supabase-js": "^2.53.0",
|
|
28
30
|
"@types/express": "^5.0.3",
|
|
29
|
-
"@upstash/redis": "^1.35.
|
|
31
|
+
"@upstash/redis": "^1.35.3",
|
|
30
32
|
"aws-jwt-verify": "^5.1.0",
|
|
31
33
|
"olca-ipc": "^2.2.1",
|
|
32
34
|
"zod": "^3.25.76"
|
|
33
35
|
},
|
|
34
36
|
"devDependencies": {
|
|
35
|
-
"@modelcontextprotocol/inspector": "^0.16.
|
|
37
|
+
"@modelcontextprotocol/inspector": "^0.16.2",
|
|
36
38
|
"dotenv-cli": "^8.0.0",
|
|
37
39
|
"prettier": "^3.6.2",
|
|
38
40
|
"prettier-plugin-organize-imports": "^4.1.0",
|