@cloudbase/cloudbase-mcp
Version:
腾讯云开发 MCP Server,通过AI提示词和MCP协议+云开发,让开发更智能、更高效,当你在Cursor/ VSCode GitHub Copilot/WinSurf/CodeBuddy/Augment Code/Claude Code等AI编程工具里写代码时,它能自动帮你生成可直接部署的前后端应用+小程序,并一键发布到腾讯云开发 CloudBase。
215 lines (205 loc) • 6.29 kB
TypeScript
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
export { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import * as _cloudbase_toolbox from '@cloudbase/toolbox';
import CloudBase from '@cloudbase/manager-node';
export { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
interface InteractiveResult {
type: 'envId' | 'clarification' | 'confirmation';
data: any;
cancelled?: boolean;
}
declare class InteractiveServer {
private app;
private server;
private wss;
private port;
private isRunning;
private currentResolver;
private sessionData;
private readonly DEFAULT_PORT;
private readonly FALLBACK_PORTS;
constructor();
private cleanup;
private setupExpress;
private setupWebSocket;
start(): Promise<number>;
stop(): Promise<void>;
collectEnvId(availableEnvs: any[]): Promise<InteractiveResult>;
clarifyRequest(message: string, options?: string[]): Promise<InteractiveResult>;
private getEnvSetupHTML;
private getLogsHTML;
private getClarificationHTML;
private getConfirmationHTML;
get running(): boolean;
get currentPort(): number;
}
interface UploadFileParams {
cloudPath: string;
fileContent: string;
}
interface ListFilesParams {
prefix: string;
marker?: string;
}
interface DeleteFileParams {
cloudPath: string;
}
interface GetFileInfoParams {
cloudPath: string;
}
interface ToolResponse {
success: boolean;
[key: string]: any;
}
interface DataModelField {
name: string;
type: 'string' | 'number' | 'boolean' | 'date' | 'array' | 'object' | 'objectId' | 'file' | 'image';
required?: boolean;
default?: any;
description?: string;
validation?: {
min?: number;
max?: number;
pattern?: string;
enum?: any[];
};
}
interface DataModelSchema {
type: 'object';
properties: Record<string, {
type: string;
description?: string;
required?: boolean;
default?: any;
validation?: any;
}>;
required?: string[];
}
interface DataModel {
id?: string;
name: string;
title: string;
schema: DataModelSchema;
envId?: string;
status?: 'draft' | 'published';
createdAt?: string;
updatedAt?: string;
}
interface CloudBaseOptions {
secretId?: string;
secretKey?: string;
token?: string;
envId?: string;
proxy?: string;
region?: string;
envType?: string;
}
/**
* 数据上报类
* 用于收集 MCP 工具使用情况和错误信息,帮助改进产品
*
* 隐私保护:
* - 可通过环境变量 CLOUDBASE_MCP_TELEMETRY_DISABLED=true 完全关闭
* - 不收集敏感信息(代码内容、具体文件路径等)
* - 使用设备指纹而非真实用户信息
* - 所有数据仅用于产品改进,不用于其他用途
*/
declare class TelemetryReporter {
private deviceId;
private userAgent;
private additionalParams;
private enabled;
constructor();
/**
* 获取用户运行环境信息
* 包含操作系统、Node版本和MCP版本等信息
*/
getUserAgent(): {
userAgent: string;
deviceId: string;
osType: string;
osRelease: string;
nodeVersion: string;
arch: string;
mcpVersion: string;
};
/**
* 获取设备唯一标识
* 基于主机名、CPU信息和MAC地址生成匿名设备指纹
*/
private getDeviceId;
/**
* 发送HTTP请求
*/
private postFetch;
/**
* 上报事件
* @param eventCode 事件代码
* @param eventData 事件数据
*/
report(eventCode: string, eventData?: {
[key: string]: any;
}): Promise<void>;
/**
* 设置公共参数
*/
addAdditionalParams(params: {
[key: string]: any;
}): void;
/**
* 检查是否启用
*/
isEnabled(): boolean;
}
declare const telemetryReporter: TelemetryReporter;
declare const reportToolkitLifecycle: (params: {
event: "start" | "exit";
duration?: number;
exitCode?: number;
error?: string;
}) => Promise<void>;
declare const info: (message: string, data?: any) => void;
declare const warn: (message: string, data?: any) => void;
declare const error: (message: string, data?: any) => void;
interface ExtendedMcpServer extends McpServer {
cloudBaseOptions?: CloudBaseOptions;
}
/**
* Create and configure a CloudBase MCP Server instance
* @param options Server configuration options
* @returns Configured McpServer instance
*/
declare function createCloudBaseMcpServer(options?: {
name?: string;
version?: string;
enableTelemetry?: boolean;
cloudBaseOptions?: CloudBaseOptions;
}): ExtendedMcpServer;
/**
* Get the default configured CloudBase MCP Server
*/
declare function getDefaultServer(): ExtendedMcpServer;
declare function getLoginState(): Promise<_cloudbase_toolbox.Credential>;
declare function logout(): Promise<void>;
declare function getEnvId(cloudBaseOptions?: CloudBaseOptions): Promise<string>;
declare function resetCloudBaseManagerCache(): void;
interface GetManagerOptions {
requireEnvId?: boolean;
cloudBaseOptions?: CloudBaseOptions;
}
/**
* 每次都实时获取最新的 token/secretId/secretKey
*/
declare function getCloudBaseManager(options?: GetManagerOptions): Promise<CloudBase>;
/**
* 使用传入的 CloudBase 配置创建 manager,不使用缓存
* @param cloudBaseOptions 传入的 CloudBase 配置选项
* @returns CloudBase manager 实例
*/
declare function createCloudBaseManagerWithOptions(cloudBaseOptions: CloudBaseOptions): CloudBase;
/**
* Get interactive server instance (CommonJS compatible)
*/
declare function getInteractiveServerAsync(): Promise<InteractiveServer>;
export { createCloudBaseManagerWithOptions, createCloudBaseMcpServer, error, getCloudBaseManager, getDefaultServer, getEnvId, getInteractiveServerAsync, getLoginState, info, logout, reportToolkitLifecycle, resetCloudBaseManagerCache, telemetryReporter, warn };
export type { CloudBaseOptions, DataModel, DataModelField, DataModelSchema, DeleteFileParams, ExtendedMcpServer, GetFileInfoParams, InteractiveResult, ListFilesParams, ToolResponse, UploadFileParams };