@cloudbase/cloudbase-mcp 2.13.0 → 2.14.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/index.d.ts CHANGED
@@ -1,13 +1,379 @@
1
- export { createCloudBaseMcpServer, getDefaultServer, type McpServer, type ExtendedMcpServer, StdioServerTransport, telemetryReporter, reportToolkitLifecycle, reportToolCall, info, error, warn } from "./server.js";
2
- export type { UploadFileParams, ListFilesParams, DeleteFileParams, GetFileInfoParams, ToolResponse, DataModelField, DataModelSchema, DataModel, CloudBaseOptions } from "./types.js";
3
- export { getLoginState, logout } from "./auth.js";
4
- export { isCloudMode, enableCloudMode, getCloudModeStatus, shouldRegisterTool } from "./utils/cloud-mode.js";
5
- export { getCloudBaseManager, getEnvId, resetCloudBaseManagerCache, createCloudBaseManagerWithOptions, envManager } from "./cloudbase-manager.js";
6
- export { simplifyEnvList } from "./tools/env.js";
7
- export { RAW_IDE_FILE_MAPPINGS } from "./tools/setup.js";
8
- export type { InteractiveResult } from "./interactive-server.js";
9
- /**
10
- * Get interactive server instance (CommonJS compatible)
11
- */
12
- export declare function getInteractiveServerAsync(): Promise<import("./interactive-server.js").InteractiveServer>;
13
- //# sourceMappingURL=index.d.ts.map
1
+ import CloudBase from '@cloudbase/manager-node';
2
+ import { Credential as Credential_2 } from '@cloudbase/toolbox';
3
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
5
+
6
+ declare type AuthFlowMode = "web" | "device";
7
+
8
+ export declare type CloudBaseOptions = NonNullable<ConstructorParameters<typeof CloudBase>[0]>;
9
+
10
+ /**
11
+ * Create a manager with the provided CloudBase options, without using cache
12
+ * @param cloudBaseOptions Provided CloudBase options
13
+ * @returns CloudBase manager instance
14
+ */
15
+ export declare function createCloudBaseManagerWithOptions(cloudBaseOptions: CloudBaseOptions): CloudBase;
16
+
17
+ /**
18
+ * Create and configure a CloudBase MCP Server instance
19
+ * @param options Server configuration options
20
+ * @returns Configured McpServer instance
21
+ *
22
+ * @example
23
+ * import { createCloudBaseMcpServer } from "@cloudbase/mcp-server";
24
+ * import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
25
+ *
26
+ * const server = createCloudBaseMcpServer({ cloudBaseOptions: {
27
+ * envId, // 环境ID
28
+ * secretId, // 腾讯云密钥ID
29
+ * secretKey, // 腾讯云密钥
30
+ * region, // 地域,默认是 ap-shanghai
31
+ * token // 临时密钥,有有效期限制,生成密钥时可控制
32
+ * } });
33
+ *
34
+ * const transport = new StdioServerTransport();
35
+ * await server.connect(transport);
36
+ */
37
+ export declare function createCloudBaseMcpServer(options?: {
38
+ name?: string;
39
+ version?: string;
40
+ enableTelemetry?: boolean;
41
+ cloudBaseOptions?: CloudBaseOptions;
42
+ cloudMode?: boolean;
43
+ ide?: string;
44
+ logger?: Logger;
45
+ pluginsEnabled?: string[];
46
+ pluginsDisabled?: string[];
47
+ }): Promise<ExtendedMcpServer>;
48
+
49
+ export declare interface DataModel {
50
+ id?: string;
51
+ name: string;
52
+ title: string;
53
+ schema: DataModelSchema;
54
+ envId?: string;
55
+ status?: 'draft' | 'published';
56
+ createdAt?: string;
57
+ updatedAt?: string;
58
+ }
59
+
60
+ export declare interface DataModelField {
61
+ name: string;
62
+ type: 'string' | 'number' | 'boolean' | 'date' | 'array' | 'object' | 'objectId' | 'file' | 'image';
63
+ required?: boolean;
64
+ default?: any;
65
+ description?: string;
66
+ validation?: {
67
+ min?: number;
68
+ max?: number;
69
+ pattern?: string;
70
+ enum?: any[];
71
+ };
72
+ }
73
+
74
+ export declare interface DataModelSchema {
75
+ type: 'object';
76
+ properties: Record<string, {
77
+ type: string;
78
+ description?: string;
79
+ required?: boolean;
80
+ default?: any;
81
+ validation?: any;
82
+ }>;
83
+ required?: string[];
84
+ }
85
+
86
+ export declare interface DeleteFileParams {
87
+ cloudPath: string;
88
+ }
89
+
90
+ declare interface DeviceFlowAuthInfo {
91
+ user_code: string;
92
+ verification_uri?: string;
93
+ device_code: string;
94
+ expires_in: number;
95
+ }
96
+
97
+ /**
98
+ * Enable cloud mode by setting environment variable
99
+ */
100
+ export declare function enableCloudMode(): void;
101
+
102
+ declare function ensureLogin(options?: {
103
+ fromCloudBaseLoginPage?: boolean;
104
+ ignoreEnvVars?: boolean;
105
+ region?: string;
106
+ authMode?: AuthFlowMode;
107
+ clientId?: string;
108
+ onDeviceCode?: (info: DeviceFlowAuthInfo) => void;
109
+ }): Promise<{
110
+ secretId: string;
111
+ secretKey: string;
112
+ token: string | undefined;
113
+ envId: string | undefined;
114
+ } | Credential_2>;
115
+
116
+ declare class EnvironmentManager {
117
+ private cachedEnvId;
118
+ private envIdPromise;
119
+ reset(): void;
120
+ getEnvId(): Promise<string>;
121
+ private _fetchEnvId;
122
+ private _setCachedEnvId;
123
+ setEnvId(envId: string): Promise<void>;
124
+ getCachedEnvId(): string | null;
125
+ }
126
+
127
+ export declare const envManager: EnvironmentManager;
128
+
129
+ export declare const error: (message: string, data?: object | Error) => void;
130
+
131
+ export declare interface ExtendedMcpServer extends McpServer {
132
+ cloudBaseOptions?: CloudBaseOptions;
133
+ ide?: string;
134
+ logger?: Logger;
135
+ setLogger(logger: Logger): void;
136
+ }
137
+
138
+ /**
139
+ * 每次都实时获取最新的 token/secretId/secretKey
140
+ */
141
+ export declare function getCloudBaseManager(options?: GetManagerOptions): Promise<CloudBase>;
142
+
143
+ /**
144
+ * Get cloud mode status for logging/debugging
145
+ */
146
+ export declare function getCloudModeStatus(): {
147
+ enabled: boolean;
148
+ source: string | null;
149
+ };
150
+
151
+ /**
152
+ * Get the default configured CloudBase MCP Server
153
+ */
154
+ export declare function getDefaultServer(): Promise<ExtendedMcpServer>;
155
+
156
+ export declare function getEnvId(cloudBaseOptions?: CloudBaseOptions): Promise<string>;
157
+
158
+ export declare interface GetFileInfoParams {
159
+ cloudPath: string;
160
+ }
161
+
162
+ /**
163
+ * Get interactive server instance (CommonJS compatible)
164
+ */
165
+ export declare function getInteractiveServerAsync(): Promise<InteractiveServer>;
166
+
167
+ export declare function getLoginState(options?: Parameters<typeof ensureLogin>[0]): Promise<{
168
+ secretId: string;
169
+ secretKey: string;
170
+ token: string | undefined;
171
+ envId: string | undefined;
172
+ } | Credential_2>;
173
+
174
+ declare interface GetManagerOptions {
175
+ requireEnvId?: boolean;
176
+ cloudBaseOptions?: CloudBaseOptions;
177
+ mcpServer?: any;
178
+ authStrategy?: 'fail_fast' | 'ensure';
179
+ }
180
+
181
+ declare interface IdeFileDescriptor {
182
+ path: string;
183
+ isMcpConfig?: boolean;
184
+ }
185
+
186
+ export declare const info: (message: string, data?: object | Error) => void;
187
+
188
+ export declare interface InteractiveResult {
189
+ type: "envId" | "clarification" | "confirmation";
190
+ data: any;
191
+ cancelled?: boolean;
192
+ switch?: boolean;
193
+ timeout?: boolean;
194
+ timeoutDuration?: number;
195
+ }
196
+
197
+ declare class InteractiveServer {
198
+ private app;
199
+ private server;
200
+ private wss;
201
+ private port;
202
+ private isRunning;
203
+ private currentResolver;
204
+ private sessionData;
205
+ private _mcpServer;
206
+ get mcpServer(): any;
207
+ set mcpServer(server: any);
208
+ private readonly DEFAULT_PORT;
209
+ private readonly FALLBACK_PORTS;
210
+ /** Idle timeout for HTTP/WS connections (e.g. long login). Avoids "connection disconnected" after ~1 min. */
211
+ private static readonly SERVER_IDLE_MS;
212
+ /** WebSocket ping interval to keep connection alive past proxies/firewalls. */
213
+ private static readonly WS_PING_INTERVAL_MS;
214
+ constructor(mcpServer?: any);
215
+ private cleanup;
216
+ /** Apply timeouts so long-lived login does not cause "connection disconnected". */
217
+ private applyServerTimeouts;
218
+ private setupExpress;
219
+ private setupWebSocket;
220
+ start(): Promise<number>;
221
+ stop(): Promise<void>;
222
+ collectEnvId(availableEnvs: any[], accountInfo?: {
223
+ uin?: string;
224
+ }, errorContext?: any, // EnvSetupContext
225
+ manager?: any, // CloudBase manager instance for refreshing env list
226
+ mcpServer?: any): Promise<InteractiveResult>;
227
+ clarifyRequest(message: string, options?: string[]): Promise<InteractiveResult>;
228
+ private escapeHtml;
229
+ private getEnvSetupHTML;
230
+ private getEnvSetupHTML_OLD;
231
+ private getClarificationHTML;
232
+ private getConfirmationHTML;
233
+ get running(): boolean;
234
+ get currentPort(): number;
235
+ }
236
+
237
+ /**
238
+ * Check if MCP is running in cloud mode
239
+ * Cloud mode is enabled by:
240
+ * 1. Command line argument --cloud-mode
241
+ * 2. Environment variable CLOUDBASE_MCP_CLOUD_MODE=true
242
+ * 3. Environment variable MCP_CLOUD_MODE=true
243
+ */
244
+ export declare function isCloudMode(): boolean;
245
+
246
+ export declare interface ListFilesParams {
247
+ prefix: string;
248
+ marker?: string;
249
+ }
250
+
251
+ declare type Logger = (data: {
252
+ type: string;
253
+ requestId?: string;
254
+ result?: any;
255
+ toolName?: string;
256
+ args?: any;
257
+ message?: string;
258
+ duration?: number;
259
+ [key: string]: any;
260
+ }) => void;
261
+
262
+ export declare function logout(): Promise<void>;
263
+
264
+ export { McpServer }
265
+
266
+ export declare const RAW_IDE_FILE_MAPPINGS: Record<string, IdeFileDescriptor[]>;
267
+
268
+ export declare const reportToolCall: (params: {
269
+ toolName: string;
270
+ success: boolean;
271
+ requestId?: string;
272
+ duration?: number;
273
+ error?: string;
274
+ inputParams?: any;
275
+ cloudBaseOptions?: CloudBaseOptions;
276
+ ide?: string;
277
+ }) => Promise<void>;
278
+
279
+ export declare const reportToolkitLifecycle: (params: {
280
+ event: "start" | "exit";
281
+ duration?: number;
282
+ exitCode?: number;
283
+ error?: string;
284
+ cloudBaseOptions?: CloudBaseOptions;
285
+ ide?: string;
286
+ }) => Promise<void>;
287
+
288
+ export declare function resetCloudBaseManagerCache(): void;
289
+
290
+ /**
291
+ * Check if a tool should be registered in cloud mode
292
+ * @param toolName - The name of the tool
293
+ * @returns true if the tool should be registered in current mode
294
+ */
295
+ export declare function shouldRegisterTool(toolName: string): boolean;
296
+
297
+ /**
298
+ * Simplify environment list data by keeping only essential fields for AI assistant
299
+ * This reduces token consumption when returning environment lists via MCP tools
300
+ * @param envList - Full environment list from API
301
+ * @returns Simplified environment list with only essential fields
302
+ */
303
+ export declare function simplifyEnvList(envList: any[]): any[];
304
+
305
+ export { StdioServerTransport }
306
+
307
+ /**
308
+ * 数据上报类
309
+ * 用于收集 MCP 工具使用情况和错误信息,帮助改进产品
310
+ *
311
+ * 隐私保护:
312
+ * - 可通过环境变量 CLOUDBASE_MCP_TELEMETRY_DISABLED=true 完全关闭
313
+ * - 不收集敏感信息(代码内容、具体文件路径等)
314
+ * - 使用设备指纹而非真实用户信息
315
+ * - 所有数据仅用于产品改进,不用于其他用途
316
+ */
317
+ declare class TelemetryReporter {
318
+ private deviceId;
319
+ private userAgent;
320
+ private additionalParams;
321
+ private enabled;
322
+ constructor();
323
+ /**
324
+ * 获取用户运行环境信息
325
+ * 包含操作系统、Node版本和MCP版本等信息
326
+ */
327
+ getUserAgent(): {
328
+ userAgent: string;
329
+ deviceId: string;
330
+ osType: string;
331
+ osRelease: string;
332
+ nodeVersion: string;
333
+ arch: string;
334
+ mcpVersion: string;
335
+ };
336
+ /**
337
+ * 获取设备唯一标识
338
+ * 基于主机名、CPU信息和MAC地址生成匿名设备指纹
339
+ */
340
+ private getDeviceId;
341
+ /**
342
+ * 发送HTTP请求
343
+ */
344
+ private postFetch;
345
+ /**
346
+ * 上报事件
347
+ * @param eventCode 事件代码
348
+ * @param eventData 事件数据
349
+ */
350
+ report(eventCode: string, eventData?: {
351
+ [key: string]: any;
352
+ }): Promise<void>;
353
+ /**
354
+ * 设置公共参数
355
+ */
356
+ addAdditionalParams(params: {
357
+ [key: string]: any;
358
+ }): void;
359
+ /**
360
+ * 检查是否启用
361
+ */
362
+ isEnabled(): boolean;
363
+ }
364
+
365
+ export declare const telemetryReporter: TelemetryReporter;
366
+
367
+ export declare interface ToolResponse {
368
+ success: boolean;
369
+ [key: string]: any;
370
+ }
371
+
372
+ export declare interface UploadFileParams {
373
+ cloudPath: string;
374
+ fileContent: string;
375
+ }
376
+
377
+ export declare const warn: (message: string, data?: object | Error) => void;
378
+
379
+ export { }