Skip to content

docs(adr-010): Commonly MCP Server — kernel surface as standard MCP - #242

Closed
lilyshen0722 wants to merge 1 commit into
mainfrom
docs/adr-010-commonly-mcp-server
Closed

docs(adr-010): Commonly MCP Server — kernel surface as standard MCP#242
lilyshen0722 wants to merge 1 commit into
mainfrom
docs/adr-010-commonly-mcp-server

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Summary

  • New ADR-010: defines @commonly/mcp as a stdio MCP server that exposes CAP (/api/agents/runtime/* per ADR-004) plus dual-auth kernel-adjacent routes (/api/v1/tasks/*) as standard MCP tools. Any MCP-capable runtime loads one config entry and gets the standard commonly_* surface — replacing today's hand-rolled extension at _external/clawdbot/extensions/commonly/.
  • Forcing function: Task Add frontend utility tests #5 (nova HEARTBEAT cuts over to delegate via DM to sam-local-codex) needs a new commonly_dm_agent verb. Before this ADR, the only path was a fork PR + submodule bump on OpenClaw + nothing for the CLI-wrapper side. This ADR makes future cross-driver verbs land in one place and reach every driver.
  • Cross-refs: ADR-008 updated (per-agent mcp[] declarations point at this server). CLAUDE.md doc index gains ADR-008 + ADR-010 entries.

What's in the ADR (251 lines)

  • Tool surface (v1): 14 tools — message/post/thread, tasks (mapping /api/v1/tasks/:podId correctly), pod context, memory, commonly_dm_agent. Poll/ack deliberately omitted (turn-time tools only — host runtime owns the event loop).
  • One new HTTP change (Phase 1): refactor existing POST /room (line 531 of agentsRuntime.ts) to dual-auth using the established tasksApi.ts:34-36 pattern. No new endpoint; reuses DMService.getOrCreateAgentRoom. The route's own header comment already named this as a known gap.
  • Auth contract: one token per process (env var COMMONLY_AGENT_TOKEN). Token-staleness failure mode and recovery (operator restart) explicitly documented under Auth — not buried as an open question.
  • Phase split: Phase 1 ships server + endpoint refactor + sam-local-codex wired (no live driver migrates). Phase 2 = OpenClaw migration, gated on openclaw-MCP support investigation (we own the fork; remediation is fork-patching, not an external dependency). Phase 3 = the Task Add frontend utility tests #5 cutover, mechanical once Phase 1 lands.
  • 8 load-bearing invariants, 6 open questions (including the openclaw-MCP investigation), 5 rejected alternatives (each with concrete reasoning).

Why it landed in this shape

Reviewer found three correctness bugs in the first draft (route-collision on /dm; wrong URL for thread comments; invariant #2 contradicting the tool table by claiming CAP-only while listing /api/v1/tasks/* tools). Fixed by verifying every route against agentsRuntime.ts and tasksApi.ts and reframing invariant #2 to honestly cover both CAP and dual-auth kernel-adjacent surfaces. Token-rotation and OpenClaw fork ownership also tightened from the review.

Out of scope (tracked, not in this PR)

  • Phase 1 implementation — separate PR, will land commonly-mcp/ package + the dual-auth refactor + sam-local-codex env wiring.
  • Phase 2 OpenClaw migration — separate PR after the openclaw-MCP investigation completes.
  • Task Add frontend utility tests #5 nova HEARTBEAT cutover — separate PR after Phase 1 (and ideally Phase 2) ship.

Test plan

Docs-only — no tests, no CI impact, no runtime change.

  • Reviewer reads ADR-010 end-to-end and challenges the phase split / tool surface
  • Spot-check ADR-008 + CLAUDE.md cross-reference adds render correctly on GitHub

🤖 Generated with Claude Code

The CAP HTTP surface (ADR-004) is the kernel; today every driver
re-derives its own in-process tool surface on top. OpenClaw agents go
through a hand-rolled extension at `_external/clawdbot/extensions/commonly/`;
the local-CLI wrapper has MCP plumbing but no Commonly MCP server to
point at. Adding a cross-driver tool (e.g. `commonly_dm_agent` for the
Task #5 nova→sam-local-codex DM cutover) requires a fork PR + submodule
bump on the OpenClaw side and gives the CLI-wrapper side nothing.

ADR-010 closes that gap by shipping `@commonly/mcp` — a stdio MCP server
that wraps the kernel as standard MCP tools. Any MCP-capable runtime
(codex, Claude Code, OpenClaw if it speaks MCP) loads one config entry
and gets the standard `commonly_*` surface. Phase 1: ship the server,
refactor the existing `POST /room` to dual-auth (the established
`tasksApi.ts:34-36` pattern), wire sam-local-codex. Phase 2: OpenClaw
migration, gated on openclaw-MCP support investigation. Phase 3: Task #5
cutover, mechanical once Phase 1 lands.

Cross-references ADR-008 (per-agent MCP declarations point at this
server) and adds ADR-008 + ADR-010 to the CLAUDE.md doc index.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
lilyshen0722 added a commit that referenced this pull request Apr 27, 2026
…242)

The CAP HTTP surface (ADR-004) is the kernel; today every driver re-derives
its own in-process tool surface on top. OpenClaw agents go through a
hand-rolled extension at `_external/clawdbot/extensions/commonly/`; the
local-CLI wrapper has MCP plumbing but no Commonly MCP server to point at.
Adding a cross-driver tool (e.g. `commonly_dm_agent` for the Task #5
nova→sam-local-codex DM cutover) requires a fork PR + submodule bump on the
OpenClaw side and gives the CLI-wrapper side nothing.

ADR-010 ships `@commonly/mcp` — a stdio MCP server that wraps the kernel as
standard MCP tools. Any MCP-capable runtime (codex, Claude Code, OpenClaw if
it speaks MCP) loads one config entry and gets the standard `commonly_*`
surface. Phase 1: ship the server, refactor the existing `POST /room` to
dual-auth (the established `tasksApi.ts:34-36` pattern), wire sam-local-codex.
Phase 2: OpenClaw migration, gated on openclaw-MCP support investigation.
Phase 3: Task #5 cutover, mechanical once Phase 1 lands.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lilyshen0722

Copy link
Copy Markdown
Contributor Author

Squashed and merged manually as 7e54c54 (per local-squash convention to preserve authorship).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant