cls-mcp-server 0.1.0 → 0.2.1
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 +59 -5
- package/dist/index.js +36 -12
- package/package.json +5 -3
package/README.md
CHANGED
@@ -10,7 +10,9 @@ Follow [Node.js](https://nodejs.org/) instructions to install Node.js.
|
|
10
10
|
|
11
11
|
### MCP Server Setup
|
12
12
|
|
13
|
-
|
13
|
+
#### Stdio (Recommend)
|
14
|
+
|
15
|
+
To configure `cls-mcp-server` as an MCP service in stdio transport, add the following JSON configuration to your `mcpServers` settings:
|
14
16
|
|
15
17
|
```json
|
16
18
|
{
|
@@ -26,6 +28,7 @@ To configure `cls-mcp-server` as an MCP service, add the following JSON configur
|
|
26
28
|
"cls-mcp-server"
|
27
29
|
],
|
28
30
|
"env": {
|
31
|
+
"TRANSPORT": "stdio",
|
29
32
|
"TENCENTCLOUD_SECRET_ID": "YOUR_TENCENT_SECRET_ID",
|
30
33
|
"TENCENTCLOUD_SECRET_KEY": "YOUR_TENCENT_SECRET_KEY",
|
31
34
|
"TENCENTCLOUD_API_BASE_HOST": "tencentcloudapi.com",
|
@@ -37,10 +40,61 @@ To configure `cls-mcp-server` as an MCP service, add the following JSON configur
|
|
37
40
|
}
|
38
41
|
```
|
39
42
|
|
40
|
-
|
43
|
+
Go to [Environment value explanation](#environment-value-explanation) for detail explanation.
|
44
|
+
|
45
|
+
#### SSE
|
46
|
+
|
47
|
+
1. Create `.env` in current path, config environment values:
|
48
|
+
|
49
|
+
```
|
50
|
+
TRANSPORT=sse
|
51
|
+
TENCENTCLOUD_SECRET_ID=YOUR_TENCENT_SECRET_ID
|
52
|
+
TENCENTCLOUD_SECRET_KEY=YOUR_TENCENT_SECRET_KEY
|
53
|
+
TENCENTCLOUD_API_BASE_HOST=tencentcloudapi.com
|
54
|
+
TENCENTCLOUD_REGION=ap-guangzhou
|
55
|
+
MAX_LENGTH=15000
|
56
|
+
PORT=3000
|
57
|
+
```
|
58
|
+
|
59
|
+
2. Install `cls-mcp-server` globally by npm
|
60
|
+
|
61
|
+
```
|
62
|
+
npm install -g cls-mcp-server@latest
|
63
|
+
```
|
64
|
+
|
65
|
+
3. Run `cls-mcp-server` command to start sse server
|
66
|
+
|
67
|
+
```
|
68
|
+
cls-mcp-server
|
69
|
+
```
|
70
|
+
|
71
|
+
4. Config your `mcpServers` settings
|
72
|
+
|
73
|
+
```json
|
74
|
+
{
|
75
|
+
"mcpServers": {
|
76
|
+
"cls-mcp-server": {
|
77
|
+
"name": "cls-mcp-server",
|
78
|
+
"type": "sse",
|
79
|
+
"isActive": true,
|
80
|
+
"baseUrl": "http://localhost:3000/sse"
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
```
|
85
|
+
|
86
|
+
Go to [Environment value explanation](#environment-value-explanation) for detail explanation.
|
87
|
+
|
88
|
+
#### Environment value explanation
|
89
|
+
|
90
|
+
Replace `TRANSPORT` value to config MCP transport, `stdio` or `sse`. Default `stdio`.
|
91
|
+
|
92
|
+
Replace `YOUR_TENCENT_SECRET_ID` and `YOUR_TENCENT_SECRET_KEY` with your actual Tencent Cloud credentials.
|
93
|
+
|
94
|
+
Replace `TENCENTCLOUD_API_BASE_HOST` value if you need to change base host of Tencent Cloud API. Default "tencentcloudapi.com".
|
41
95
|
|
42
|
-
Replace `
|
96
|
+
Replace `TENCENTCLOUD_REGION` value with your desired default region. Will only take effect if no region input from AI.
|
43
97
|
|
44
|
-
Replace `
|
98
|
+
Replace `MAX_LENGTH` value to fit token length requirement of your AI model. If not provided, will send entire response to AI model.
|
45
99
|
|
46
|
-
Replace `
|
100
|
+
Replace `PORT` value to change sse server port. Default `3000`. Will only take effect in sse transport.
|
package/dist/index.js
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
"use strict";
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
5
|
+
};
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
const tencentcloud_sdk_nodejs_cls_1 = require("tencentcloud-sdk-nodejs-cls");
|
5
|
-
const tencentcloud_sdk_nodejs_region_1 = require("tencentcloud-sdk-nodejs-region");
|
6
|
-
// eslint-disable-next-line import/no-unresolved
|
7
7
|
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
8
|
-
|
8
|
+
const sse_js_1 = require("@modelcontextprotocol/sdk/server/sse.js");
|
9
9
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
10
|
+
require("dotenv/config");
|
11
|
+
const express_1 = __importDefault(require("express"));
|
12
|
+
const tencentcloud_sdk_nodejs_cls_1 = require("tencentcloud-sdk-nodejs-cls");
|
13
|
+
const tencentcloud_sdk_nodejs_region_1 = require("tencentcloud-sdk-nodejs-region");
|
10
14
|
const zod_1 = require("zod");
|
15
|
+
console.log(process.env); // remove this after you've confirmed it is working
|
11
16
|
const ClsClient = tencentcloud_sdk_nodejs_cls_1.cls.v20201016.Client;
|
12
17
|
const RegionClient = tencentcloud_sdk_nodejs_region_1.region.v20220627.Client;
|
13
18
|
// Initialize MCP server
|
@@ -273,12 +278,31 @@ const formatResponse = (data, isError) => {
|
|
273
278
|
isError: !!isError,
|
274
279
|
};
|
275
280
|
};
|
276
|
-
|
277
|
-
const transport =
|
278
|
-
|
279
|
-
|
281
|
+
function main() {
|
282
|
+
const transport = process.env.TRANSPORT;
|
283
|
+
if (transport === 'sse') {
|
284
|
+
const app = (0, express_1.default)();
|
285
|
+
let transport = null;
|
286
|
+
app.get('/sse', (req, res) => {
|
287
|
+
transport = new sse_js_1.SSEServerTransport('/messages', res);
|
288
|
+
mcpServer.connect(transport).catch((error) => {
|
289
|
+
console.error('Fatal error in main():', error);
|
290
|
+
process.exit(error?.code || 1);
|
291
|
+
});
|
292
|
+
});
|
293
|
+
app.post('/messages', (req, res) => {
|
294
|
+
if (transport) {
|
295
|
+
transport.handlePostMessage(req, res);
|
296
|
+
}
|
297
|
+
});
|
298
|
+
app.listen(process.env.PORT ? Number(process.env.PORT) : 3000);
|
299
|
+
}
|
300
|
+
else {
|
301
|
+
const stdioTransport = new stdio_js_1.StdioServerTransport();
|
302
|
+
mcpServer.connect(stdioTransport).catch((error) => {
|
303
|
+
console.error('Fatal error in main():', error);
|
304
|
+
process.exit(error?.code || 1);
|
305
|
+
});
|
306
|
+
}
|
280
307
|
}
|
281
|
-
main()
|
282
|
-
// console.error('Fatal error in main():', error);
|
283
|
-
process.exit(error?.code || 1);
|
284
|
-
});
|
308
|
+
main();
|
package/package.json
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
{
|
2
2
|
"name": "cls-mcp-server",
|
3
|
-
"version": "0.1
|
3
|
+
"version": "0.2.1",
|
4
4
|
"main": "index.js",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
7
7
|
],
|
8
8
|
"bin": {
|
9
|
-
"cls-mcp-server": "
|
9
|
+
"cls-mcp-server": "dist/index.js"
|
10
10
|
},
|
11
11
|
"scripts": {
|
12
12
|
"build": "tsc && chmod 755 dist/index.js",
|
13
13
|
"lint": "eslint -c .eslintrc.js --fix --quiet src/**/*.ts src/**/*.tsx",
|
14
14
|
"prepare": "husky",
|
15
15
|
"publish": "npm run build && npm publish --registry=\"https://registry.npmjs.org/\"",
|
16
|
-
"postinstall": "patch-package"
|
16
|
+
"postinstall": "patch-package",
|
17
|
+
"start:sse": "npm run build && node ./dist/index.js"
|
17
18
|
},
|
18
19
|
"keywords": [],
|
19
20
|
"author": "",
|
@@ -21,6 +22,7 @@
|
|
21
22
|
"description": "",
|
22
23
|
"dependencies": {
|
23
24
|
"@modelcontextprotocol/sdk": "^1.9.0",
|
25
|
+
"dotenv": "^16.5.0",
|
24
26
|
"express": "^5.1.0",
|
25
27
|
"lighthouse-mcp-server": "^0.0.6",
|
26
28
|
"lodash.isnil": "^4.0.0",
|