@tiangong-lca/mcp-server 0.0.2 → 0.0.3

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  [中文](./README.md) | [English](./README_EN.md)
4
4
 
5
- TianGong LCA Model Context Protocol (MCP) Server 支持 STDIO 和 SSE 两种协议。
5
+ TianGong LCA Model Context Protocol (MCP) Server 支持 STDIO SSE StreamableHttp 三种协议。
6
6
 
7
7
  ## 启动 MCP 服务器
8
8
 
@@ -23,7 +23,7 @@ npm install -g supergateway
23
23
 
24
24
  npx dotenv -e .env -- \
25
25
  npx -y supergateway \
26
- --stdio "npx -y @tiangong-lca/mcp-server" \
26
+ --stdio "npx -y -p @tiangong-lca/mcp-server tiangong-lca-mcp-stdio" \
27
27
  --port 3001 \
28
28
  --ssePath /sse --messagePath /message
29
29
  ```
@@ -84,13 +84,10 @@ npm start
84
84
  # 打包当前项目
85
85
  npm run build && npm pack
86
86
 
87
- # 如果需要可以全局安装 supergateway(可选)
88
- npm install -g supergateway
89
-
90
87
  # 启动 SSE 服务器,如配置了参数 --baseUrl ,应设置为有效的 IP 地址或域名
91
88
  npx dotenv -e .env -- \
92
89
  npx -y supergateway \
93
- --stdio "npx -y tiangong-lca-mcp-server-0.0.1.tgz" \
90
+ --stdio "npx -y -p tiangong-lca-mcp-server-0.0.3.tgz tiangong-lca-mcp-stdio" \
94
91
  --port 3001 \
95
92
  --ssePath /sse \
96
93
  --messagePath /message
@@ -1,6 +1,7 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import { regFlowSearchTool } from '../tools/flow_hybrid_search.js';
3
3
  import { regProcessSearchTool } from '../tools/process_hybrid_search.js';
4
+ import { regBomCalculationTool } from '../tools/bom_calculation.js';
4
5
  export function initializeServer() {
5
6
  const server = new McpServer({
6
7
  name: 'TianGong-MCP-Server',
@@ -8,6 +9,9 @@ export function initializeServer() {
8
9
  });
9
10
  regFlowSearchTool(server);
10
11
  regProcessSearchTool(server);
12
+ regBomCalculationTool(server);
11
13
  return server;
12
14
  }
13
- export const server = initializeServer();
15
+ export function getServer() {
16
+ return initializeServer();
17
+ }
package/dist/src/index.js CHANGED
@@ -1,15 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
2
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
- import { regFlowSearchTool } from './tools/flow_hybrid_search.js';
5
- import { regProcessSearchTool } from './tools/process_hybrid_search.js';
6
- const server = new McpServer({
7
- name: 'TianGong-MCP-Server',
8
- version: '1.0.0',
9
- });
10
- regFlowSearchTool(server);
11
- regProcessSearchTool(server);
3
+ import { getServer } from './_shared/init_server.js';
12
4
  async function runServer() {
5
+ const server = getServer();
13
6
  const transport = new StdioServerTransport();
14
7
  await server.connect(transport);
15
8
  }
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
3
3
  import express from 'express';
4
- import { server } from './_shared/init_server.js';
4
+ import { getServer } from './_shared/init_server.js';
5
5
  const app = express();
6
6
  app.use(express.json());
7
7
  app.post('/mcp', async (req, res) => {
8
8
  try {
9
+ const server = getServer();
9
10
  const transport = new StreamableHTTPServerTransport({
10
11
  sessionIdGenerator: undefined,
11
12
  });
@@ -0,0 +1,29 @@
1
+ import { z } from 'zod';
2
+ const input_schema = {
3
+ a: z.number().min(1).describe('The first number'),
4
+ b: z.number().min(1).describe('The second number'),
5
+ };
6
+ async function calculation({ a, b }) {
7
+ try {
8
+ return a + b;
9
+ }
10
+ catch (error) {
11
+ console.error('Error making the request:', error);
12
+ throw error;
13
+ }
14
+ }
15
+ export function regBomCalculationTool(server) {
16
+ server.tool('BOM_Calculation', 'Calculate sum of two numbers.', input_schema, async ({ a, b }) => {
17
+ const result = await calculation({
18
+ a, b,
19
+ });
20
+ return {
21
+ content: [
22
+ {
23
+ type: 'text',
24
+ text: result.toString(),
25
+ },
26
+ ],
27
+ };
28
+ });
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiangong-lca/mcp-server",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "TianGong LCA MCP Server",
5
5
  "license": "MIT",
6
6
  "author": "Nan LI",
@@ -18,17 +18,17 @@
18
18
  "scripts": {
19
19
  "build": "tsc && shx chmod +x dist/src/*.js",
20
20
  "start": "npm run build && npx dotenv -e .env -- npx @modelcontextprotocol/inspector node dist/src/index.js",
21
- "start:server": "npm run build && npx dotenv -e .env -- node dist/src/index_server.js",
21
+ "start:server": "npm run build && concurrently \"npx dotenv -e .env -- node dist/src/index_server.js\" \"npx @modelcontextprotocol/inspector\"",
22
22
  "lint": "prettier -c --write \"**/**.{js,jsx,tsx,ts,less,md,json}\""
23
23
  },
24
24
  "dependencies": {
25
- "@types/express": "^5.0.1",
26
- "@modelcontextprotocol/sdk": "^1.10.2",
25
+ "@types/express": "^5.0.2",
26
+ "@modelcontextprotocol/sdk": "^1.11.4",
27
27
  "@supabase/supabase-js": "^2.49.4",
28
- "zod": "^3.24.3"
28
+ "zod": "^3.24.4"
29
29
  },
30
30
  "devDependencies": {
31
- "@modelcontextprotocol/inspector": "^0.10.2",
31
+ "@modelcontextprotocol/inspector": "^0.12.0",
32
32
  "dotenv-cli": "^8.0.0",
33
33
  "prettier": "^3.5.3",
34
34
  "prettier-plugin-organize-imports": "^4.1.0",