Skip to content

Commit fb32d83

Browse files
committed
docs: update README for HTTP REST API and 43 MCP tools
- Add HTTP REST API Server section with full endpoint table - Update MCP tools count 39/40 → 43 (Config:10 Agent:25 Stats:4 Workflow:4) - Add codes serve command to commands reference - Add chatsession/ and httpserver/ to dev structure - Document httpTokens and httpBind config fields - Update both English and Chinese READMEs
1 parent 441334f commit fb32d83

2 files changed

Lines changed: 118 additions & 8 deletions

File tree

README.md

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ Environment configuration management, project management, and multi-agent collab
1111
- **Agent Teams** — Autonomous Claude agents collaborating with task dependencies, messaging, and auto-reporting
1212
- **Workflow Templates** — YAML-based agent team templates for repeatable multi-agent pipelines
1313
- **Cost Tracking** — Session-level API usage statistics by project and model
14-
- **MCP Server** — 40 tools integrated into Claude Code for managing everything from conversations
14+
- **HTTP REST API** — Full REST API server (`codes serve`) for remote access, mobile clients, and WebSocket-based chat sessions
15+
- **MCP Server** — 43 tools integrated into Claude Code for managing everything from conversations
1516
- **Cross-Platform** — Linux, macOS, Windows (amd64 & arm64)
1617

