rfhub-mcp 0.7.0 → 0.9.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/dist/server.js +12 -10
- package/dist/tools/arfcn-calculator-4g.js +129 -135
- package/dist/tools/arfcn-calculator-5g.js +198 -205
- package/dist/tools/arfcn-calculator-ntn.js +198 -205
- package/dist/types/server.d.ts +3 -0
- package/dist/types/server.d.ts.map +1 -0
- package/dist/types/tools/arfcn-calculator-4g.d.ts +7 -0
- package/dist/types/tools/arfcn-calculator-4g.d.ts.map +1 -0
- package/dist/types/tools/arfcn-calculator-5g.d.ts +6 -0
- package/dist/types/tools/arfcn-calculator-5g.d.ts.map +1 -0
- package/dist/types/tools/arfcn-calculator-ntn.d.ts +6 -0
- package/dist/types/tools/arfcn-calculator-ntn.d.ts.map +1 -0
- package/dist/types/utils/request.d.ts +8 -0
- package/dist/types/utils/request.d.ts.map +1 -0
- package/dist/types/utils/response.d.ts +7 -0
- package/dist/types/utils/response.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import packageJson from "../package.json" with { type: "json" };
|
|
2
3
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
4
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
5
|
import ArfcnCalculator4G from "./tools/arfcn-calculator-4g.js";
|
|
5
6
|
import ArfcnCalculator5G from "./tools/arfcn-calculator-5g.js";
|
|
6
7
|
import ArfcnCalculatorNTN from "./tools/arfcn-calculator-ntn.js";
|
|
8
|
+
import { safeApiPost } from "./utils/request.js";
|
|
7
9
|
const mcpServer = new McpServer({
|
|
8
|
-
name:
|
|
9
|
-
version:
|
|
10
|
-
title:
|
|
11
|
-
description:
|
|
12
|
-
websiteUrl:
|
|
10
|
+
name: packageJson.name,
|
|
11
|
+
version: packageJson.version,
|
|
12
|
+
title: packageJson.title,
|
|
13
|
+
description: packageJson.description,
|
|
14
|
+
websiteUrl: packageJson.websiteUrl,
|
|
13
15
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
ArfcnCalculator4G.registerComputeTool(mcpServer, safeApiPost);
|
|
17
|
+
ArfcnCalculator5G.registerComputeTool(mcpServer, safeApiPost);
|
|
18
|
+
ArfcnCalculatorNTN.registerComputeTool(mcpServer, safeApiPost);
|
|
17
19
|
async function main() {
|
|
18
20
|
const transport = new StdioServerTransport();
|
|
19
21
|
await mcpServer.connect(transport);
|
|
20
|
-
console.log("
|
|
22
|
+
console.log("rfhub-mcp server is running...");
|
|
21
23
|
}
|
|
22
24
|
main().catch((error) => {
|
|
23
|
-
console.error("
|
|
25
|
+
console.error("rfhub-mcp server error:", error);
|
|
24
26
|
process.exit(1);
|
|
25
27
|
});
|
|
@@ -1,137 +1,131 @@
|
|
|
1
1
|
import * as z from "zod/v4";
|
|
2
|
-
import { safeApiPost } from "../utils/request.js";
|
|
3
2
|
import { mcpExResponse } from "../utils/response.js";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return mcpExResponse;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
}
|
|
3
|
+
export const registerComputeTool = (mcpServer, getResult) => {
|
|
4
|
+
const ModeEnum = z.enum(["n", "f"]);
|
|
5
|
+
const DirectionEnum = z.enum(["uplink", "downlink"]);
|
|
6
|
+
const DuplexModeEnum = z.enum(["TDD", "FDD"]);
|
|
7
|
+
const computeInputSchema = z.object({
|
|
8
|
+
Mode: ModeEnum.optional().describe("计算模式,例如 n 表示频点模式,f 表示频率模式"),
|
|
9
|
+
DataTransmissionDirection: DirectionEnum.describe("数据传输方向,可选上行(uplink)、下行(downlink)"),
|
|
10
|
+
NREF: z.number().int().optional().describe('频点参考(NREF),例如 504999。用于在频点模式(Mode=`"n"`)下确定中心频率。'),
|
|
11
|
+
FREF: z.number().optional().describe('频率参考(FREF),单位为 MHz,例如 3500.0。用于在频率模式(Mode=`"f"`)下直接指定中心频率。'),
|
|
12
|
+
Band: z.string().optional().describe('频段标识符,例如 "b3"、"b41" 等'),
|
|
13
|
+
Bandwidth: z.number().positive().optional().describe("信道带宽,单位为 MHz,例如 100 表示 100MHz"),
|
|
14
|
+
});
|
|
15
|
+
const computeOutputSchema = z.object({
|
|
16
|
+
Mode: ModeEnum.nullable().optional(),
|
|
17
|
+
Mode_Error: z.string().nullable().optional(),
|
|
18
|
+
DataTransmissionDirection: DirectionEnum.nullable().optional(),
|
|
19
|
+
DataTransmissionDirection_Error: z.string().nullable().optional(),
|
|
20
|
+
NREF: z.number().int().nullable().optional(),
|
|
21
|
+
NREF_Error: z.string().nullable().optional(),
|
|
22
|
+
FREF: z.number().nullable().optional(),
|
|
23
|
+
FREF_Error: z.string().nullable().optional(),
|
|
24
|
+
BandOptions: z.array(z.string()).nullable().optional(),
|
|
25
|
+
BandOptions_Error: z.string().nullable().optional(),
|
|
26
|
+
Band: z.string().nullable().optional(),
|
|
27
|
+
Band_Error: z.string().nullable().optional(),
|
|
28
|
+
FREF_Low: z.number().nullable().optional(),
|
|
29
|
+
FREF_High: z.number().nullable().optional(),
|
|
30
|
+
NREF_First: z.number().int().nullable().optional(),
|
|
31
|
+
NREF_Last: z.number().int().nullable().optional(),
|
|
32
|
+
DuplexMode: DuplexModeEnum.nullable().optional(),
|
|
33
|
+
SCS: z.string().nullable().optional(),
|
|
34
|
+
BandwidthOptions: z.array(z.string()).nullable().optional(),
|
|
35
|
+
BandwidthOptions_Error: z.string().nullable().optional(),
|
|
36
|
+
Bandwidth: z.number().nullable().optional(),
|
|
37
|
+
Bandwidth_Error: z.string().nullable().optional(),
|
|
38
|
+
NRB: z.number().int().nullable().optional(),
|
|
39
|
+
FREF_AvailableLow: z.number().nullable().optional(),
|
|
40
|
+
FREF_AvailableHigh: z.number().nullable().optional(),
|
|
41
|
+
});
|
|
42
|
+
const apiResultSchema = z.object({
|
|
43
|
+
Mode: z.string().nullable().optional(),
|
|
44
|
+
Mode_Error: z.string().nullable().optional(),
|
|
45
|
+
DataTransmissionDirection: z.string().nullable().optional(),
|
|
46
|
+
DataTransmissionDirection_Error: z.string().nullable().optional(),
|
|
47
|
+
NREF: z.string().nullable().optional(),
|
|
48
|
+
NREF_Error: z.string().nullable().optional(),
|
|
49
|
+
FREF: z.string().nullable().optional(),
|
|
50
|
+
FREF_Error: z.string().nullable().optional(),
|
|
51
|
+
BandOptions: z.array(z.string()).nullable().optional(),
|
|
52
|
+
BandOptions_Error: z.string().nullable().optional(),
|
|
53
|
+
Band: z.string().nullable().optional(),
|
|
54
|
+
Band_Error: z.string().nullable().optional(),
|
|
55
|
+
FREF_Low: z.string().nullable().optional(),
|
|
56
|
+
FREF_High: z.string().nullable().optional(),
|
|
57
|
+
NREF_First: z.string().nullable().optional(),
|
|
58
|
+
NREF_Last: z.string().nullable().optional(),
|
|
59
|
+
DuplexMode: DuplexModeEnum.nullable().optional(),
|
|
60
|
+
SCS: z.string().nullable().optional(),
|
|
61
|
+
BandwidthOptions: z.array(z.string()).nullable().optional(),
|
|
62
|
+
BandwidthOptions_Error: z.string().nullable().optional(),
|
|
63
|
+
Bandwidth: z.string().nullable().optional(),
|
|
64
|
+
Bandwidth_Error: z.string().nullable().optional(),
|
|
65
|
+
NRB: z.string().nullable().optional(),
|
|
66
|
+
FREF_AvailableLow: z.string().nullable().optional(),
|
|
67
|
+
FREF_AvailableHigh: z.string().nullable().optional(),
|
|
68
|
+
});
|
|
69
|
+
mcpServer.registerTool("arfcn_calculator_4g_compute", {
|
|
70
|
+
title: "4G/LTE频点频率转换与对应频带信息",
|
|
71
|
+
description: "支持4G LTE网络中频率与频点之间的相互转换,并附带特定频段的详细信息展示",
|
|
72
|
+
inputSchema: computeInputSchema,
|
|
73
|
+
outputSchema: computeOutputSchema,
|
|
74
|
+
}, async (input) => {
|
|
75
|
+
try {
|
|
76
|
+
const apiRequest = {
|
|
77
|
+
Mode: input.Mode ?? (input.NREF && "n"),
|
|
78
|
+
DataTransmissionDirection: input.DataTransmissionDirection,
|
|
79
|
+
Band: input.Band?.replaceAll("b", "").replaceAll("B", "") ?? null,
|
|
80
|
+
NERF: input.NREF?.toString() ?? null,
|
|
81
|
+
FERF: input.FREF?.toString() ?? null,
|
|
82
|
+
Bandwidth: input.Bandwidth?.toString() ?? null,
|
|
83
|
+
};
|
|
84
|
+
const result = await getResult("/api/arfcn-calculator-4g/compute", apiRequest);
|
|
85
|
+
// const result = await safeApiPost("/api/arfcn-calculator-4g/compute", apiRequest);
|
|
86
|
+
const apiResult = apiResultSchema.parse(result);
|
|
87
|
+
const structuredContent = {
|
|
88
|
+
Mode: apiResult.Mode ?? null,
|
|
89
|
+
Mode_Error: apiResult.Mode_Error ?? null,
|
|
90
|
+
DataTransmissionDirection: apiResult.DataTransmissionDirection ?? null,
|
|
91
|
+
DataTransmissionDirection_Error: apiResult.DataTransmissionDirection_Error ?? null,
|
|
92
|
+
NREF: apiResult.NREF ?? null,
|
|
93
|
+
NREF_Error: apiResult.NREF_Error ?? null,
|
|
94
|
+
FREF: apiResult.FREF ?? null,
|
|
95
|
+
FREF_Error: apiResult.FREF_Error ?? null,
|
|
96
|
+
BandOptions: apiResult.BandOptions ?? null,
|
|
97
|
+
BandOptions_Error: apiResult.BandOptions_Error ?? null,
|
|
98
|
+
Band: apiResult.Band ?? null,
|
|
99
|
+
Band_Error: apiResult.Band_Error ?? null,
|
|
100
|
+
FREF_Low: apiResult.FREF_Low ?? null,
|
|
101
|
+
FREF_High: apiResult.FREF_High ?? null,
|
|
102
|
+
NREF_First: apiResult.NREF_First ?? null,
|
|
103
|
+
NREF_Last: apiResult.NREF_Last ?? null,
|
|
104
|
+
DuplexMode: apiResult.DuplexMode ?? null,
|
|
105
|
+
SCS: apiResult.SCS ?? null,
|
|
106
|
+
BandwidthOptions: apiResult.BandwidthOptions ?? null,
|
|
107
|
+
BandwidthOptions_Error: apiResult.BandwidthOptions_Error ?? null,
|
|
108
|
+
Bandwidth: apiResult.Bandwidth ?? null,
|
|
109
|
+
Bandwidth_Error: apiResult.Bandwidth_Error ?? null,
|
|
110
|
+
NRB: apiResult.NRB ?? null,
|
|
111
|
+
FREF_AvailableLow: apiResult.FREF_AvailableLow ?? null,
|
|
112
|
+
FREF_AvailableHigh: apiResult.FREF_AvailableHigh ?? null,
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
content: [
|
|
116
|
+
{
|
|
117
|
+
type: "text",
|
|
118
|
+
text: JSON.stringify(structuredContent, null, 2),
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
structuredContent,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return mcpExResponse;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
export default {
|
|
130
|
+
registerComputeTool,
|
|
131
|
+
};
|