@tiangong-lca/mcp-server 0.0.4 → 0.0.5

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
@@ -40,7 +40,7 @@ docker pull linancn/tiangong-lca-mcp-server:0.0.1
40
40
  # Start MCP server using Docker
41
41
  docker run -d \
42
42
  --name tiangong-lca-mcp-server \
43
- --publish 3001:80 \
43
+ --publish 9278:9278 \
44
44
  --env-file .env \
45
45
  linancn/tiangong-lca-mcp-server:0.0.1
46
46
  ```
@@ -2,9 +2,41 @@
2
2
  import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
3
3
  import express from 'express';
4
4
  import { getServer } from './_shared/init_server.js';
5
+ const BEARER_KEY = process.env.BEARER_KEY;
6
+ const authenticateBearer = (req, res, next) => {
7
+ if (!BEARER_KEY) {
8
+ next();
9
+ return;
10
+ }
11
+ const authHeader = req.headers.authorization;
12
+ if (!authHeader || !authHeader.startsWith('Bearer ')) {
13
+ res.status(401).json({
14
+ jsonrpc: '2.0',
15
+ error: {
16
+ code: -32001,
17
+ message: 'Missing or invalid authorization header',
18
+ },
19
+ id: null,
20
+ });
21
+ return;
22
+ }
23
+ const token = authHeader.substring(7);
24
+ if (token !== BEARER_KEY) {
25
+ res.status(403).json({
26
+ jsonrpc: '2.0',
27
+ error: {
28
+ code: -32002,
29
+ message: 'Invalid bearer token',
30
+ },
31
+ id: null,
32
+ });
33
+ return;
34
+ }
35
+ next();
36
+ };
5
37
  const app = express();
6
38
  app.use(express.json());
7
- app.post('/mcp', async (req, res) => {
39
+ app.post('/mcp', authenticateBearer, async (req, res) => {
8
40
  try {
9
41
  const server = getServer();
10
42
  const transport = new StreamableHTTPServerTransport({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiangong-lca/mcp-server",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "TianGong LCA MCP Server",
5
5
  "license": "MIT",
6
6
  "author": "Nan LI",
@@ -25,16 +25,16 @@
25
25
  "olca-ipc": "^2.2.1",
26
26
  "@types/express": "^5.0.2",
27
27
  "@modelcontextprotocol/sdk": "^1.12.1",
28
- "@supabase/supabase-js": "^2.49.8",
29
- "zod": "^3.25.42"
28
+ "@supabase/supabase-js": "^2.49.10",
29
+ "zod": "^3.25.51"
30
30
  },
31
31
  "devDependencies": {
32
- "@modelcontextprotocol/inspector": "^0.13.0",
32
+ "@modelcontextprotocol/inspector": "^0.14.0",
33
33
  "dotenv-cli": "^8.0.0",
34
34
  "prettier": "^3.5.3",
35
35
  "prettier-plugin-organize-imports": "^4.1.0",
36
36
  "shx": "^0.4.0",
37
- "supergateway": "^3.0.1",
37
+ "supergateway": "^3.1.0",
38
38
  "tsx": "^4.19.4",
39
39
  "typescript": "^5.8.3"
40
40
  }