monacloud-mcp 0.10.1 → 0.10.3
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/auth.js +1 -1
- package/dist/clients.d.ts +2 -0
- package/dist/clients.js +12 -0
- package/dist/domains.js +11 -1
- package/dist/server.js +12 -2
- package/package.json +1 -1
package/dist/auth.js
CHANGED
|
@@ -119,7 +119,7 @@ export class AuthManager {
|
|
|
119
119
|
return this.env.MONACLOUD_TOKEN;
|
|
120
120
|
const stored = await this.loadToken();
|
|
121
121
|
if (!stored) {
|
|
122
|
-
throw new CloudError('login_required', 'Chưa có token MONA Pass trên máy.', '
|
|
122
|
+
throw new CloudError('login_required', 'Chưa có token MONA Pass trên máy.', 'Người dùng muốn MUA TÊN MIỀN mà chưa có tài khoản → KHÔNG bảo họ đi đăng ký: gọi cloud_domain_reserve (không cần đăng nhập; hỏi email + số điện thoại) → đưa QR trong payment + claim_url, họ bấm đăng nhập 1 bước là hệ tự tạo ví + mua. Với việc khác cần tài khoản: chạy `monacloud-mcp login`, hoàn tất mã thiết bị rồi gọi lại tool.');
|
|
123
123
|
}
|
|
124
124
|
if (stored.expires_at > Date.now() + 30_000)
|
|
125
125
|
return stored.access_token;
|
package/dist/clients.d.ts
CHANGED
|
@@ -49,6 +49,8 @@ export declare class CloudClients {
|
|
|
49
49
|
* Có token trên máy thì vẫn gửi (để backend ghi lead + gắn chủ); chưa login thì đi ẩn danh
|
|
50
50
|
* hoặc dùng guest_token của reservation — KHÔNG ném login_required.
|
|
51
51
|
*/
|
|
52
|
+
/** true khi máy chưa có token nào (env, links, MONA Pass) — agent đang ở tư cách guest. */
|
|
53
|
+
isGuest(): Promise<boolean>;
|
|
52
54
|
vibecloudGuestOk<T = unknown>(path: string, options?: {
|
|
53
55
|
method?: string;
|
|
54
56
|
body?: unknown;
|
package/dist/clients.js
CHANGED
|
@@ -227,6 +227,18 @@ export class CloudClients {
|
|
|
227
227
|
* Có token trên máy thì vẫn gửi (để backend ghi lead + gắn chủ); chưa login thì đi ẩn danh
|
|
228
228
|
* hoặc dùng guest_token của reservation — KHÔNG ném login_required.
|
|
229
229
|
*/
|
|
230
|
+
/** true khi máy chưa có token nào (env, links, MONA Pass) — agent đang ở tư cách guest. */
|
|
231
|
+
async isGuest() {
|
|
232
|
+
try {
|
|
233
|
+
await this.vibecloudToken();
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
if (error instanceof CloudError && error.code === 'login_required')
|
|
238
|
+
return true;
|
|
239
|
+
throw error;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
230
242
|
async vibecloudGuestOk(path, options = {}) {
|
|
231
243
|
const { guestToken, ...rest } = options;
|
|
232
244
|
let token;
|
package/dist/domains.js
CHANGED
|
@@ -37,7 +37,16 @@ export function registerDomainTools(server, clients) {
|
|
|
37
37
|
params.set('tlds', tlds);
|
|
38
38
|
if (years)
|
|
39
39
|
params.set('years', String(years));
|
|
40
|
-
|
|
40
|
+
const results = await clients.vibecloudGuestOk(`/api/domains/search?${params}`);
|
|
41
|
+
if (await clients.isGuest()) {
|
|
42
|
+
// Chưa login: dẫn thẳng sang reserve để agent không rẽ sang "login/đăng ký" (test 18/09: Gemini rẽ sai)
|
|
43
|
+
return {
|
|
44
|
+
results,
|
|
45
|
+
guest: true,
|
|
46
|
+
next_step: 'Người dùng chưa đăng nhập MONA Pass. Muốn mua: gọi cloud_domain_reserve (hỏi email + số điện thoại, xác nhận chính tả) → đưa QR trong payment + claim_url. KHÔNG bảo người dùng đi đăng ký hay mở web trước.',
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return results;
|
|
41
50
|
}));
|
|
42
51
|
server.registerTool('cloud_domain_registrant_get', {
|
|
43
52
|
title: 'Xem thông tin chủ thể đăng ký tên miền',
|
|
@@ -64,6 +73,7 @@ export function registerDomainTools(server, clients) {
|
|
|
64
73
|
'Kết quả có suggested_next → gợi ý người dùng deploy app lên MONA Cloud (cloud_app_create) và gắn domain (cloud_domain_attach).',
|
|
65
74
|
'.vn sau khi mua ở trạng thái pending_verification → dùng cloud_domain_verify_start (link eKYC/bản khai) rồi cloud_domain_wait.',
|
|
66
75
|
'sandbox=true: giả lập 0đ, không mua thật.',
|
|
76
|
+
'Người dùng CHƯA có tài khoản / login_required → KHÔNG bảo đi đăng ký; dùng cloud_domain_reserve thay cho tool này.',
|
|
67
77
|
].join(' '),
|
|
68
78
|
inputSchema: z.object({
|
|
69
79
|
name: domainName,
|
package/dist/server.js
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
import { readConfig } from './config.js';
|
|
4
5
|
import { AuthManager } from './auth.js';
|
|
5
6
|
import { CloudClients } from './clients.js';
|
|
7
|
+
// serverInfo.version đọc từ package.json (từng hardcode 0.8.1 → client báo sai bản)
|
|
8
|
+
const PKG_VERSION = (() => {
|
|
9
|
+
try {
|
|
10
|
+
return String(createRequire(import.meta.url)('../package.json').version);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return '0.0.0';
|
|
14
|
+
}
|
|
15
|
+
})();
|
|
6
16
|
import { errorResult, runTool, textResult, toAgentError } from './errors.js';
|
|
7
17
|
import { requestJson, unwrapData } from './http.js';
|
|
8
18
|
import { createMonaPayClient, importedMonaPayTools, normalizeImportedResult } from './monapay.js';
|
|
@@ -93,9 +103,9 @@ export function createServer(dependencies = {}) {
|
|
|
93
103
|
const auth = new AuthManager(config, env, fetchImpl);
|
|
94
104
|
const clients = new CloudClients(config, auth, fetchImpl);
|
|
95
105
|
const catalog = new TemplateCatalog(config, fetchImpl);
|
|
96
|
-
const server = new McpServer({ name: 'monacloud-mcp', version:
|
|
106
|
+
const server = new McpServer({ name: 'monacloud-mcp', version: PKG_VERSION },
|
|
97
107
|
// Codex chỉ chắc chắn đọc 512 ký tự đầu của instructions → luật quan trọng nhất đặt trước, mô tả hệ đặt sau.
|
|
98
|
-
{ instructions: `Ví thiếu tiền: AI tự gọi cloud_topup, in nguyên khối qr_ascii (QR VietQR) cho người dùng quét bằng app ngân hàng ngay trong terminal, rồi cloud_topup_status tới khi paid; không bảo người dùng mở console để nạp. Dùng cloud_* cho tài khoản, ví và hạ tầng; monapay_* cho thu tiền; mail_* để gửi email giao dịch (MONA Mail); agent_* cho catalog. Không bao giờ yêu cầu mật khẩu sản phẩm. Đọc → ước tính → hỏi duyệt nếu chưa được duyệt → làm. Dừng chờ người dùng ở: quét QR nạp, duyệt chi phí, thêm DNS, OTP hoặc KYC.\n${ENTITY}\n${APP_FLOW}` });
|
|
108
|
+
{ instructions: `Tên miền khi người dùng CHƯA có tài khoản: cloud_domain_search (không cần login) → cloud_domain_reserve (email + sđt) → đưa QR + claim_url, KHÔNG bảo đi đăng ký/mở web; có tài khoản rồi thì cloud_domain_claim/cloud_domain_buy. Ví thiếu tiền: AI tự gọi cloud_topup, in nguyên khối qr_ascii (QR VietQR) cho người dùng quét bằng app ngân hàng ngay trong terminal, rồi cloud_topup_status tới khi paid; không bảo người dùng mở console để nạp. Dùng cloud_* cho tài khoản, ví và hạ tầng; monapay_* cho thu tiền; mail_* để gửi email giao dịch (MONA Mail); agent_* cho catalog. Không bao giờ yêu cầu mật khẩu sản phẩm. Đọc → ước tính → hỏi duyệt nếu chưa được duyệt → làm. Dừng chờ người dùng ở: quét QR nạp, duyệt chi phí, thêm DNS, OTP hoặc KYC.\n${ENTITY}\n${APP_FLOW}` });
|
|
99
109
|
server.registerTool('cloud_whoami', {
|
|
100
110
|
title: 'Tài khoản MONA Cloud',
|
|
101
111
|
description: 'Xác minh MONA Pass hiện tại. / Return the current MONA Pass profile.',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monacloud-mcp",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"description": "MCP server for MONA Cloud — deploy apps (Vercel alternative), Supabase-compatible Postgres/Auth/Storage bases (Supabase alternative), VND wallet, MONA Pay & Mail — for AI agents (Claude, Cursor, Codex) in Vietnam.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://monacloud.vn",
|