GitHub 仓库:lechan775/mobile-open-claw ⚠️ 私有仓库
后端:Spring Boot 3.4.3 + Google ADK 0.5.0 + D Domain-Driven Design
前端:Android Jetpack Compose + Nginx 静态 Web 页面
核心能力:多智能体自动装配 · MCP 协议集成 · 并行/串行/循环工作流 · SSE 流式对话
mobile-open-claw 是一套移动端 AI Agent 全栈应用,解决的核心问题是:如何在一套工程框架内,以声明式配置(YAML)快速定义、装配和运行多个 AI Agent,并通过统一的 REST API 对外暴露对话能力。
它的设计初衷是降低 AI Agent 应用的工程门槛——你只需要写一份 YAML 配置文件,就可以得到一个拥有 MCP 工具调用、多智能体协作能力、且同时支持 Web 和 Android 客户端的完整应用。
graph TB
subgraph Clients["客户端层"]
Web["🌐 Nginx 静态页面<br/>login.html + index.html"]
Android["📱 Android App<br/>Jetpack Compose + Material3"]
end
subgraph Trigger["触发器层 (Trigger)"]
Controller["AgentServiceController<br/>REST API + SSE Stream"]
end
subgraph App["应用编排层 (App)"]
AutoConfig["AiAgentAutoConfig<br/>启动时自动装配 Agent"]
end
subgraph Domain["领域层 (Domain) - 核心"]
Armory["🔧 ArmoryService<br/>Agent 装配流水线"]
Chat["💬 ChatService<br/>会话管理与对话调度"]
MCP["🔌 MCP 协议<br/>Stdio / SSE / Local"]
Skills["📦 Skills 技能系统"]
Workflow["⚙️ Agent 工作流<br/>Parallel / Sequential / Loop"]
end
subgraph Infra["基础设施层 (Infrastructure)"]
DAO["MyBatis DAO"]
Gateway["外部 Gateway"]
Redis["Redis 缓存"]
end
Web --> Controller
Android --> Controller
Controller --> Chat
AutoConfig --> Armory
Armory --> Workflow
Armory --> MCP
Armory --> Skills
Chat --> Armory
Domain --> Infra
| 模块 | 职责 | 关键类 |
|---|---|---|
| api | 接口契约定义 | IAgentService, DTOs |
| app | 应用启动 & 自动装配 | Application, AiAgentAutoConfig |
| domain | 领域模型 & 核心逻辑 | ArmoryService, ChatService, Agent 节点树 |
| infrastructure | 数据访问 & 外部集成 | DAO, Gateway, Redis |
| trigger | HTTP 控制器 & 事件监听 | AgentServiceController |
| types | 公共枚举/常量/异常 | ResponseCode, AppException |
这是整个项目最核心的设计——基于责任链模式的 Agent 自动装配引擎。
yamlai:
agent:
config:
enabled: true
tables:
myAgent:
app-name: MyAssistant
agent:
agent-id: 100001
agent-name: 通用助手
agent-desc: 支持百度搜索的通用对话助手
module:
ai-api:
base-url: https://apis.xxx.cn
api-key: sk-xxx
completions-path: v1/chat/completions
chat-model:
model: gpt-4.1
tool-mcp-list: # MCP 工具列表
- sse:
name: baidu-search
base-uri: http://appbuilder.baidu.com/v2/ai_search/mcp/
sse-endpoint: sse?api_key=xxx
- local:
name: myToolCallbackProvider # 本地工具
tool-skills-list: # Skills 技能
- type: resource
path: agent/skills
agents:
- name: assistant
description: 通用AI助手
instruction: |
你是一个全能的AI助手,可以使用百度搜索获取最新信息。
runner:
agent-name: assistant
应用启动时,AiAgentAutoConfig 监听 ApplicationReadyEvent,触发以下装配流程:
flowchart LR
Start(["🚀 应用启动"]) --> Config["读取 YAML 配置<br/>AiAgentAutoConfigProperties"]
Config --> Factory["DefaultArmoryFactory<br/>构建责任链"]
Factory --> AiApi["AiApiNode<br/>创建 OpenAI API 客户端"]
AiApi --> ChatModel["ChatModelNode<br/>装配 ChatModel + MCP + Skills"]
ChatModel --> Agent["AgentNode<br/>逐条注册 LlmAgent"]
Agent --> Workflow{"存在 AgentWorkflow?"}
Workflow -->|Parallel| PNode["ParallelAgentNode<br/>并行执行"]
Workflow -->|Sequential| SNode["SequentialAgentNode<br/>串行执行"]
Workflow -->|Loop| LNode["LoopAgentNode<br/>循环迭代"]
Workflow -->|无| Runner["RunnerNode<br/>注册 InMemoryRunner"]
PNode --> Runner
SNode --> Runner
LNode --> Runner
Runner --> Done(["✅ Agent 就绪"])
java// 每个 Node 继承 AbstractArmorySupport,实现策略路由
@Service
public class ChatModelNode extends AbstractArmorySupport {
@Override
protected AiAgentRegisterVO doApply(ArmoryCommandEntity param, DynamicContext ctx) {
// 1. 构建 Spring AI ChatModel
// 2. 注入 MCP 工具回调(Stdio/SSE/Local)
// 3. 注入 Skills 技能
// 4. 路由到下一个节点
return router(requestParameter, dynamicContext);
}
@Override
public StrategyHandler<...> get(...) {
return agentNode; // 下一站:AgentNode
}
}
责任链模式来自
xfg-wrench-starter-design-framework(@小傅哥的设计模式框架),每个 Node 只关心自己的装配逻辑,通过router()传递到下一节点。
mobile-open-claw 支持三种 Agent 编排模式,直接封装自 Google ADK:
多个子 Agent 同时运行,互不依赖,适用于多维度信息收集:
yamlagent-workflows:
- type: parallel
name: ParallelResearch
sub-agents:
- RenewableEnergyResearcher # 研究可再生能源
- EVResearcher # 研究电动车技术
- CarbonCaptureResearcher # 研究碳捕获
Agent 按顺序执行,后续 Agent 可引用前置 Agent 的输出(通过 output-key + {} 占位符):
yamlagent-workflows:
- type: sequential
name: ResearchAndSynthesis
sub-agents:
- ParallelResearch # 先并行研究
- SynthesisAgent # 再汇总生成报告
子 Agent 迭代执行直到收敛或达到 maxIterations:
yamlagent-workflows:
- type: loop
name: SelfImprovingWriter
max-iterations: 3
sub-agents:
- DraftAgent
- ReviewAgent
支持三种 MCP (Model Context Protocol) 工具接入模式,覆盖本地到远程的全部场景:
| 模式 | 通信方式 | 实现类 | 适用场景 |
|---|---|---|---|
| Stdio | 标准输入输出进程 | StdioToolMcpCreateService | 本地命令行工具 |
| SSE | HTTP Server-Sent Events | SSEToolMcpCreateService | 远程 MCP Server |
| Local | JVM 直接调用 | LocalToolMcpCreateService | Spring Bean 方法 |
java// SSE 模式核心实现
HttpClientSseClientTransport transport = HttpClientSseClientTransport
.builder(baseUri)
.sseEndpoint(sseEndpoint)
.build();
McpSyncClient client = McpClient.sync(transport)
.requestTimeout(Duration.ofMillis(500000))
.build();
ToolCallback[] callbacks = SyncMcpToolCallbackProvider.builder()
.mcpClients(client)
.build()
.getToolCallbacks();
基础路径:/api/v1/ | 端口:8091 | CORS:全部开放
| 方法 | 路径 | 说明 |
|---|---|---|
GET | /api/v1/query_ai_agent_config_list | 获取可用 Agent 列表 |
POST | /api/v1/create_session | 创建对话会话 |
POST | /api/v1/chat | 提交对话(同步) |
POST | /api/v1/chat_stream | 流式对话(SSE) |
统一响应结构:
json{
"code": "0000",
"info": "成功",
"data": { "content": "..." }
}
| 层级 | 技术 | 版本 |
|---|---|---|
| AI 编排引擎 | Google ADK | 0.5.0 |
| AI 框架 | Spring AI | 1.1.0-M3 |
| LangChain4j | 1.4.0 | |
| 后端框架 | Spring Boot | 3.4.3 |
| 语言 | Java | 17 |
| ORM | MyBatis | 3.0.4 |
| 数据库 | MySQL | 8.x |
| 缓存 | Guava Cache | 32.1.3-jre |
| Android UI | Jetpack Compose + Material3 | — |
| Web 前端 | 原生 HTML/CSS/JS (Nginx) | — |
| 容器化 | Docker + Docker Compose | — |
bash# 1. 克隆仓库
git clone https://github.com/lechan775/mobile-open-claw.git
cd mobile-open-claw/mobile-open-claw
# 2. 配置 application-dev.yml 中的数据库连接 & API Key
# 3. 启动
cd mobile-open-claw-app
mvn spring-boot:run -Dspring-boot.run.profiles=dev
访问 http://localhost:8091 即可使用。
bashcd docs/dev-ops
docker-compose -f docker-compose-environment.yml up -d # MySQL 等基础设施
docker-compose -f docker-compose-app.yml up -d # Nginx + 应用
openclaw_andro/ ├── mobile-open-claw/ # 🔧 后端 (Spring Boot + DDD) │ ├── mobile-open-claw-api/ # API 接口契约层 │ ├── mobile-open-claw-app/ # 应用启动 & 自动配置 │ ├── mobile-open-claw-domain/ # 领域核心(Agent/Workflow/MCP/Skills) │ ├── mobile-open-claw-infrastructure/ # 基础设施(DAO/Gateway/Redis) │ ├── mobile-open-claw-trigger/ # HTTP 控制器 & 事件触发 │ ├── mobile-open-claw-types/ # 公共类型 & 异常 │ └── docs/ # 部署脚本 & 开发文档 │ └── mobileopenclawgateway/ # 📱 Android 前端 (Jetpack Compose) └── app/ └── src/main/java/cn/bugstack/ai/mobileopenclawgateway/
xfg-frame-archetype v2.2本文发布于 2026 年 5 月,项目持续迭代中。


本文作者:williams
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!