1718
## Install
@@ -59,12 +60,12 @@ Add `codes` as an MCP server to let Claude Code manage agent teams, projects, an
5960
}
6061
```
6162

62-
Once configured, Claude Code gains access to 39 MCP tools:
63+
Once configured, Claude Code gains access to 43 MCP tools:
6364

6465
| Category | Tools | Examples |
6566
|----------|-------|---------|
6667
| **Config** (10) | Projects, profiles, remotes | `list_projects`, `switch_profile`, `sync_remote` |
67-
| **Agent** (21) | Teams, tasks, messages | `team_create`, `task_create`, `message_send` |
68+
| **Agent** (25) | Teams, tasks, messages | `team_create`, `task_create`, `message_send` |
6869
| **Stats** (4) | Usage tracking | `stats_summary`, `stats_by_project`, `stats_by_model` |
6970
| **Workflow** (4) | Templates | `workflow_list`, `workflow_run`, `workflow_create` |
7071

@@ -149,6 +150,56 @@ tasks:
149150
150151
Workflows can also be created programmatically via the `workflow_create` MCP tool.
151152

153+
## HTTP REST API Server
154+
155+
`codes serve` starts a REST API server (default `:3456`) that exposes all `codes` functionality over HTTP — designed for iOS/mobile apps and remote automation.
156+
157+
**First run** auto-generates and saves an auth token to `~/.codes/config.json`. All endpoints (except `/health`) require:
158+
159+
```
160+
Authorization: Bearer <token>
161+
```
162+
163+
### Endpoints
164+
165+
| Method | Path | Description |
166+
|--------|------|-------------|
167+
| `GET` | `/health` | Health check (no auth) |
168+
| `POST` | `/dispatch` | Dispatch task to agent team |
169+
| `POST` | `/dispatch/simple` | Simplified single-task dispatch |
170+
| `GET/POST` | `/sessions` | List / create chat sessions |
171+
| `GET/DELETE` | `/sessions/{id}` | Get / delete session |
172+
| `GET` | `/sessions/{id}/ws` | WebSocket stream (real-time I/O) |
173+
| `POST` | `/sessions/{id}/message` | Send message to session |
174+
| `POST` | `/sessions/{id}/interrupt` | Interrupt running session |
175+
| `POST` | `/sessions/{id}/resume` | Resume paused session |
176+
| `GET` | `/projects` | List projects |
177+
| `GET` | `/projects/{name}` | Get project details |
178+
| `GET` | `/profiles` | List profiles |
179+
| `POST` | `/profiles/switch` | Switch active profile |
180+
| `GET` | `/stats/summary` | Cost summary |
181+
| `GET` | `/stats/projects` | Cost by project |
182+
| `GET` | `/stats/models` | Cost by model |
183+
| `POST` | `/stats/refresh` | Rebuild stats cache |
184+
| `GET` | `/workflows` | List workflows |
185+
| `GET/POST` | `/workflows/{name}` | Get / run workflow |
186+
| `GET/POST` | `/teams` | List / create teams |
187+
| `GET/DELETE` | `/teams/{name}` | Get / delete team |
188+
| `GET` | `/teams/{name}/status` | Team dashboard |
189+
| `GET/POST` | `/teams/{name}/tasks` | List / create tasks |
190+
| `GET` | `/tasks/{id}` | Get task by ID |
191+
192+
### Configuration
193+
194+
Add to `~/.codes/config.json` to pin the bind address or pre-set tokens:
195+
196+
```json
197+
{
198+
"httpBind": ":3456",
199+
"httpTokens": ["your-secret-token"]
200+
}
201+
```
202+
152203
## Commands
153204

154205
```
@@ -157,6 +208,7 @@ codes init [--yes] # Install binary + shell completion
157208
codes start <path|alias> # Launch Claude in directory (alias: s)
158209
codes version / update # Version info / update Claude CLI
159210
codes doctor # System diagnostics
211+
codes serve [--addr :3456] # Start HTTP REST API server
160212
```
161213

162214
### Profile Management (`codes profile`, alias: `pf`)
@@ -287,9 +339,12 @@ codes/
287339
├── cmd/codes/ # Entry point
288340
├── internal/
289341
│ ├── agent/ # Agent teams: daemon, runner, storage
342+
│ ├── chatsession/ # Claude chat session lifecycle + WebSocket streaming
290343
│ ├── commands/ # Cobra CLI commands
291344
│ ├── config/ # Configuration management
292-
│ ├── mcp/ # MCP server (40 tools, stdio transport)
345+
│ ├── dispatch/ # Intent-based task dispatch to agent teams
346+
│ ├── httpserver/ # HTTP REST API server (sessions, projects, stats, workflows)
347+
│ ├── mcp/ # MCP server (43 tools, stdio transport)
293348
│ ├── session/ # Terminal session manager
294349
│ ├── stats/ # Cost tracking and aggregation
295350
│ ├── remote/ # SSH remote management

README.zh-CN.md

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ Claude Code 的环境配置管理、项目管理与多 Agent 协作工具。一
1111
- **Agent 团队** — 多个 Claude Agent 自治协作,任务依赖、消息传递、自动汇报
1212
- **Workflow 模板** — YAML 定义的 Agent 团队模板,一键启动可复用的多 Agent 流水线
1313
- **成本追踪** — 按项目、模型维度的 API 用量统计
14-
- **MCP Server** — 39 个工具集成到 Claude Code,直接在对话中管理一切
14+
- **HTTP REST API** — 内置 REST API Server(`codes serve`),支持远程访问、移动客户端和 WebSocket 实时对话
15+
- **MCP Server** — 43 个工具集成到 Claude Code,直接在对话中管理一切
1516
- **跨平台** — Linux, macOS, Windows (amd64 & arm64)
1617

1718
## 安装
@@ -59,12 +60,12 @@ git clone https://github.com/ourines/codes.git && cd codes && make build
5960
}
6061
```
6162

62-
配置完成后,Claude Code 即可使用 39 个 MCP 工具:
63+
配置完成后,Claude Code 即可使用 43 个 MCP 工具:
6364

6465
| 分类 | 工具 | 示例 |
6566
|------|------|------|
6667
| **配置管理** (10) | 项目、Profile、远程主机 | `list_projects``switch_profile``sync_remote` |
67-
| **Agent** (21) | 团队、任务、消息 | `team_create``task_create``message_send` |
68+
| **Agent** (25) | 团队、任务、消息 | `team_create``task_create``message_send` |
6869
| **统计** (4) | 用量追踪 | `stats_summary``stats_by_project``stats_by_model` |
6970
| **Workflow** (4) | 模板 | `workflow_list``workflow_run``workflow_create` |
7071

@@ -149,6 +150,56 @@ tasks:
149150
150151
也可通过 `workflow_create` MCP 工具在对话中创建 workflow。
151152

