cls-mcp-server 0.1.0 → 0.2.0
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 +46 -5
- package/dist/index.js +36 -12
- package/package.json +4 -2
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
|
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",
|
@@ -36,11 +39,49 @@ To configure `cls-mcp-server` as an MCP service, add the following JSON configur
|
|
36
39
|
}
|
37
40
|
}
|
38
41
|
```
|
42
|
+
Go to [Environment value explanation](#environment-value-explanation) for detail explanation.
|
43
|
+
|
44
|
+
#### SSE
|
45
|
+
1. Create `.env` in current path, config environment values:
|
46
|
+
|
47
|
+
```
|
48
|
+
TRANSPORT=sse
|
49
|
+
TENCENTCLOUD_SECRET_ID=YOUR_TENCENT_SECRET_ID
|
50
|
+
TENCENTCLOUD_SECRET_KEY=YOUR_TENCENT_SECRET_KEY
|
51
|
+
TENCENTCLOUD_API_BASE_HOST=tencentcloudapi.com
|
52
|
+
TENCENTCLOUD_REGION=ap-guangzhou
|
53
|
+
MAX_LENGTH=15000
|
54
|
+
```
|
55
|
+
|
56
|
+
2. Run command
|
57
|
+
```
|
58
|
+
npm run start:sse
|
59
|
+
```
|
60
|
+
|
61
|
+
3. Config your `mcpServers` settings
|
62
|
+
```json
|
63
|
+
{
|
64
|
+
"mcpServers": {
|
65
|
+
"cls-mcp-server": {
|
66
|
+
"name": "cls-mcp-server",
|
67
|
+
"type": "sse",
|
68
|
+
"isActive": true,
|
69
|
+
"baseUrl": "http://localhost:3000/sse"
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
```
|
74
|
+
|
75
|
+
Go to [Environment value explanation](#environment-value-explanation) for detail explanation.
|
76
|
+
|
77
|
+
#### Environment value explanation
|
78
|
+
|
79
|
+
Replace `TRANSPORT` value to config MCP transport, `stdio` or `sse`. Default `stdio`.
|
39
80
|
|
40
|
-
Replace `
|
81
|
+
Replace `YOUR_TENCENT_SECRET_ID` and `YOUR_TENCENT_SECRET_KEY` with your actual Tencent Cloud credentials.
|
41
82
|
|
42
|
-
Replace `TENCENTCLOUD_API_BASE_HOST` if you need to change base host of Tencent Cloud API. Default "tencentcloudapi.com".
|
83
|
+
Replace `TENCENTCLOUD_API_BASE_HOST` value if you need to change base host of Tencent Cloud API. Default "tencentcloudapi.com".
|
43
84
|
|
44
|
-
Replace `TENCENTCLOUD_REGION` with your desired default region.
|
85
|
+
Replace `TENCENTCLOUD_REGION` value with your desired default region. Will only take effect if no region input from AI.
|
45
86
|
|
46
|
-
Replace `MAX_LENGTH` to fit token length requirement of your AI model. If not provided, will send entire response to AI model.
|
87
|
+
Replace `MAX_LENGTH` value to fit token length requirement of your AI model. If not provided, will send entire response to AI model.
|
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(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,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "cls-mcp-server",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.2.0",
|
4
4
|
"main": "index.js",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
@@ -13,7 +13,8 @@
|
|
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",
|