feat(dec-001): C7 — kit install package + toreva CLI + examples#7
Conversation
Adds three GitHub issue forms (bug, feature, integration-help) plus a config.yml that disables blank issues and points devs at Discussions (general Q&A), dev@toreva.io (compliance-sensitive), and the cdx triage protocol (SLAs). Each form includes a regulated-claim check (Earn/Stake/Balance/yield/ custody) so cdx-agent can route to compliance-agent before substantive reply, per dev-advocacy posture in cdx/docs/dev-advocacy-day1.md. Doctrine: po/docs/decisions/DEC-001-wallet-mode-architecture.md §"Connect integration mechanic — MCP" + 5-word ATTEST bar. Spawned-By: day1-launch-po-001 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Ship the kit half of DEC-001 v1.0 gate C7 (MCP server quartet — kit slice). Adds a self-serve install path so a Connect-mode user can wire Toreva into Claude Desktop, OpenClaw, or Cursor in two commands and verify the result with a third. CLI surface (packages/cli): - toreva init --client=<claude-desktop|openclaw|cursor> writes the Toreva MCP server stanza into the client's config file, preserving any existing mcpServers entries and refusing to clobber invalid JSON. - toreva login runs the gateway's OAuth-equivalent device-code flow (POST /auth/device → poll /auth/token) and persists the token to ~/.config/toreva/config.json (chmod 600). TOREVA_AUTH_TOKEN env var short-circuits for CI / power users. - toreva doctor reports config_present + auth_token + mcp_call as a three-line OK/WARN/FAIL diagnostic; non-zero exit on failure. Stub flags until gateway ships canonical endpoint shapes — TOREVA_MCP_URL defaults to https://mcp.toreva.com and is pinned in the stanza env. Examples (examples/<client>/): - One folder per supported client with the JSON snippet + a README that shows the npx flow and the manual-edit fallback. Tests (packages/cli/src/__tests__/, 18 new cases): - init: parses --client, builds the stdio stanza, writes fresh configs, preserves existing entries, refuses invalid JSON, rejects unsupported clients. - login: completes the device-code flow with a mocked fetch, skips the flow when TOREVA_AUTH_TOKEN is set, throws on malformed responses and 5xx during polling, asserts chmod 600 on the written config. - doctor: covers all-OK, missing config, missing token, 401 from gateway, and network unreachable; plus formatReport rendering. Repo plumbing: - bin/toreva monorepo shim so `npx toreva` works from this checkout before publishing; resolves to packages/cli/dist/index.js. - Root package.json exposes the bin. - README rewritten with the install + first-run UX as the headline path. Doctrine: po/docs/decisions/DEC-001-wallet-mode-architecture.md §"Connect integration mechanic — MCP". Spawned-By: day1-launch-po-001 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 473583d767
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| env: { | ||
| TOREVA_MCP_URL: mcpUrl, | ||
| }, |
There was a problem hiding this comment.
Pass relay auth token into MCP server stanza
buildServerStanza only injects TOREVA_MCP_URL, but the MCP server currently boots from RELAY_URL/RELAY_AUTH_TOKEN and hard-fails when RELAY_AUTH_TOKEN is missing (packages/mcp/src/server.ts). With the new documented flow (toreva init + toreva login), login writes a token to disk but nothing in the generated client stanza exposes that token to @toreva/mcp, so the first MCP launch still exits immediately with an auth-token error for users who don’t also set legacy env vars manually.
Useful? React with 👍 / 👎.
Summary
Ships the kit half of DEC-001 v1.0 gate C7 (MCP server quartet — kit slice). Lets a Connect-mode user wire Toreva into Claude Desktop, OpenClaw, or Cursor in two commands and verify the result with a third.
torevaCLI (npx-installable):init --client=<claude-desktop|openclaw|cursor>,login(gateway device-code flow),doctor(config + token + first MCP call).examples/<client>/for each supported MCP client — JSON snippet + per-client README.How it works
toreva initreadsTOREVA_MCP_URL(defaulthttps://mcp.toreva.com), resolves the client's config path (with overrides for tests), and writes a stdio stanza:It preserves any existing
mcpServersentries and refuses to clobber invalid JSON.toreva loginruns the gateway device-code flow (POST /auth/device→ poll/auth/token) and persists the resulting token to~/.config/toreva/config.jsonwith mode0600.TOREVA_AUTH_TOKENshort-circuits for CI.toreva doctorreportsconfig_present+auth_token+mcp_call(hits${TOREVA_MCP_URL}/healthzwith the bearer token); non-zero exit on failure.Stub-until-gateway-ships flags
TOREVA_MCP_URL— defaulthttps://mcp.toreva.com(per dispatch instruction)./auth/device,/auth/token,/healthzendpoint contracts are provisional. Gateway team owns the canonical shapes; tests use a mocked fetch so swapping is one-file change inpackages/cli/src/commands/login.ts.Coordination
Do not merge — coordinated launch with the gateway half of C7. Gateway must finalize MCP server URL + auth-token shape before merge so we can pin instead of stub.
Doctrine
po/docs/decisions/DEC-001-wallet-mode-architecture.md§"Connect integration mechanic — MCP".Test plan
pnpm build— all 4 workspace packages compile cleanpnpm test— 68/68 passing (11 files; 18 new inpackages/cli/src/__tests__/)node bin/toreva --helpprints usagenode bin/toreva init --client=cursor(with overrides) writes a valid stanzanpx toreva loginagainst the real gatewaynpx toreva doctorand confirm[ OK ]× 3🤖 Generated with Claude Code