153+
## HTTP REST API Server
154+
155+
`codes serve` 启动 REST API Server(默认 `:3456`),通过 HTTP 暴露所有 `codes` 功能,适用于 iOS/移动端 App 和远程自动化。
156+
157+
**首次运行**会自动生成 Auth Token 并保存到 `~/.codes/config.json`。所有端点(`/health` 除外)需携带:
158+
159+
```
160+
Authorization: Bearer <token>
161+
```
162+
163+
### 端点列表
164+
165+
| 方法 | 路径 | 说明 |
166+
|------|------|------|
167+
| `GET` | `/health` | 健康检查(无需认证) |
168+
| `POST` | `/dispatch` | 分发任务到 Agent 团队 |
169+
| `POST` | `/dispatch/simple` | 简化版单任务分发 |
170+
| `GET/POST` | `/sessions` | 列出 / 创建对话 Session |
171+
| `GET/DELETE` | `/sessions/{id}` | 获取 / 删除 Session |
172+
| `GET` | `/sessions/{id}/ws` | WebSocket 流(实时 I/O) |
173+
| `POST` | `/sessions/{id}/message` | 向 Session 发送消息 |
174+
| `POST` | `/sessions/{id}/interrupt` | 中断正在运行的 Session |
175+
| `POST` | `/sessions/{id}/resume` | 恢复暂停的 Session |
176+
| `GET` | `/projects` | 列出项目 |
177+
| `GET` | `/projects/{name}` | 获取项目详情 |
178+
| `GET` | `/profiles` | 列出 Profile |
179+
| `POST` | `/profiles/switch` | 切换活跃 Profile |
180+
| `GET` | `/stats/summary` | 费用概要 |
181+
| `GET` | `/stats/projects` | 按项目统计费用 |
182+
| `GET` | `/stats/models` | 按模型统计费用 |
183+
| `POST` | `/stats/refresh` | 重建统计缓存 |
184+
| `GET` | `/workflows` | 列出 Workflow |
185+
| `GET/POST` | `/workflows/{name}` | 获取 / 运行 Workflow |
186+
| `GET/POST` | `/teams` | 列出 / 创建团队 |
187+
| `GET/DELETE` | `/teams/{name}` | 获取 / 删除团队 |
188+
| `GET` | `/teams/{name}/status` | 团队仪表盘 |
189+
| `GET/POST` | `/teams/{name}/tasks` | 列出 / 创建任务 |
190+
| `GET` | `/tasks/{id}` | 按 ID 获取任务 |
191+
192+
### 配置
193+
194+
在 `~/.codes/config.json` 中可预设监听地址和 Token:
195+
196+
```json
197+
{
198+
"httpBind": ":3456",
199+
"httpTokens": ["your-secret-token"]
200+
}
201+
```
202+
152203
## 命令参考
153204

154205
```
@@ -157,6 +208,7 @@ codes init [--yes] # 安装二进制文件 + shell 补全
157208
codes start <路径|别名> # 在指定目录启动 Claude(别名: s)
158209
codes version / update # 版本信息 / 更新 Claude CLI
159210
codes doctor # 系统诊断
211+
codes serve [--addr :3456] # 启动 HTTP REST API Server
160212
```
161213

162214
### Profile 管理 (`codes profile`,别名: `pf`)
@@ -287,9 +339,12 @@ codes/
287339
├── cmd/codes/ # 入口
288340
├── internal/
289341
│ ├── agent/ # Agent 团队:守护进程、任务执行、存储
342+
│ ├── chatsession/ # Claude 对话 Session 生命周期 + WebSocket 流
290343
│ ├── commands/ # Cobra CLI 命令
291344
│ ├── config/ # 配置管理
292-
│ ├── mcp/ # MCP Server(39 工具,stdio 传输)
345+
│ ├── dispatch/ # 意图驱动的任务分发到 Agent 团队
346+
│ ├── httpserver/ # HTTP REST API Server(Session、项目、统计、Workflow)
347+
│ ├── mcp/ # MCP Server(43 工具,stdio 传输)
293348
│ ├── session/ # 终端会话管理
294349
│ ├── stats/ # 成本追踪与聚合
295350
│ ├── remote/ # SSH 远程管理

0 commit comments

Comments
 (0)