Skip to content

Commit efd35ed

Browse files
committed
docs(plans): add MCP upstream CRUD commands plan
1 parent 1d495cd commit efd35ed

1 file changed

Lines changed: 117 additions & 0 deletions

File tree

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# MCP Upstream CRUD Commands
2+
3+
## Overview
4+
5+
Add MCP upstream management to the Telegram bot and verify full CRUD coverage across all interfaces (CLI, HTTP API, Telegram). Currently:
6+
7+
| Operation | CLI | HTTP API | Telegram |
8+
|-----------|-----|----------|----------|
9+
| List | `sluice mcp list` | `GET /api/mcp/upstreams` | missing |
10+
| Add | `sluice mcp add` | `POST /api/mcp/upstreams` | missing |
11+
| Remove | `sluice mcp remove` | `DELETE /api/mcp/upstreams/{name}` | missing |
12+
| Update | missing | missing | missing |
13+
14+
After this plan, Telegram will have `/mcp list`, `/mcp add`, `/mcp remove`, and an update command will be available across all interfaces.
15+
16+
## Context
17+
18+
- Telegram commands: `internal/telegram/commands.go` (CommandHandler, Handle dispatch)
19+
- HTTP API: `internal/api/server.go` (MCP upstream handlers)
20+
- API spec: `internal/api/api.gen.go` (generated from OpenAPI)
21+
- CLI: `cmd/sluice/mcp.go` (mcp subcommand)
22+
- MCP store: `internal/store/store.go` (AddMCPUpstream, ListMCPUpstreams, RemoveMCPUpstream)
23+
- MCP gateway: `internal/mcp/gateway.go` (upstream lifecycle)
24+
- Auto-injection: `cmd/sluice/main.go` (MCP config write to shared volume)
25+
26+
## Development Approach
27+
28+
- **Testing approach**: Regular (code first, then tests)
29+
- Complete each task fully before moving to the next
30+
- CRITICAL: every task MUST include new/updated tests
31+
- CRITICAL: all tests must pass before starting next task
32+
33+
## Testing Strategy
34+
35+
- Unit tests for new Telegram command handlers
36+
- Existing store and API tests cover persistence layer
37+
38+
## Progress Tracking
39+
40+
- Mark completed items with `[x]` immediately when done
41+
- Add newly discovered tasks with + prefix
42+
43+
## Implementation Steps
44+
45+
### Task 1: Add /mcp commands to Telegram bot
46+
47+
**Files:**
48+
- Modify: `internal/telegram/commands.go`
49+
50+
- [ ] Add `case "mcp"` to Handle() dispatch
51+
- [ ] Implement `handleMCP(args)` with subcommands: list, add, remove
52+
- [ ] `/mcp list` - list registered upstreams with name, transport, command/URL
53+
- [ ] `/mcp add <name> --command <cmd>` - add stdio upstream (parse flags from args)
54+
- [ ] `/mcp add <name> --url <url>` - add HTTP/WebSocket upstream
55+
- [ ] `/mcp remove <name>` - remove upstream by name
56+
- [ ] After add/remove: trigger MCP config re-injection into agent container
57+
- [ ] Format list output for Telegram readability (not JSON)
58+
- [ ] Write tests for each subcommand
59+
- [ ] Run tests
60+
61+
### Task 2: Add /mcp to Telegram command menu
62+
63+
**Files:**
64+
- Modify: `internal/telegram/approval.go`
65+
66+
- [ ] Add `{Command: "mcp", Description: "Manage MCP upstreams"}` to registerCommands
67+
- [ ] Update help output to include MCP section
68+
- [ ] Write tests for updated help
69+
- [ ] Run tests
70+
71+
### Task 3: Add update/edit support to CLI and store
72+
73+
**Files:**
74+
- Modify: `internal/store/store.go`
75+
- Modify: `cmd/sluice/mcp.go`
76+
77+
- [ ] Add `UpdateMCPUpstream(name, opts)` to store (update command, transport, args, env, timeout)
78+
- [ ] Add `sluice mcp update <name> [--command <cmd>] [--timeout N]` CLI subcommand
79+
- [ ] Write tests for store update
80+
- [ ] Write tests for CLI update
81+
- [ ] Run tests
82+
83+
### Task 4: Add update endpoint to HTTP API
84+
85+
**Files:**
86+
- Modify: `internal/api/server.go`
87+
- Modify: `api/openapi.yaml` (if exists)
88+
89+
- [ ] Add `PATCH /api/mcp/upstreams/{name}` handler
90+
- [ ] Accept partial update (only fields provided are changed)
91+
- [ ] Write tests for PATCH endpoint
92+
- [ ] Run tests
93+
94+
### Task 5: Verify acceptance criteria
95+
96+
- [ ] Verify `/mcp list` in Telegram shows upstreams
97+
- [ ] Verify `/mcp add` creates upstream and triggers auto-injection
98+
- [ ] Verify `/mcp remove` removes upstream
99+
- [ ] Verify CLI `sluice mcp update` works
100+
- [ ] Verify API `PATCH /api/mcp/upstreams/{name}` works
101+
- [ ] Run full test suite: `go test ./... -v -timeout 30s`
102+
103+
### Task 6: [Final] Update documentation
104+
105+
- [ ] Update CLAUDE.md CLI subcommands section with mcp update
106+
- [ ] Update help command output
107+
- [ ] Move this plan to `docs/plans/completed/`
108+
109+
## Post-Completion
110+
111+
**Manual verification:**
112+
- Deploy to knuth
113+
- Add an MCP upstream via Telegram: `/mcp add test-server --command "echo hello"`
114+
- Verify it appears in `/mcp list`
115+
- Verify `mcp-servers.json` is written to shared volume
116+
- Verify OpenClaw discovers the new MCP server
117+
- Remove it: `/mcp remove test-server`

0 commit comments

Comments
 (0)