### Complete Example: Multi-Agent Server Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/py/server-quickstart.md A comprehensive example demonstrating a production-ready multi-agent server setup using FastAPI, CloudBase Agent SDK, and environment variable loading. ```APIDOC ## Multi-Agent Server Example ### Description This example showcases a production-ready FastAPI server capable of hosting multiple CloudBase agents. It includes setup for environment variables, logging, CORS, and mounting agent services. ### Method N/A (Server setup and execution) ### Endpoint Multiple endpoints are configured based on mounted agent services, including `/my-agent-1`, `/my-agent-2`, etc. ### Parameters N/A ### Request Example N/A ### Response N/A #### Server Startup - **Command**: `uvicorn main:main_app --reload` (assuming the file is named `main.py`) - **Description**: Starts the FastAPI application. #### Example Agent Setup (within the main file) ```python #!/usr/bin/env python3 import logging import uvicorn from dotenv import load_dotenv from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from cloudbase_agent.langgraph import LangGraphAgent from cloudbase_agent.server import ( AgentCreatorResult, AgentServiceApp, HealthzConfig, OpenAIChatCompletionRequest, RunAgentInput, create_openai_adapter, create_send_message_adapter, ) from cloudbase_agent.server.errors import install_exception_handlers # Load environment variables load_dotenv() # Configure logging logging.basicConfig(level=logging.INFO) # Import your agent workflows from agents.chat.agent import build_chat_workflow from agents.assistant.agent import build_assistant_workflow # --- Agent Creator Functions --- def create_chat_agent() -> AgentCreatorResult: # ... implementation for chat agent ... agent = LangGraphAgent(name="chat-agent", graph=build_chat_workflow()) return {"agent": agent} def create_assistant_agent() -> AgentCreatorResult: # ... implementation for assistant agent ... agent = LangGraphAgent(name="assistant-agent", graph=build_assistant_workflow()) return {"agent": agent} # --- FastAPI App Setup --- main_app = FastAPI(title="Multi-Agent Service") main_app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # --- Mount Agent Services --- # Agent 1: Chat Agent agent_service_chat = AgentServiceApp() agent_fastapi_chat = agent_service_chat.build( create_chat_agent, base_path="/chat", enable_openai_endpoint=True, enable_healthz=True, healthz_config=HealthzConfig(service_name="chat-agent", version="1.0.0") ) main_app.mount("/my-agent-1", agent_fastapi_chat) # Agent 2: Assistant Agent agent_service_assistant = AgentServiceApp() agent_fastapi_assistant = agent_service_assistant.build( create_assistant_agent, base_path="/assistant", enable_openai_endpoint=True, enable_healthz=True, healthz_config=HealthzConfig(service_name="assistant-agent", version="1.0.0") ) main_app.mount("/my-agent-2", agent_fastapi_assistant) # --- Root Endpoint --- @main_app.get("/") async def root(): return {"message": "Welcome to the Multi-Agent Service!"} # --- Main Execution Block --- if __name__ == "__main__": uvicorn.run(main_app, host="0.0.0.0", port=8000) ``` ``` -------------------------------- ### Installation Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/ts/server-quickstart.md Instructions on how to install the @cloudbase/agent-server package. It is recommended to always use the @latest tag. ```APIDOC ## Installation ```bash npm install @cloudbase/agent-server@latest ``` **Important:** Always use `@latest` for `@cloudbase/agent-*` packages. Do NOT use version ranges like `^1.0.0` or exact versions, as these versions may not exist. The packages do not follow traditional semantic versioning. ``` -------------------------------- ### Installation Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/ts/ui-miniprogram.md Install the latest version of the SDK using npm. ```APIDOC ## Installation ```bash npm install @cloudbase/agent-ui-miniprogram@latest ``` ``` -------------------------------- ### Basic Coze Agent Initialization and Service Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/py/adapter-coze.md Demonstrates the basic setup for initializing the CozeAgentAdapter with bot ID and API key, and running it as an AgentServiceApp. This is the simplest way to get a Coze bot running through the CloudBase Agent. ```python from cloudbase_agent.coze import CozeAgentAdapter from cloudbase_agent.server import AgentServiceApp def create_agent(): return CozeAgentAdapter( bot_id="your-bot-id", api_key="your-api-key" ) AgentServiceApp().run(create_agent, port=8000) ``` -------------------------------- ### Project Installation and Dependency Management Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/CONTRIBUTING.md Instructions for cloning the project repository and installing necessary dependencies using npm, yarn, or pnpm. ```bash git clone https://github.com/TencentCloudBase/CloudBase-AI-Tool-Kit.git cd CloudBase-AI-Tool-Kit ``` ```bash # 使用 npm npm install # 或使用 yarn yarn install # 或使用 pnpm pnpm install ``` -------------------------------- ### Standardize Skills Installation Commands Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/specs/openclaw-ide-support/design.md Defines the recommended installation commands for CloudBase Skills. The general command allows for interactive selection, while the OpenClaw-specific command uses the -y flag for a streamlined, one-step installation experience. ```bash # General recommendation npx skills add tencentcloudbase/cloudbase-skills # OpenClaw specific recommendation npx skills add tencentcloudbase/cloudbase-skills -y ``` -------------------------------- ### Integrate Langchain Agent with Cloudbase Agent Server Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/ts/adapter-langchain.md Shows how to run a LangChain agent using the @cloudbase/agent-server. This example demonstrates the basic structure for starting the server and providing the agent. ```typescript import { run } from "@cloudbase/agent-server"; run({ createAgent: () => ({ agent }), port: 9000, }); ``` -------------------------------- ### Client Tool Example Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/ts/ui-miniprogram.md An example of how to add a client-side tool to the agent's capabilities. ```APIDOC ## Client Tool Example ```typescript Component({ behaviors: [createAGUIBehavior({ transport })], lifetimes: { attached() { this.agui.addTool({ name: "show_toast", description: "Show a toast message", parameters: { type: "object", properties: { title: { type: "string" } }, required: ["title"] }, handler: async ({ args }) => { wx.showToast({ title: args.title }); return { success: true }; } }); } } }); ``` ``` -------------------------------- ### Install @cloudbase/agent-ui-miniprogram SDK Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/ts/ui-miniprogram.md Installs the latest version of the WeChat Mini Program SDK for AG-UI protocol using npm. ```bash npm install @cloudbase/agent-ui-miniprogram@latest ``` -------------------------------- ### Install CloudBase Agent Packages Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/py/skill.md Commands to install the core framework and specific integration packages via pip. ```bash pip install cloudbase-agent-langgraph pip install cloudbase-agent-core pip install cloudbase-agent-server pip install cloudbase-agent-tools pip install cloudbase-agent-storage pip install cloudbase-agent-observability pip install cloudbase-agent-coze pip install cloudbase-agent-crewai ``` -------------------------------- ### Install and Use CloudBase AI CLI Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/scripts/releases/github-release.md This snippet shows how to install the CloudBase CLI globally and initiate the AI command-line interface. It serves as the entry point for managing various AI programming tools. ```bash # Install npm install @cloudbase/cli@latest -g # Start using tcb ai ``` -------------------------------- ### Client Tool Example: show_toast Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/ts/ui-miniprogram.md Provides an example of adding a client tool named 'show_toast' to the agent, which displays a toast message in the WeChat Mini Program using wx.showToast. ```typescript Component({ behaviors: [createAGUIBehavior({ transport })], lifetimes: { attached() { this.agui.addTool({ name: "show_toast", description: "Show a toast message", parameters: { type: "object", properties: { title: { type: "string" } }, required: ["title"] }, handler: async ({ args }) => { wx.showToast({ title: args.title }); return { success: true }; } }); } } }); ``` -------------------------------- ### Standard CloudBase Skills Installation Command Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/specs/openclaw-ide-support/tasks.md The standardized command used to install CloudBase Skills across the documentation and IDE integration flows. ```bash npx skills add tencentcloudbase/cloudbase-skills ``` ```bash npx skills add tencentcloudbase/cloudbase-skills -y ``` -------------------------------- ### get() Function: Cross-Document Permission Verification Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/no-sql-web-sdk/security-rules.md Explains the usage, syntax, examples, limitations, and billing implications of the `get()` function for accessing data in other documents during permission checks. ```APIDOC ### Built-in Functions #### get() Function: Cross-Document Permission Verification **Function Description:** The `get()` function allows accessing other document data during permission verification, enabling complex cross-document permission control. **Syntax:** `get('database.collectionName.documentId')` **Usage Examples:** **Role-based Permission Control:** ```json { "read": "get('database.user_roles.' + auth.uid).role in ['admin', 'editor']", "write": "get('database.user_roles.' + auth.uid).role == 'admin'" } ``` **Associated Data Permissions:** ```json { "read": "auth.uid == get('database.projects.' + doc.projectId).owner" } ``` **Usage Limitations:** > **Important:** When using the `get()` function, note the following limitations: > - **Variable restrictions in get parameters**: Variables `doc` that exist in get parameters must appear in query conditions in `==` or `in` format. If using `in` format, only `in` with a single value is allowed, i.e., `doc.shopId in array, array.length == 1` > - Maximum 3 `get` functions per expression > - Maximum access to 10 different documents > - Maximum nesting depth of 2 levels (i.e., `get(get(path))`) > - Generates additional database read operations (billed) **Billing Notes:** > **Important:** Security rules themselves are not charged, but additional data access by security rules will be counted in billing: > - **get() function**: Each `get()` produces additional data access > - **Document ID queries for all write operations**: All write operations for document ID queries produce one data access > - **Variable usage**: When not using variables, each `get()` produces one read operation. When using variables, each `get()` produces one read operation for each variable value. For example: rule `get(\`database.collection.${doc._id}\`).test`, when querying `_.or([{_id:1},{_id:2},{_id:3},{_id:4},{_id:5}])` will produce 5 reads. The system will cache reads for the same doc and field. > > **Important:** Using `get()` or accessing `doc` counts toward database quota as it reads from the service. ``` -------------------------------- ### Deploy Agent with AgentServiceApp Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/py/references/server.md Demonstrates three ways to deploy an agent: a one-line execution, a customizable build process, and manual integration using core adapters for maximum flexibility. ```python # Method 1: One-line AgentServiceApp().run(create_agent, port=9000) # Method 2: Build + customize app = AgentServiceApp() fastapi_app = app.build(create_agent, base_path="/api", enable_openai_endpoint=True, enable_healthz=True) uvicorn.run(fastapi_app, host="0.0.0.0", port=9000) # Method 3: Core adapters @app.post("/my-agent/send-message") async def send_message(request: RunAgentInput): return await create_send_message_adapter(create_my_agent, request) ``` -------------------------------- ### Install CloudBase AI CLI Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/README-ZH.md Install the CloudBase CLI globally to access AI-assisted development features. This simplifies the setup process across various AI programming tools. ```bash npm install @cloudbase/cli@latest -g ``` -------------------------------- ### All Options for run() Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/ts/server-quickstart.md Provides a comprehensive list of all available options for the `run()` function, including `createAgent`, `port`, `basePath`, `cors`, `useAGUI`, `aguiOptions`, `logger`, and `observability`. ```APIDOC ## All Options ```typescript run({ createAgent, port: 9000, basePath: "/api/", // Custom base path (default: dual endpoints) cors: true, // or { origin: "https://..." } useAGUI: true, // Enable /agui endpoint (default: true) aguiOptions: { runtimeOptions: {}, endpointOptions: {} }, logger: createConsoleLogger("debug"), observability: { type: "otlp", url: "...", headers: {...} } }); ``` ``` -------------------------------- ### Minimal Node.js Express HTTP Function Example Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloud-functions/SKILL.md A basic example of a Node.js HTTP Function using Express. It sets up a simple GET route for the root path that returns a JSON message. This illustrates the minimal structure required for an Express-based HTTP function, including listening on port 9000. ```javascript const express = require('express'); const app = express(); app.use(express.json()); app.get('/', (req, res) => res.json({ message: 'Hello!' })); app.listen(9000); // Must be port 9000 ``` -------------------------------- ### Initialize and run a Cloudbase Agent server Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/ts/skill.md Demonstrates how to initialize an agent server using the LanggraphAgent adapter and start it on a specified port. ```typescript import { run } from "@cloudbase/agent-server"; import { LanggraphAgent } from "@cloudbase/agent-adapter-langgraph"; run({ createAgent: () => ({ agent: new LanggraphAgent({ workflow }) }), port: 9000, }); ``` -------------------------------- ### CloudBase AI CLI Installation Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/README-ZH.md This command demonstrates the recommended method for setting up CloudBase AI capabilities using the CloudBase AI CLI. It assumes Node.js and a CloudBase environment are already configured. ```bash cloudbase-cli install ``` -------------------------------- ### Express Static File Server Setup Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/specs/env-ui-optimization/implementation-comparison.md This example demonstrates setting up an Express server to serve static files. It includes a typical directory structure for a project utilizing Express for static content delivery, such as HTML, CSS, and JavaScript files. ```typescript mcp/ ├── src/ │ ├── interactive-server.ts # Express 服务器 │ └── templates/ │ └── env-setup/ │ └── renderer.ts # 服务端渲染逻辑 └── static/ # 静态文件(源码) └── env-setup/ ├── index.html ├── styles.css └── script.js ``` -------------------------------- ### Build Process and Output Structure Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/specs/env-ui-optimization/implementation-comparison.md Commands for installing dependencies and building the project using npm. It also illustrates the expected output directory structure after a successful build, including the compiled JavaScript and static assets. ```bash # 1. 安装依赖 npm install copy-webpack-plugin --save-dev # 2. 构建 npm run build # 输出目录结构: # dist/ # ├── index.cjs # └── static/ # └── env-setup/ # ├── index.html # ├── styles.css # └── script.js ``` -------------------------------- ### Initialize CloudBase MCP Server Source: https://context7.com/tencentcloudbase/cloudbase-mcp/llms.txt Demonstrates how to instantiate the CloudBase MCP server with authentication credentials, plugin configurations, and IDE integration settings. ```typescript import { createCloudBaseMcpServer } from "@cloudbase/cloudbase-mcp"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; const server = await createCloudBaseMcpServer({ name: "cloudbase-mcp", version: "1.0.0", enableTelemetry: true, cloudBaseOptions: { envId: "your-env-id", secretId: "your-secret-id", secretKey: "your-secret-key", region: "ap-shanghai", token: "optional-token" }, pluginsEnabled: ["env", "database", "functions", "hosting", "storage"], pluginsDisabled: ["cloudrun"], ide: "Cursor" }); const transport = new StdioServerTransport(); await server.connect(transport); ``` -------------------------------- ### Install Dependencies Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/py/adapter-langgraph.md Install the necessary packages for the LangGraph adapter, including cloudbase-agent-langgraph, langgraph, and langchain. ```APIDOC ## Install Dependencies ### Description Install the necessary packages for the LangGraph adapter, including `cloudbase-agent-langgraph`, `langgraph`, and `langchain`. ### Command ```bash pip install cloudbase_agent[langgraph] ``` ### Included Packages - `cloudbase-agent-langgraph`: LangGraph adapter - `langgraph`: LangGraph framework - `langchain`: LangChain core - `langchain-openai`: OpenAI integration ``` -------------------------------- ### Install @cloudbase/js-sdk Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/relational-database-web/SKILL.md Installs the CloudBase JavaScript SDK, which is required for interacting with CloudBase services from a web application. ```bash npm install @cloudbase/js-sdk ``` -------------------------------- ### Deploy Application with manageAgent Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/py/agent-deployment.md This command demonstrates how to deploy the application using the manageAgent utility. Key parameters include the action (create), runtime (Python3.10), and targetPath. It emphasizes that the 'env/' directory must be included in the deployment package. ```bash # manageAgent(action="create", runtime="Python3.10", installDependency=false, targetPath="...") ``` -------------------------------- ### Coze Agent Initialization with All Options Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/py/adapter-coze.md Shows how to initialize the CozeAgentAdapter with all available configuration options, including base URL and debug mode. This allows for more customized integration with the Coze API. ```python adapter = CozeAgentAdapter( bot_id="bot_1234567890", api_key="sk-1234567890", base_url="https://api.coze.com", debug_mode=True ) ``` -------------------------------- ### Complete Complex Query Example Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/no-sql-web-sdk/complex-queries.md A comprehensive example demonstrating the combination of `where`, `field`, `orderBy`, `limit`, and `skip`. ```APIDOC ## Complete Complex Query Example Here's a comprehensive example combining all query features: ```javascript const _ = db.command; const result = await db.collection('todos') .where({ // Status must be 'active' or 'pending' status: _.in(['active', 'pending']), // Priority is high priority: 'high', // Age greater than 18 age: _.gt(18), // Created in the last 30 days createdAt: _.gte(new Date(Date.now() - 30 * 24 * 60 * 60 * 1000)) }) .field({ title: true, status: true, priority: true, assignee: true, createdAt: true }) .orderBy('createdAt', 'desc') .orderBy('priority', 'asc') .limit(50) .skip(0) .get(); console.log('Found', result.data.length, 'todos'); console.log('Results:', result.data); ``` ``` -------------------------------- ### CloudBase Web SDK Authentication Setup Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/doc/prompts/auth-web.mdx This snippet demonstrates the initialization of the CloudBase SDK for web authentication, including environment configuration and enabling session detection. ```APIDOC ## Initialization for Web Authentication ### Description Initialize the CloudBase SDK with your environment ID, region, and publishable key. Enable session detection to manage user authentication state. ### Method `cloudbase.init(config)` ### Parameters - **env** (string) - Required - Your CloudBase environment ID. - **region** (string) - Optional - The CloudBase environment region (defaults to 'ap-shanghai'). - **accessKey** (string) - Required - Your CloudBase publishable key. - **auth** (object) - Required - Configuration for authentication. - **detectSessionInUrl** (boolean) - Required - Enables session detection within the URL. ### Request Example ```js import cloudbase from '@cloudbase/js-sdk' const app = cloudbase.init({ env: `your-env-id`, region: `your-region`, accessKey: 'your-publishable-key', auth: { detectSessionInUrl: true }, }) const auth = app.auth ``` ### Response - **auth** (object) - The authentication instance from the initialized CloudBase app. ``` -------------------------------- ### Install Cloudbase Agent dependencies Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/ts/skill.md Installs the necessary Cloudbase agent server and LangGraph adapter packages using npm. ```bash npm install @cloudbase/agent-server@latest @cloudbase/agent-adapter-langgraph@latest ``` -------------------------------- ### Basic Usage of LangchainAgent Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/ts/adapter-langchain.md Demonstrates the fundamental setup for creating a LangchainAgent, including initializing the model, checkpointer, and middleware. ```APIDOC ## Basic Usage of LangchainAgent ### Description This snippet shows the basic integration of LangchainAgent with Langchain's `createAgent` function, including setting up a model and middleware. ### Method N/A (Code Example) ### Endpoint N/A (Code Example) ### Parameters N/A ### Request Example N/A ### Response N/A ```typescript import { createAgent as createLangchainAgent } from "langchain"; import { MemorySaver } from "@langchain/langgraph"; import { ChatOpenAI } from "@langchain/openai"; import { LangchainAgent, clientTools } from "@cloudbase/agent-adapter-langchain"; const model = new ChatOpenAI({ model: "gpt-4o" }); const checkpointer = new MemorySaver(); const lcAgent = createLangchainAgent({ model, checkpointer, middleware: [clientTools()], }); const agent = new LangchainAgent({ agent: lcAgent }); ``` ``` -------------------------------- ### Deployment Methods Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/ts/server-quickstart.md Demonstrates different ways to deploy agents using the @cloudbase/agent-server package: standalone 'run()', creating an Express app with 'createExpressServer()', and adding routes to an existing Express app with 'createExpressRoutes()'. ```APIDOC ## Deployment Methods ### run() - Standalone ```typescript import { run } from "@cloudbase/agent-server"; run({ createAgent: () => ({ agent }), port: 9000 }); ``` ### createExpressServer() - Get App ```typescript import { createExpressServer } from "@cloudbase/agent-server"; const app = createExpressServer({ createAgent: () => ({ agent }) }); app.listen(9000); ``` ### createExpressRoutes() - Add to Existing ```typescript import { createExpressRoutes } from "@cloudbase/agent-server"; createExpressRoutes({ createAgent: () => ({ agent }), express: app, basePath: "/api/" }); ``` ``` -------------------------------- ### writeSecurityRule - Simple Permission Examples Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/no-sql-web-sdk/security-rules.md Examples of using writeSecurityRule to apply common, predefined security permission levels to database collections. ```APIDOC ## POST /writeSecurityRule (Simple Permissions) ### Description Applies predefined security rules to database collections. ### Method POST ### Endpoint /writeSecurityRule ### Parameters #### Request Body - **resourceType** (string) - Required - Must be "database". - **resourceId** (string) - Required - The name of the collection. - **aclTag** (string) - Required - The simple permission type: - "READONLY": Public read, creator-only write. - "PRIVATE": Only creator and admin can access. - "ADMINWRITE": Public read, admin-only write. - "ADMINONLY": Admin-only access. ### Request Example (Public read, creator-only write) ```json { "resourceType": "database", "resourceId": "posts", "aclTag": "READONLY" } ``` ### Request Example (Private collection) ```json { "resourceType": "database", "resourceId": "userSettings", "aclTag": "PRIVATE" } ``` ### Request Example (Public read, admin-only write) ```json { "resourceType": "database", "resourceId": "announcements", "aclTag": "ADMINWRITE" } ``` ### Request Example (Admin-only access) ```json { "resourceType": "database", "resourceId": "adminLogs", "aclTag": "ADMINONLY" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Security rule updated successfully." } ``` ``` -------------------------------- ### Create Your First Agent Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/py/adapter-langgraph.md Example of creating a simple chatbot agent using LangGraph and wrapping it with CloudBase Agent. ```APIDOC ## Create Your First Agent ### Description This example demonstrates how to define a LangGraph workflow with a chat node, compile it, and then wrap it using `LangGraphAgent` from the CloudBase Agent SDK. ### Agent Definition (`agent.py`) ```python from langgraph.graph import StateGraph, MessagesState, END, START from langgraph.checkpoint.memory import MemorySaver from langchain_openai import ChatOpenAI from langchain_core.messages import SystemMessage from cloudbase_agent.langgraph import LangGraphAgent # Define state class State(MessagesState): pass # Define chat node def chat_node(state: State, config, writer): """Generate AI response.""" chat_model = ChatOpenAI(model="gpt-4o-mini") system = SystemMessage(content="You are a helpful assistant.") messages = [system, *state["messages"]] chunks = [] for chunk in chat_model.stream(messages, config): writer({"messages": [chunk]}) # Stream to client chunks.append(chunk) return {"messages": chunks} # Build workflow def build_workflow(): graph = StateGraph(State) graph.add_node("chat", chat_node) graph.add_edge(START, "chat") graph.add_edge("chat", END) memory = MemorySaver() return graph.compile(checkpointer=memory) # Wrap with CloudBase Agent agent = LangGraphAgent( name="chatbot", description="A helpful conversational assistant", graph=build_workflow() ) ``` ### Deployment (`server.py`) ```python from cloudbase_agent.server import AgentServiceApp AgentServiceApp().run( lambda: {"agent": agent}, port=9000, enable_openai_endpoint=True ) ``` ``` -------------------------------- ### Basic Usage Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/ts/ui-miniprogram.md Demonstrates how to integrate the SDK into a WeChat Mini Program component using the `createAGUIBehavior` function. ```APIDOC ## Basic Usage ```typescript import { createAGUIBehavior, CloudbaseTransport } from "@cloudbase/agent-ui-miniprogram"; const transport = new CloudbaseTransport({ botId: "your-bot-id" }); Component({ behaviors: [createAGUIBehavior({ transport })], methods: { onSend() { this.agui.sendMessage(this.data.inputText); } } }); ``` ``` -------------------------------- ### CloudBase AI CLI Installation Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/README.md Command to install the CloudBase AI CLI tool for managing cloud resources and AI-native development workflows. ```bash npm install -g @cloudbase/cli ``` -------------------------------- ### Install @cloudbase/agent-server Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/config/source/skills/cloudbase-agent/ts/server-quickstart.md Installs the latest version of the @cloudbase/agent-server package. It's crucial to use `@latest` as these packages do not follow standard semantic versioning. ```bash npm install @cloudbase/agent-server@latest ``` -------------------------------- ### Conditional Tool Registration Example (JavaScript) Source: https://github.com/tencentcloudbase/cloudbase-mcp/blob/main/specs/cloud-mode-optimization/implementation-summary.md Demonstrates how to use the `conditionalRegisterTool` function to register a tool only if it's compatible with the current operating mode (local or cloud). ```javascript // Assuming 'server', 'toolConfig', and 'handler' are defined elsewhere // import { conditionalRegisterTool } from './utils'; // Adjust path as needed // Example placeholder values const server = { registerTool: (name, config, handler) => console.log(`Registered ${name}`) }; const toolConfig = {}; const handler = () => {}; // Registering the 'uploadFile' tool conditionally conditionalRegisterTool( server, "uploadFile", toolConfig, handler ); // Example of a compatible tool registration (assuming it's not in the incompatible list) conditionalRegisterTool( server, "listBuckets", // Example of a compatible tool toolConfig, handler ); ```