Skip to content

feat(dec-001): C7 — kit install package + toreva CLI + examples#7

Merged
gapview01 merged 2 commits into
mainfrom
feat/dec-001-c7-kit-install
Apr 26, 2026
Merged

feat(dec-001): C7 — kit install package + toreva CLI + examples#7
gapview01 merged 2 commits into
mainfrom
feat/dec-001-c7-kit-install

Conversation

@gapview01
Copy link
Copy Markdown
Member

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.

  • New toreva CLI (npx-installable): init --client=<claude-desktop|openclaw|cursor>, login (gateway device-code flow), doctor (config + token + first MCP call).
  • README rewritten with install + first-run UX as the headline path.
  • examples/<client>/ for each supported MCP client — JSON snippet + per-client README.
  • 18 new unit tests (init / login / doctor) — full suite is 68 passing.

How it works

toreva init reads TOREVA_MCP_URL (default https://mcp.toreva.com), resolves the client's config path (with overrides for tests), and writes a stdio stanza:

"toreva": {
  "command": "npx",
  "args": ["-y", "@toreva/mcp"],
  "env": { "TOREVA_MCP_URL": "https://mcp.toreva.com" }
}

It preserves any existing mcpServers entries and refuses to clobber invalid JSON.

toreva login runs the gateway device-code flow (POST /auth/device → poll /auth/token) and persists the resulting token to ~/.config/toreva/config.json with mode 0600. TOREVA_AUTH_TOKEN short-circuits for CI.

toreva doctor reports config_present + auth_token + mcp_call (hits ${TOREVA_MCP_URL}/healthz with the bearer token); non-zero exit on failure.

Stub-until-gateway-ships flags

  • TOREVA_MCP_URL — default https://mcp.toreva.com (per dispatch instruction).
  • Token-shape and /auth/device, /auth/token, /healthz endpoint contracts are provisional. Gateway team owns the canonical shapes; tests use a mocked fetch so swapping is one-file change in packages/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 clean
  • pnpm test — 68/68 passing (11 files; 18 new in packages/cli/src/__tests__/)
  • Smoke: node bin/toreva --help prints usage
  • Smoke: node bin/toreva init --client=cursor (with overrides) writes a valid stanza
  • Live: post-gateway-merge, run npx toreva login against the real gateway
  • Live: post-gateway-merge, run npx toreva doctor and confirm [ OK ] × 3
  • Manual: install into a real Claude Desktop / OpenClaw / Cursor client and confirm tools appear

🤖 Generated with Claude Code

gapview01 and others added 2 commits April 26, 2026 15:16
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>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +29 to +31
env: {
TOREVA_MCP_URL: mcpUrl,
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@gapview01 gapview01 merged commit 1a720ef into main Apr 26, 2026
3 checks passed
@gapview01 gapview01 deleted the feat/dec-001-c7-kit-install branch April 26, 2026 23:04
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