@qingchencloud/mcp 1.0.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.
Files changed (2) hide show
  1. package/dist/index.js +163 -0
  2. package/package.json +29 -0
package/dist/index.js ADDED
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
5
+ const API_URL = (process.env.QINGCHEN_API_URL || "https://app.qingchencloud.com").replace(/\/$/, "");
6
+ const API_TOKEN = process.env.QINGCHEN_API_TOKEN || "";
7
+ if (!API_TOKEN) {
8
+ process.stderr.write("错误: 请设置环境变量 QINGCHEN_API_TOKEN\n");
9
+ process.exit(1);
10
+ }
11
+ async function api(method, path, body) {
12
+ const res = await fetch(`${API_URL}/api/v1/open${path}`, {
13
+ method,
14
+ headers: { "X-API-Token": API_TOKEN, "Content-Type": "application/json" },
15
+ body: body != null ? JSON.stringify(body) : undefined,
16
+ });
17
+ const data = await res.json();
18
+ if (data.code !== 0)
19
+ throw new Error(data.message || "请求失败");
20
+ return data.data;
21
+ }
22
+ const server = new Server({ name: "qingchencloud", version: "1.0.0" }, { capabilities: { tools: {} } });
23
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
24
+ tools: [
25
+ {
26
+ name: "create_task",
27
+ description: "创建构建任务,将网址打包为原生应用(Android/iOS/Windows/macOS)",
28
+ inputSchema: {
29
+ type: "object",
30
+ properties: {
31
+ app_name: { type: "string", description: "应用名称" },
32
+ target_url: { type: "string", description: "目标网址 (https://...)" },
33
+ platforms: {
34
+ type: "array",
35
+ items: { type: "string", enum: ["android", "ios", "windows", "macos"] },
36
+ description: "目标平台列表",
37
+ },
38
+ icon_file_id: { type: "string", description: "图标文件ID(可选,通过Web上传获取)" },
39
+ },
40
+ required: ["app_name", "target_url", "platforms"],
41
+ },
42
+ },
43
+ {
44
+ name: "get_task",
45
+ description: "查询构建任务状态和下载链接",
46
+ inputSchema: {
47
+ type: "object",
48
+ properties: {
49
+ task_no: { type: "string", description: "任务编号" },
50
+ },
51
+ required: ["task_no"],
52
+ },
53
+ },
54
+ {
55
+ name: "list_tasks",
56
+ description: "列出构建任务列表",
57
+ inputSchema: {
58
+ type: "object",
59
+ properties: {
60
+ page: { type: "number", description: "页码,默认1" },
61
+ status: { type: "string", enum: ["pending", "building", "completed", "failed"], description: "状态筛选" },
62
+ },
63
+ },
64
+ },
65
+ {
66
+ name: "get_task_cost",
67
+ description: "预估构建费用",
68
+ inputSchema: {
69
+ type: "object",
70
+ properties: {
71
+ platforms: {
72
+ type: "array",
73
+ items: { type: "string" },
74
+ description: "平台列表",
75
+ },
76
+ },
77
+ required: ["platforms"],
78
+ },
79
+ },
80
+ {
81
+ name: "get_credits",
82
+ description: "查询各平台额度余额",
83
+ inputSchema: { type: "object", properties: {} },
84
+ },
85
+ {
86
+ name: "list_packages",
87
+ description: "列出可购买的套餐和加油包",
88
+ inputSchema: { type: "object", properties: {} },
89
+ },
90
+ {
91
+ name: "get_profile",
92
+ description: "查询当前用户信息",
93
+ inputSchema: { type: "object", properties: {} },
94
+ },
95
+ {
96
+ name: "upload_icon",
97
+ description: "上传应用图标(请通过Web管理面板上传,获取file_id后传给create_task)",
98
+ inputSchema: {
99
+ type: "object",
100
+ properties: {
101
+ url: { type: "string", description: "图标URL(仅提示,实际需通过Web上传)" },
102
+ },
103
+ },
104
+ },
105
+ ],
106
+ }));
107
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
108
+ const { name, arguments: args = {} } = request.params;
109
+ const a = args;
110
+ try {
111
+ switch (name) {
112
+ case "create_task": {
113
+ const result = await api("POST", "/tasks", {
114
+ app_name: a.app_name,
115
+ target_url: a.target_url,
116
+ platforms: a.platforms,
117
+ icon_file_id: a.icon_file_id || "",
118
+ });
119
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
120
+ }
121
+ case "get_task": {
122
+ const result = await api("GET", `/tasks/${a.task_no}`);
123
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
124
+ }
125
+ case "list_tasks": {
126
+ const page = a.page || 1;
127
+ const status = a.status ? `&status=${a.status}` : "";
128
+ const result = await api("GET", `/tasks?page=${page}${status}`);
129
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
130
+ }
131
+ case "get_task_cost": {
132
+ const result = await api("POST", "/tasks/cost", { platforms: a.platforms });
133
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
134
+ }
135
+ case "get_credits": {
136
+ const result = await api("GET", "/credits");
137
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
138
+ }
139
+ case "list_packages": {
140
+ const result = await api("GET", "/packages");
141
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
142
+ }
143
+ case "get_profile": {
144
+ const result = await api("GET", "/profile");
145
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
146
+ }
147
+ case "upload_icon":
148
+ return {
149
+ content: [{
150
+ type: "text",
151
+ text: "图标上传请通过 Web 管理面板完成:\n1. 登录 " + API_URL + "\n2. 上传图标获取 file_id\n3. 将 file_id 传给 create_task 的 icon_file_id 参数\n\n不传 icon_file_id 时系统使用默认图标。",
152
+ }],
153
+ };
154
+ default:
155
+ return { content: [{ type: "text", text: `未知工具: ${name}` }], isError: true };
156
+ }
157
+ }
158
+ catch (e) {
159
+ return { content: [{ type: "text", text: `错误: ${e.message}` }], isError: true };
160
+ }
161
+ });
162
+ const transport = new StdioServerTransport();
163
+ await server.connect(transport);
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@qingchencloud/mcp",
3
+ "version": "1.0.0",
4
+ "description": "晴辰APP云 MCP Server — 通过 AI 将网址打包为原生应用",
5
+ "type": "module",
6
+ "bin": {
7
+ "qingchencloud-mcp": "dist/index.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "dev": "tsc --watch",
12
+ "start": "node dist/index.js",
13
+ "prepublishOnly": "npm run build"
14
+ },
15
+ "files": ["dist"],
16
+ "dependencies": {
17
+ "@modelcontextprotocol/sdk": "^1.0.0"
18
+ },
19
+ "devDependencies": {
20
+ "@types/node": "^20.0.0",
21
+ "typescript": "^5.0.0"
22
+ },
23
+ "keywords": ["mcp", "appbuilder", "qingchencloud", "claude"],
24
+ "license": "MIT",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/1186258278/QingChenApp"
28
+ }
29
+ }