mcp-bkhcn 1.0.8

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/build/index.js ADDED
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { z } from "zod";
5
+ /* =====================================================
6
+ INIT MCP SERVER
7
+ ===================================================== */
8
+ const server = new McpServer({
9
+ name: "eservice",
10
+ version: "1.0.0",
11
+ });
12
+ /* =====================================================
13
+ TOOL: search_eservice
14
+ ===================================================== */
15
+ server.tool("tra_cuu", "Tìm kiếm và tra cứu văn bản pháp luật", {
16
+ text: z
17
+ .string()
18
+ .describe("Câu hỏi tổng quát của người dùng về luật"),
19
+ }, async ({ text }) => {
20
+ try {
21
+ const response = await fetch("https://flowisetenant.demozone.vn/api/v1/prediction/1180af68-e391-4278-b837-d213388e77d4", {
22
+ method: "POST",
23
+ headers: {
24
+ Authorization: "Bearer gWeqZI27K3BLKBIQtR9m10gE1vs0boHTQXV5CsPJEjg",
25
+ "Content-Type": "application/json",
26
+ },
27
+ body: JSON.stringify({
28
+ question: text,
29
+ }),
30
+ });
31
+ const result = await response.json();
32
+ return {
33
+ content: [
34
+ {
35
+ type: "text",
36
+ // Flowise thường trả về result.text
37
+ text: result?.text ??
38
+ JSON.stringify(result, null, 2),
39
+ },
40
+ ],
41
+ };
42
+ }
43
+ catch (error) {
44
+ return {
45
+ content: [
46
+ {
47
+ type: "text",
48
+ text: `❌ Lỗi khi gọi API tra cứu: ${error.message}`,
49
+ },
50
+ ],
51
+ };
52
+ }
53
+ });
54
+ /* =====================================================
55
+ START MCP SERVER
56
+ ===================================================== */
57
+ async function main() {
58
+ console.log("✅ MCP eService server started");
59
+ const transport = new StdioServerTransport();
60
+ await server.connect(transport);
61
+ }
62
+ main().catch((err) => {
63
+ console.error("❌ Error starting MCP server:", err);
64
+ process.exit(1);
65
+ });
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "mcp-bkhcn",
3
+ "version": "1.0.8",
4
+ "type": "module",
5
+ "bin": {
6
+ "mcp-server": "build/index.js"
7
+ },
8
+ "scripts": {
9
+ "build": "tsc && chmod 755 build/index.js",
10
+ "start": "node build/index.js",
11
+ "prepublishOnly": "npm run build"
12
+ },
13
+ "dependencies": {
14
+ "@modelcontextprotocol/sdk": "^1.25.2",
15
+ "zod": "^4.3.5"
16
+ },
17
+ "devDependencies": {
18
+ "@types/node": "^25.0.9",
19
+ "typescript": "^5.9.3"
20
+ }
21
+ }
package/src/index.ts ADDED
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
+ import { z } from "zod";
6
+
7
+ /* =====================================================
8
+ INIT MCP SERVER
9
+ ===================================================== */
10
+ const server = new McpServer({
11
+ name: "eservice",
12
+ version: "1.0.0",
13
+ });
14
+
15
+ /* =====================================================
16
+ TOOL: search_eservice
17
+ ===================================================== */
18
+ server.tool(
19
+ "tra_cuu",
20
+ "Tìm kiếm và tra cứu văn bản pháp luật",
21
+ {
22
+ text: z
23
+ .string()
24
+ .describe("Câu hỏi tổng quát của người dùng về luật"),
25
+ },
26
+ async ({ text }) => {
27
+ try {
28
+ const response = await fetch(
29
+ "https://flowisetenant.demozone.vn/api/v1/prediction/1180af68-e391-4278-b837-d213388e77d4",
30
+ {
31
+ method: "POST",
32
+ headers: {
33
+ Authorization:
34
+ "Bearer gWeqZI27K3BLKBIQtR9m10gE1vs0boHTQXV5CsPJEjg",
35
+ "Content-Type": "application/json",
36
+ },
37
+ body: JSON.stringify({
38
+ question: text,
39
+ }),
40
+ }
41
+ );
42
+
43
+ const result = await response.json();
44
+
45
+ return {
46
+ content: [
47
+ {
48
+ type: "text",
49
+ // Flowise thường trả về result.text
50
+ text:
51
+ result?.text ??
52
+ JSON.stringify(result, null, 2),
53
+ },
54
+ ],
55
+ };
56
+ } catch (error: any) {
57
+ return {
58
+ content: [
59
+ {
60
+ type: "text",
61
+ text: `❌ Lỗi khi gọi API tra cứu: ${error.message}`,
62
+ },
63
+ ],
64
+ };
65
+ }
66
+ }
67
+ );
68
+
69
+
70
+ /* =====================================================
71
+ START MCP SERVER
72
+ ===================================================== */
73
+ async function main() {
74
+ console.log("✅ MCP eService server started");
75
+ const transport = new StdioServerTransport();
76
+ await server.connect(transport);
77
+ }
78
+
79
+ main().catch((err) => {
80
+ console.error("❌ Error starting MCP server:", err);
81
+ process.exit(1);
82
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ES2022",
5
+ "moduleResolution": "node",
6
+ "rootDir": "src",
7
+ "outDir": "build",
8
+ "types": [
9
+ "node"
10
+ ],
11
+ "strict": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true
14
+ },
15
+ "include": [
16
+ "src"
17
+ ]
18
+ }