feat: add oneclaw module for 1Claw MCP integration by kmjones1979 · Pull Request #857 · coder/registry · GitHub
Skip to content

feat: add oneclaw module for 1Claw MCP integration#857

Open
kmjones1979 wants to merge 3 commits intocoder:mainfrom
kmjones1979:add-kmjones1979-oneclaw-module
Open

feat: add oneclaw module for 1Claw MCP integration#857
kmjones1979 wants to merge 3 commits intocoder:mainfrom
kmjones1979:add-kmjones1979-oneclaw-module

Conversation

@kmjones1979
Copy link
Copy Markdown

Summary

Resubmission of #845 (closed for structural reasons) with the reviewer feedback addressed and additional security hardening of the bootstrap flow.

Adds the kmjones1979 namespace and the oneclaw module, which provides vault-backed secrets and MCP server wiring for AI coding agents (Cursor, Claude Code) in Coder workspaces.

Changes since #845

Structural (addresses @DevelopmentCats review)

The reviewer asked that the module follow the standard schema used in the coder/ namespace:

Generally in almost all cases you would just have: main.tf, README.md, main.test.ts, main.tftest.hcl and script files which amount to maybe one or two scripts.

Done:

  • variables.tf and outputs.tf are consolidated into main.tf.
  • scripts/bootstrap.sh and scripts/setup.sh are merged into a single scripts/run.sh executed by one coder_script.
  • The Terraform-native provisioning mode (scripts/provision.sh, null_resource.provision, master_api_key) is removed. That mode relied on a local-exec provisioner writing a state file to the provisioner's cwd, which is ephemeral inside Coder template provisioners and cannot round-trip credentials into coder_env. Two modes remain: bootstrap (recommended) and manual.

Final tree:

registry/kmjones1979/
├── README.md
├── .images/avatar.png
└── modules/oneclaw/
    ├── README.md
    ├── main.tf
    ├── main.test.ts
    ├── main.tftest.hcl
    └── scripts/run.sh

Security hardening for the 1ck_ human bootstrap key

The 1ck_ human API key is privileged (can create and destroy vaults in the caller's 1Claw account), so the module goes out of its way to make sure it cannot be recovered from the workspace after bootstrap:

  1. The key is delivered to the script as a sensitive coder_env variable (_ONECLAW_HUMAN_API_KEY) rather than via templatefile() substitution. As a result, the literal key never appears in the rendered script body that lives in Terraform state or in the Coder agent's /tmp/coder-agent.log. The rendered script only shows HUMAN_KEY="\${_ONECLAW_HUMAN_API_KEY:-}".
  2. The key is sent to the 1Claw auth endpoint via curl --data-binary @- from stdin, so it never appears in ps aux / /proc/<pid>/cmdline.
  3. HUMAN_KEY and _ONECLAW_HUMAN_API_KEY are unset immediately after authentication, so downstream subprocesses spawned by the script do not inherit the key.
  4. Only the scoped ocv_ agent key and the vault id are persisted to ~/.1claw/bootstrap.json and the MCP config files.
  5. README.md documents a post-bootstrap cleanup flow: once the state file exists, the user is instructed to set human_api_key = "" in their Terraform so subsequent restarts do not reference the human key at all.

Test plan

Verified against a local Coder server (v2.31.9) running the module with real 1Claw credentials.

  • terraform test passes (4 runs, Terraform 1.14 via Docker)
  • bun test main.test.ts passes (5 tests, including an explicit assertion that the human key value is not embedded in the rendered script)
  • shellcheck is clean on scripts/run.sh
  • bun run fmt leaves the tree unchanged
  • Live workspace on local Coder: first boot creates vault + agent + policy and writes bootstrap.json + Cursor/Claude MCP configs
  • Live workspace restart is idempotent — the script detects the state file and skips provisioning
  • Post-bootstrap cleanup flow (human_api_key = "", coder update, restart) continues to work using cached credentials
  • Filesystem audit after each scenario confirms the 1ck_ key value does not appear in any file on the workspace (state file, MCP configs, agent log, script log, shell init files, /proc/<pid>/environ of any Coder process)

Made with Cursor

Add kmjones1979 namespace and oneclaw module, ported from
1clawAI/1claw-coder-workspace-module. Provides vault-backed secrets
and MCP server config for AI coding agents in Coder workspaces.

- Namespace: kmjones1979 (avatar from GitHub)
- Module: oneclaw with three provisioning modes (terraform-native,
  shell bootstrap, manual)
- Tests: main.tftest.hcl (5 runs) and main.test.ts (5 tests)
- Scripts: provision.sh, bootstrap.sh, setup.sh

Made-with: Cursor
…dling

Addresses reviewer feedback on closed PR coder#845 that the module was "split up
way more than usual" and did not follow the registry module schema.

Structure (matches the coder/ namespace conventions):
- Collapse variables.tf + outputs.tf into main.tf
- Merge scripts/bootstrap.sh + scripts/setup.sh into a single scripts/run.sh
  executed by a single coder_script
- Remove Terraform-native provisioning mode (scripts/provision.sh,
  null_resource.provision, master_api_key): it relied on local-exec writing a
  state file to the provisioner's cwd, which is ephemeral inside Coder template
  provisioners and therefore cannot round-trip credentials into coder_env
- Keep two supported modes: bootstrap (human 1ck_ key, recommended) and
  manual (pre-provisioned scoped ocv_ key)

Security hardening for the 1ck_ human bootstrap key:
- Deliver the key via a sensitive coder_env (_ONECLAW_HUMAN_API_KEY) instead
  of templatefile() substitution, so the literal key never appears in the
  rendered script body stored in Terraform state or logged to the workspace's
  /tmp/coder-agent.log
- Send the key to the 1Claw auth endpoint via curl --data-binary @- from stdin
  so it does not appear in process argv (ps/proc/cmdline)
- Unset HUMAN_KEY and _ONECLAW_HUMAN_API_KEY as soon as auth completes so
  downstream processes do not inherit the key
- Only the scoped ocv_ agent key and vault id are persisted to
  ~/.1claw/bootstrap.json and the MCP config files
- README documents post-bootstrap cleanup (set human_api_key = "" once the
  state file exists) and the full security guarantees

Tested end-to-end against a local Coder server with real 1Claw credentials:
first boot, idempotent restart, and post-bootstrap cleanup all succeed and
leave no copy of the 1ck_ value anywhere on the workspace filesystem or in
its process environments.

Made-with: Cursor
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