mystack-rig 1.2.1__tar.gz → 1.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/GLOSSARY.md +16 -0
  2. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/PKG-INFO +80 -5
  3. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/README.md +79 -4
  4. mystack_rig-1.3.1/docs/adr/0003-mcp-servers-declared-once-rendered-at-authorize.md +18 -0
  5. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/agents.py +12 -51
  6. mystack_rig-1.3.1/src/cli/ansible_filters/__init__.py +0 -0
  7. mystack_rig-1.3.1/src/cli/ansible_filters/rig_mcp.py +318 -0
  8. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/encrypt.py +51 -10
  9. mystack_rig-1.3.1/src/cli/git_author.py +65 -0
  10. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/main.py +78 -1
  11. mystack_rig-1.3.1/src/cli/mcp.py +267 -0
  12. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/remote_dev.py +361 -122
  13. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/snapshots.py +10 -28
  14. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/vault_keys.py +9 -1
  15. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/mystack_rig.egg-info/PKG-INFO +80 -5
  16. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/mystack_rig.egg-info/SOURCES.txt +9 -0
  17. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/mystack_rig.egg-info/scm_file_list.json +9 -0
  18. mystack_rig-1.3.1/src/mystack_rig.egg-info/scm_version.json +8 -0
  19. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_agents.py +3 -3
  20. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_ansible_galaxy.py +12 -32
  21. mystack_rig-1.3.1/tests/test_git_credentials_and_author.py +294 -0
  22. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_init_command.py +4 -4
  23. mystack_rig-1.3.1/tests/test_mcp_command.py +293 -0
  24. mystack_rig-1.3.1/tests/test_mcp_render.py +199 -0
  25. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_remote_dev_coverage_extensions.py +90 -0
  26. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_rig_ansible_vars.py +36 -0
  27. mystack_rig-1.3.1/tests/test_secret_prompt_hidden.py +269 -0
  28. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_setup_provision.py +306 -0
  29. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_snapshots.py +34 -3
  30. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_vault_keys.py +21 -0
  31. mystack_rig-1.2.1/src/mystack_rig.egg-info/scm_version.json +0 -8
  32. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/.coveragerc +0 -0
  33. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/.flake8 +0 -0
  34. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/.github/workflows/release.yml +0 -0
  35. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/.github/workflows/tests.yml +0 -0
  36. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/.gitignore +0 -0
  37. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/.rig/playbooks/README.md +0 -0
  38. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/.rig/playbooks/vpn-gateway.yml +0 -0
  39. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/CLI_STORAGE_SUMMARY.md +0 -0
  40. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/Dockerfile +0 -0
  41. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/GIT_CLONE_FEATURE.md +0 -0
  42. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/HETZNER_STORAGE_GUIDE.md +0 -0
  43. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/HETZNER_STORAGE_SECURITY_GUIDE.md +0 -0
  44. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/LICENSE +0 -0
  45. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/Makefile +0 -0
  46. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/README_REAL_E2E.md +0 -0
  47. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/STORAGE_CLI_GUIDE.md +0 -0
  48. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/docs/adr/0001-per-profile-generated-state-bucket.md +0 -0
  49. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/docs/adr/0002-outputs-as-separate-object-via-file-handoff.md +0 -0
  50. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/docs/architecture.md +0 -0
  51. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/docs/architecture.png +0 -0
  52. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/docs/architecture.svg +0 -0
  53. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/forged-idea.md +0 -0
  54. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/pyproject.toml +0 -0
  55. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/pytest.ini +0 -0
  56. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/requirements.txt +0 -0
  57. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/sample.env +0 -0
  58. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/scripts/coverage_badge.py +0 -0
  59. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/scripts/pypi_version.py +0 -0
  60. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/setup.cfg +0 -0
  61. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/__init__.py +0 -0
  62. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/__init__.py +0 -0
  63. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/__main__.py +0 -0
  64. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/config.py +0 -0
  65. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/git.py +0 -0
  66. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/last_env.py +0 -0
  67. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/last_session.py +0 -0
  68. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/log.py +0 -0
  69. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/outputs.py +0 -0
  70. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/requirements.txt +0 -0
  71. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/state_bucket.py +0 -0
  72. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/storage.py +0 -0
  73. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/cli/vpn.py +0 -0
  74. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/mystack_rig.egg-info/dependency_links.txt +0 -0
  75. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/mystack_rig.egg-info/entry_points.txt +0 -0
  76. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/mystack_rig.egg-info/requires.txt +0 -0
  77. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/src/mystack_rig.egg-info/top_level.txt +0 -0
  78. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/test_hetzner_integration.py +0 -0
  79. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/conftest.py +0 -0
  80. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_attach_command.py +0 -0
  81. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_credential_security.py +0 -0
  82. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_destroy_command.py +0 -0
  83. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_dev_command.py +0 -0
  84. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_encrypt_command.py +0 -0
  85. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_encrypt_coverage.py +0 -0
  86. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_firewall_client_ip.py +0 -0
  87. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_git_clone_unit.py +0 -0
  88. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_git_manager.py +0 -0
  89. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_gitignore_init.py +0 -0
  90. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_hetzner_storage.py +0 -0
  91. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_inspect_describe.py +0 -0
  92. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_last_env.py +0 -0
  93. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_last_session.py +0 -0
  94. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_log.py +0 -0
  95. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_main_coverage.py +0 -0
  96. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_outputs.py +0 -0
  97. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_outputs_storage.py +0 -0
  98. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_pypi_version.py +0 -0
  99. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_real_e2e_integration.py +0 -0
  100. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_real_e2e_storage.py +0 -0
  101. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_real_e2e_vpn.py +0 -0
  102. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_real_e2e_vpn_tunnel.py +0 -0
  103. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_remote_dev.py +0 -0
  104. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_rig_config.py +0 -0
  105. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_simulation_storage.py +0 -0
  106. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_small_module_coverage.py +0 -0
  107. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_state_bucket.py +0 -0
  108. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_storage_basic.py +0 -0
  109. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_vpn_optional.py +0 -0
  110. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_vpn_unit.py +0 -0
  111. {mystack_rig-1.2.1 → mystack_rig-1.3.1}/tests/test_workspace_git_clone.py +0 -0
@@ -27,3 +27,19 @@ _Avoid_: Facts, results
27
27
  **Test bucket**:
28
28
  A throwaway state bucket used only by automated test runs.
29
29
  _Avoid_: Dev bucket
30
+
31
+ **Agent**:
32
+ A coding CLI that rig installs on an Environment: OpenCode, Claude Code or Cursor CLI.
33
+ _Avoid_: Coding agent type, CLI, assistant
34
+
35
+ **Stage**:
36
+ One of the playbook steps rig runs in order when creating an Environment: provision, configure, authorize, materialize, finalize. Only provision and configure are cached in a snapshot.
37
+ _Avoid_: Phase, step
38
+
39
+ **MCP server**:
40
+ A tool server declared once in the Workspace and installed into every Agent on its Environments.
41
+ _Avoid_: Plugin, tool, integration
42
+
43
+ **MCP variable**:
44
+ A named value an MCP server needs at runtime, resolved from the vaulted variable whose name matches it ignoring case.
45
+ _Avoid_: MCP secret, MCP env
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mystack-rig
3
- Version: 1.2.1
3
+ Version: 1.3.1
4
4
  Summary: Ephemeral remotes with full local parity for coding agents
5
5
  Author: mystack-cloud
6
6
  License-Expression: MIT
@@ -61,7 +61,45 @@ Chosen at `rig init` (`agent.enabled` in `rig.yml`, same multi-select as git pro
61
61
  | [Claude Code](https://docs.anthropic.com/en/docs/claude-code) | `claude` | One agent: `coding_agent_api_key` (Anthropic). Several agents: `claude_api_key` |
62
62
  | [Cursor CLI](https://cursor.com/docs/cli/overview) | `cursor` | One agent: `coding_agent_api_key` (`CURSOR_API_KEY`). Several agents: `cursor_api_key` |
63
63
 
64
- Each selected agent is asked for its own key. Scaffolds land under `.rig/.opencode/`, `.rig/.claude/`, and `.rig/.cursor/` (plus shared `AGENTS.md`). Independent of `editor` (local IDE for `rig dev`).
64
+ Each selected agent is asked for its own key. Scaffolds land under `.rig/.opencode/`, `.rig/.claude/`, and `.rig/.cursor/` (plus shared `AGENTS.md`). MCP servers are declared once in `.rig/mcp.json` ([below](#mcp-servers)). Independent of `editor` (local IDE for `rig dev`).
65
+
66
+ ## MCP servers
67
+
68
+ Declare an MCP server once in `.rig/mcp.json` and every enabled agent gets it. The file uses Claude's `.mcp.json` schema, and values may reference **MCP variables** as `${NAME}` or `${NAME:-default}`:
69
+
70
+ ```json
71
+ {
72
+ "mcpServers": {
73
+ "awx": {
74
+ "command": "python3",
75
+ "args": ["-u", "/root/awx-mcp-stdio.py"],
76
+ "env": { "AWX_MCP_API_KEY": "${AWX_MCP_API_KEY}" }
77
+ },
78
+ "context7": {
79
+ "url": "https://mcp.context7.com/mcp",
80
+ "headers": { "CONTEXT7_API_KEY": "${CONTEXT7_API_KEY}" }
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ ```bash
87
+ rig mcp add awx --env AWX_MCP_API_KEY -- python3 -u /root/awx-mcp-stdio.py
88
+ rig mcp add context7 --url https://mcp.context7.com/mcp --header 'CONTEXT7_API_KEY=${CONTEXT7_API_KEY}'
89
+ rig mcp list # servers, and whether each variable resolves
90
+ rig mcp check # same, exit 1 on any problem (also lists ignored legacy files)
91
+ rig mcp remove awx
92
+ ```
93
+
94
+ - Bare `--env KEY` means `KEY=${KEY}`; `--env KEY=value` stores a literal. `add` prompts for each `${NAME}` that has no default and no value yet, and vaults it (shared `vars.yml`; `--personal` for `vars.<identity>.yml`).
95
+ - A variable resolves to the vaulted variable with the same name, **ignoring case**: `AWX_MCP_API_KEY` finds `awx_mcp_api_key`. Two variables that differ only by case are an error. Values come from the vars files, inventory and extra vars, not from play-level `vars:`.
96
+ - The authorize Stage renders each enabled agent's own format and writes it into `~/.claude.json` (`mcpServers`), `~/.cursor/mcp.json` and `opencode.json` (`mcp`) on the Environment. A server with the same name is replaced; servers you added by hand there are kept. Secrets are written into those files (mode 0600).
97
+ - A server whose variable has no value is **skipped with a warning**; the create still succeeds. An invalid `.rig/mcp.json` fails the Stage.
98
+ - Fields rig does not translate (anything other than `type`, `command`, `args`, `env`, `url`, `headers`) are dropped with a warning.
99
+ - `rig mcp add/remove` only edit local files. Push to a running Environment with `rig apply --authorize`; `remove` leaves the old entry on Environments that already have it until they are recreated.
100
+ - Cursor's launcher passes `--approve-mcps`, so servers rig installs never prompt.
101
+ - Support files for a server (for example a stdio wrapper script) are not managed by rig: install them from your own playbook (provision, configure or authorize) and point `command` at that path.
102
+ - The per-agent `.rig/.claude|.cursor|.opencode/mcp.json` files from earlier versions are no longer deployed. If one still declares servers, `rig apply`/`create` and `rig mcp check` warn; move them to `.rig/mcp.json`.
65
103
 
66
104
  ## IDEs
67
105
 
@@ -93,12 +131,13 @@ rig.yml # workspace manifest (vm, agent, playbooks, repos)
93
131
  requirements.yml # Galaxy collections/roles
94
132
  local_roles/ # committed Ansible roles (searched first)
95
133
  AGENTS.md # agent instructions
96
- .opencode/ | .claude/ | .cursor/ # agent config + MCP
134
+ .opencode/ | .claude/ | .cursor/ # agent config
135
+ mcp.json # user; MCP servers for every agent (see `rig mcp`)
97
136
  inventory.yml # generated at create/apply (gitignored)
98
137
  collections/ roles/ # Galaxy installs (gitignored)
99
138
  ```
100
139
 
101
- Put a committed role at `.rig/local_roles/<name>/` (`tasks/main.yml` and the usual role layout). `rig init` creates the directory. Galaxy roles install into `.rig/roles/` and stay gitignored. Ansible checks that directory before the configured path, so each committed role is linked there and wins over a Galaxy role of the same name. An older `.rig/galaxy_roles/` directory is moved into `roles` on the next init or apply.
140
+ Put a committed role at `.rig/local_roles/<name>/` (`tasks/main.yml` and the usual role layout). `rig init` creates the directory. Galaxy roles install into `.rig/roles/` and stay gitignored. `.rig/local_roles` comes first in the roles path. Give a committed role a name that no Galaxy role uses: if both exist, Ansible's own lookup finds the one in `.rig/roles` first. An older `.rig/galaxy_roles/` directory is moved into `roles` on the next init or apply.
102
141
 
103
142
  `rig.yml` defaults (edit to configure):
104
143
 
@@ -198,7 +237,7 @@ After you leave an agent TTY, rig captures the printed session / resume id (when
198
237
  | `rig-{version}-{hash}` | provision + configure (`authorize` + `materialize` still run) |
199
238
  | base image | nothing |
200
239
 
201
- **System hash** = var map (`coding_agent_type`, `coding_agent_types`, `git_providers`, `code_server_*`, `workspace_root`) + `provision.yml` + `configure.yml`. Secrets and `authorize.yml` / `materialize.yml` are not included.
240
+ **System hash** = var map (`coding_agent_type`, `coding_agent_types`, `git_providers`, `code_server_*`, `workspace_root`) + `provision.yml` + `configure.yml` + `requirements.yml` (pins Galaxy role versions). Secrets, `authorize.yml`, `materialize.yml` and the role directories (`.rig/local_roles`, `.rig/roles`) are not included, so editing a role used from `materialize.yml` does not discard the cached image. If `configure.yml` uses a local role, run `rig cache clear` after changing it.
202
241
 
203
242
  Override with `--force-playbooks` / `--force-system` (force provision+configure) / `--force-workspace` (force materialize).
204
243
 
@@ -262,6 +301,8 @@ Playbooks load `.rig/vars.yml` then `.rig/vars.{identity}.yml` (personal wins),
262
301
  | `rig_firewall_name` | Firewall resource name |
263
302
  | `rig_repos` | `[{name, url, path}, …]` (no secrets) |
264
303
  | `rig_git_providers` | e.g. `github`, `gitlab` |
304
+ | `rig_identity` | Developer identity (the `.rig/vars.{identity}.yml` handle) |
305
+ | `rig_git_author_name` / `rig_git_author_email` | Git author set on the VM (see [Git credentials and author](#git-credentials-and-author)) |
265
306
 
266
307
  Also available from vars files (defaults): `workspace_root`, `coding_agent_type`, `coding_agent_types`, `git.clone_repos`. On `rig init`, git PATs and each coding agent API key default to **personal** storage in `vars.{identity}.yml` (you are asked to confirm once); shared secrets such as `vscode_browser_password` live in `vars.yml`.
267
308
 
@@ -328,3 +369,37 @@ Push a version tag to publish that version to PyPI. The package version is the t
328
369
  ## License
329
370
 
330
371
  MIT
372
+
373
+ ## Git credentials and author
374
+
375
+ **Provider tokens never go into repo URLs.** `authorize.yml` (managed) takes
376
+ `github_pat` / `gitlab_pat` from the vars files and writes them to
377
+ `/root/.config/rig/git-provider.env` (mode `0600`, root only). From there:
378
+
379
+ - login shells get `GH_TOKEN` / `GITLAB_TOKEN` via `/etc/profile.d`, and `rig attach`
380
+ exports them to the agent process itself (it starts the agent in a non-login
381
+ shell, which never reads `/etc/profile.d`), so `gh` and `glab` work out of the
382
+ box in both;
383
+ - a system-wide git credential helper (`/usr/local/bin/rig-git-credential`)
384
+ answers `github.com` / `gitlab.com` HTTPS requests from that same file, so
385
+ `git clone`, `git push` and the `materialize.yml` clone task all use plain
386
+ URLs (`https://github.com/org/repo.git`) and nothing sits in `.git/config`
387
+ or `git remote -v`. Other users on the VM can't read the file and get no
388
+ credentials.
389
+
390
+ The `materialize.yml` clone task passes the token to git through an inline
391
+ helper fed from the task's environment (a per-repo `password_var` still wins over
392
+ `github_pat` / `gitlab_pat`), so it never touches the URL or disk. Projects
393
+ scaffolded by an older rig still have the token-in-URL clone task in their
394
+ `materialize.yml` (user-owned, never overwritten): copy the `vars:` and
395
+ `environment:` blocks of the current template and set `repo: "{{ item.repo }}"`.
396
+
397
+ **Git author.** A fresh VM has no git identity, so the first commit would fail
398
+ with *Author identity unknown*. `authorize.yml` sets `user.name` / `user.email`
399
+ (global) from `rig_git_author_name` / `rig_git_author_email`, which rig derives
400
+ from your identity: the identity as the name and `<identity>@rig.local` as the
401
+ email. Set `git_author_name` / `git_author_email` in `.rig/vars.yml`, or in your
402
+ personal `.rig/vars.{identity}.yml`, to use a real name and a GitHub-linked
403
+ email (the derived `rig.local` address is deliberately not a
404
+ `users.noreply.github.com` one, which GitHub would attribute to whoever owns
405
+ that handle).
@@ -38,7 +38,45 @@ Chosen at `rig init` (`agent.enabled` in `rig.yml`, same multi-select as git pro
38
38
  | [Claude Code](https://docs.anthropic.com/en/docs/claude-code) | `claude` | One agent: `coding_agent_api_key` (Anthropic). Several agents: `claude_api_key` |
39
39
  | [Cursor CLI](https://cursor.com/docs/cli/overview) | `cursor` | One agent: `coding_agent_api_key` (`CURSOR_API_KEY`). Several agents: `cursor_api_key` |
40
40
 
41
- Each selected agent is asked for its own key. Scaffolds land under `.rig/.opencode/`, `.rig/.claude/`, and `.rig/.cursor/` (plus shared `AGENTS.md`). Independent of `editor` (local IDE for `rig dev`).
41
+ Each selected agent is asked for its own key. Scaffolds land under `.rig/.opencode/`, `.rig/.claude/`, and `.rig/.cursor/` (plus shared `AGENTS.md`). MCP servers are declared once in `.rig/mcp.json` ([below](#mcp-servers)). Independent of `editor` (local IDE for `rig dev`).
42
+
43
+ ## MCP servers
44
+
45
+ Declare an MCP server once in `.rig/mcp.json` and every enabled agent gets it. The file uses Claude's `.mcp.json` schema, and values may reference **MCP variables** as `${NAME}` or `${NAME:-default}`:
46
+
47
+ ```json
48
+ {
49
+ "mcpServers": {
50
+ "awx": {
51
+ "command": "python3",
52
+ "args": ["-u", "/root/awx-mcp-stdio.py"],
53
+ "env": { "AWX_MCP_API_KEY": "${AWX_MCP_API_KEY}" }
54
+ },
55
+ "context7": {
56
+ "url": "https://mcp.context7.com/mcp",
57
+ "headers": { "CONTEXT7_API_KEY": "${CONTEXT7_API_KEY}" }
58
+ }
59
+ }
60
+ }
61
+ ```
62
+
63
+ ```bash
64
+ rig mcp add awx --env AWX_MCP_API_KEY -- python3 -u /root/awx-mcp-stdio.py
65
+ rig mcp add context7 --url https://mcp.context7.com/mcp --header 'CONTEXT7_API_KEY=${CONTEXT7_API_KEY}'
66
+ rig mcp list # servers, and whether each variable resolves
67
+ rig mcp check # same, exit 1 on any problem (also lists ignored legacy files)
68
+ rig mcp remove awx
69
+ ```
70
+
71
+ - Bare `--env KEY` means `KEY=${KEY}`; `--env KEY=value` stores a literal. `add` prompts for each `${NAME}` that has no default and no value yet, and vaults it (shared `vars.yml`; `--personal` for `vars.<identity>.yml`).
72
+ - A variable resolves to the vaulted variable with the same name, **ignoring case**: `AWX_MCP_API_KEY` finds `awx_mcp_api_key`. Two variables that differ only by case are an error. Values come from the vars files, inventory and extra vars, not from play-level `vars:`.
73
+ - The authorize Stage renders each enabled agent's own format and writes it into `~/.claude.json` (`mcpServers`), `~/.cursor/mcp.json` and `opencode.json` (`mcp`) on the Environment. A server with the same name is replaced; servers you added by hand there are kept. Secrets are written into those files (mode 0600).
74
+ - A server whose variable has no value is **skipped with a warning**; the create still succeeds. An invalid `.rig/mcp.json` fails the Stage.
75
+ - Fields rig does not translate (anything other than `type`, `command`, `args`, `env`, `url`, `headers`) are dropped with a warning.
76
+ - `rig mcp add/remove` only edit local files. Push to a running Environment with `rig apply --authorize`; `remove` leaves the old entry on Environments that already have it until they are recreated.
77
+ - Cursor's launcher passes `--approve-mcps`, so servers rig installs never prompt.
78
+ - Support files for a server (for example a stdio wrapper script) are not managed by rig: install them from your own playbook (provision, configure or authorize) and point `command` at that path.
79
+ - The per-agent `.rig/.claude|.cursor|.opencode/mcp.json` files from earlier versions are no longer deployed. If one still declares servers, `rig apply`/`create` and `rig mcp check` warn; move them to `.rig/mcp.json`.
42
80
 
43
81
  ## IDEs
44
82
 
@@ -70,12 +108,13 @@ rig.yml # workspace manifest (vm, agent, playbooks, repos)
70
108
  requirements.yml # Galaxy collections/roles
71
109
  local_roles/ # committed Ansible roles (searched first)
72
110
  AGENTS.md # agent instructions
73
- .opencode/ | .claude/ | .cursor/ # agent config + MCP
111
+ .opencode/ | .claude/ | .cursor/ # agent config
112
+ mcp.json # user; MCP servers for every agent (see `rig mcp`)
74
113
  inventory.yml # generated at create/apply (gitignored)
75
114
  collections/ roles/ # Galaxy installs (gitignored)
76
115
  ```
77
116
 
78
- Put a committed role at `.rig/local_roles/<name>/` (`tasks/main.yml` and the usual role layout). `rig init` creates the directory. Galaxy roles install into `.rig/roles/` and stay gitignored. Ansible checks that directory before the configured path, so each committed role is linked there and wins over a Galaxy role of the same name. An older `.rig/galaxy_roles/` directory is moved into `roles` on the next init or apply.
117
+ Put a committed role at `.rig/local_roles/<name>/` (`tasks/main.yml` and the usual role layout). `rig init` creates the directory. Galaxy roles install into `.rig/roles/` and stay gitignored. `.rig/local_roles` comes first in the roles path. Give a committed role a name that no Galaxy role uses: if both exist, Ansible's own lookup finds the one in `.rig/roles` first. An older `.rig/galaxy_roles/` directory is moved into `roles` on the next init or apply.
79
118
 
80
119
  `rig.yml` defaults (edit to configure):
81
120
 
@@ -175,7 +214,7 @@ After you leave an agent TTY, rig captures the printed session / resume id (when
175
214
  | `rig-{version}-{hash}` | provision + configure (`authorize` + `materialize` still run) |
176
215
  | base image | nothing |
177
216
 
178
- **System hash** = var map (`coding_agent_type`, `coding_agent_types`, `git_providers`, `code_server_*`, `workspace_root`) + `provision.yml` + `configure.yml`. Secrets and `authorize.yml` / `materialize.yml` are not included.
217
+ **System hash** = var map (`coding_agent_type`, `coding_agent_types`, `git_providers`, `code_server_*`, `workspace_root`) + `provision.yml` + `configure.yml` + `requirements.yml` (pins Galaxy role versions). Secrets, `authorize.yml`, `materialize.yml` and the role directories (`.rig/local_roles`, `.rig/roles`) are not included, so editing a role used from `materialize.yml` does not discard the cached image. If `configure.yml` uses a local role, run `rig cache clear` after changing it.
179
218
 
180
219
  Override with `--force-playbooks` / `--force-system` (force provision+configure) / `--force-workspace` (force materialize).
181
220
 
@@ -239,6 +278,8 @@ Playbooks load `.rig/vars.yml` then `.rig/vars.{identity}.yml` (personal wins),
239
278
  | `rig_firewall_name` | Firewall resource name |
240
279
  | `rig_repos` | `[{name, url, path}, …]` (no secrets) |
241
280
  | `rig_git_providers` | e.g. `github`, `gitlab` |
281
+ | `rig_identity` | Developer identity (the `.rig/vars.{identity}.yml` handle) |
282
+ | `rig_git_author_name` / `rig_git_author_email` | Git author set on the VM (see [Git credentials and author](#git-credentials-and-author)) |
242
283
 
243
284
  Also available from vars files (defaults): `workspace_root`, `coding_agent_type`, `coding_agent_types`, `git.clone_repos`. On `rig init`, git PATs and each coding agent API key default to **personal** storage in `vars.{identity}.yml` (you are asked to confirm once); shared secrets such as `vscode_browser_password` live in `vars.yml`.
244
285
 
@@ -305,3 +346,37 @@ Push a version tag to publish that version to PyPI. The package version is the t
305
346
  ## License
306
347
 
307
348
  MIT
349
+
350
+ ## Git credentials and author
351
+
352
+ **Provider tokens never go into repo URLs.** `authorize.yml` (managed) takes
353
+ `github_pat` / `gitlab_pat` from the vars files and writes them to
354
+ `/root/.config/rig/git-provider.env` (mode `0600`, root only). From there:
355
+
356
+ - login shells get `GH_TOKEN` / `GITLAB_TOKEN` via `/etc/profile.d`, and `rig attach`
357
+ exports them to the agent process itself (it starts the agent in a non-login
358
+ shell, which never reads `/etc/profile.d`), so `gh` and `glab` work out of the
359
+ box in both;
360
+ - a system-wide git credential helper (`/usr/local/bin/rig-git-credential`)
361
+ answers `github.com` / `gitlab.com` HTTPS requests from that same file, so
362
+ `git clone`, `git push` and the `materialize.yml` clone task all use plain
363
+ URLs (`https://github.com/org/repo.git`) and nothing sits in `.git/config`
364
+ or `git remote -v`. Other users on the VM can't read the file and get no
365
+ credentials.
366
+
367
+ The `materialize.yml` clone task passes the token to git through an inline
368
+ helper fed from the task's environment (a per-repo `password_var` still wins over
369
+ `github_pat` / `gitlab_pat`), so it never touches the URL or disk. Projects
370
+ scaffolded by an older rig still have the token-in-URL clone task in their
371
+ `materialize.yml` (user-owned, never overwritten): copy the `vars:` and
372
+ `environment:` blocks of the current template and set `repo: "{{ item.repo }}"`.
373
+
374
+ **Git author.** A fresh VM has no git identity, so the first commit would fail
375
+ with *Author identity unknown*. `authorize.yml` sets `user.name` / `user.email`
376
+ (global) from `rig_git_author_name` / `rig_git_author_email`, which rig derives
377
+ from your identity: the identity as the name and `<identity>@rig.local` as the
378
+ email. Set `git_author_name` / `git_author_email` in `.rig/vars.yml`, or in your
379
+ personal `.rig/vars.{identity}.yml`, to use a real name and a GitHub-linked
380
+ email (the derived `rig.local` address is deliberately not a
381
+ `users.noreply.github.com` one, which GitHub would attribute to whoever owns
382
+ that handle).
@@ -0,0 +1,18 @@
1
+ # MCP servers are declared once and rendered per Agent at authorize
2
+
3
+ A Workspace declares MCP servers once in `.rig/mcp.json`, in Claude's `.mcp.json` schema with `${NAME}` MCP variables. The authorize Stage renders each enabled Agent's own config from it and writes the resolved values into the Environment. Each MCP variable resolves to the vaulted variable with the same name, ignoring case, using an Ansible filter plugin that ships with rig.
4
+
5
+ ## Considered Options
6
+
7
+ - **Per-agent files** (`.rig/.claude/mcp.json`, `.cursor/`, `.opencode/`): rejected. One server had to be written three times in three syntaxes, and an Agent enabled later silently lacked servers added earlier. They are retired; rig warns when one still declares servers.
8
+ - **Deploy MCP config in provision**: rejected. Provision is cached in a snapshot and `mcp.json` is not part of the snapshot hash, so edits would not reach new Environments. It also cannot hold secrets.
9
+ - **Leave placeholders in the Agent configs and write the values to an env file**: rejected. It only works if every launch path sources the file and each Agent expands its own syntax. OpenCode turns an unset variable into an empty string without a warning, and Cursor leaves it as literal text.
10
+ - **Resolve secrets in rig and pass them to Ansible as extra vars**: rejected. It would put secrets on the `ansible-playbook` command line.
11
+
12
+ ## Consequences
13
+
14
+ - Secrets are written into the Agents' config files on the Environment (mode 0600), as well as sitting in the vault.
15
+ - A server whose variable has no value is skipped with a warning and does not fail the create. An invalid `.rig/mcp.json` does fail it.
16
+ - A same-name server is replaced whole; servers added by hand on the Environment are kept.
17
+ - Removing a server from `.rig/mcp.json` does not remove it from Environments that already have it.
18
+ - rig does not install a server's support files (for example a stdio wrapper script). The Workspace's own playbooks do.
@@ -7,11 +7,9 @@ Layout under the project (committed, user-editable):
7
7
 
8
8
  .rig/AGENTS.md # shared workspace rules
9
9
  .rig/.opencode/opencode.json # OpenCode config (API key via env)
10
- .rig/.opencode/mcp.json # OpenCode MCP servers
11
10
  .rig/.claude/settings.json # Claude Code settings
12
- .rig/.claude/mcp.json # Claude Code MCP servers (.mcp.json on remote)
13
11
  .rig/.cursor/cli-config.json # Cursor CLI config
14
- .rig/.cursor/mcp.json # Cursor CLI MCP servers
12
+ .rig/mcp.json # MCP servers for every Agent (see `rig mcp`)
15
13
  """
16
14
 
17
15
  from __future__ import annotations
@@ -122,43 +120,24 @@ def sync_opencode_config(
122
120
  _write_json(config_path, opencode_config(has_api_key=has_api_key))
123
121
  return ".rig/.opencode/opencode.json"
124
122
 
125
- OPENCODE_MCP: Dict[str, Any] = {
126
- "mcp": {
127
- # Example (disabled). Uncomment / extend as needed:
128
- # "context7": {
129
- # "type": "remote",
130
- # "url": "https://mcp.context7.com/mcp",
131
- # "enabled": false,
132
- # "headers": {"CONTEXT7_API_KEY": "{env:CONTEXT7_API_KEY}"},
133
- # },
134
- }
135
- }
136
-
137
123
  CLAUDE_SETTINGS = {
124
+ # Bare tool names allow every path; "Tool(*)" warns on recent Claude Code.
138
125
  "permissions": {
139
126
  "allow": [
140
- "Bash(*)",
141
- "Edit(*)",
142
- "Read(*)",
143
- "Write(*)",
144
- "Glob(*)",
145
- "Grep(*)",
127
+ "Bash",
128
+ "Edit",
129
+ "Read",
130
+ "Write",
131
+ "Glob",
132
+ "Grep",
146
133
  ]
147
134
  },
135
+ # Skips the first-run theme picker.
136
+ "theme": "dark",
148
137
  # API key is injected via /etc/profile.d/rig-coding-agent.sh and
149
138
  # ~/.claude/credentials.env (CODING_AGENT_API_KEY / ANTHROPIC_API_KEY).
150
139
  }
151
140
 
152
- CLAUDE_MCP: Dict[str, Any] = {
153
- "mcpServers": {
154
- # Example (disabled). Add servers as needed for Claude Code:
155
- # "filesystem": {
156
- # "command": "npx",
157
- # "args": ["-y", "@modelcontextprotocol/server-filesystem", "/root"],
158
- # },
159
- }
160
- }
161
-
162
141
  # Cursor CLI (~/.cursor/cli-config.json). API key via CURSOR_API_KEY on the VM.
163
142
  CURSOR_CLI_CONFIG: Dict[str, Any] = {
164
143
  "permissions": {
@@ -170,11 +149,6 @@ CURSOR_CLI_CONFIG: Dict[str, Any] = {
170
149
  },
171
150
  }
172
151
 
173
- CURSOR_MCP: Dict[str, Any] = {
174
- "mcpServers": {},
175
- }
176
-
177
-
178
152
  def normalize_agent_type(value: Optional[str]) -> str:
179
153
  raw = (value or "").strip().lower().replace(" ", "-").replace("_", "-")
180
154
  aliases = {
@@ -212,7 +186,7 @@ def agent_remote_paths(agent_type: str) -> Dict[str, str]:
212
186
  return {
213
187
  "config_dir": "/root/.config/opencode",
214
188
  "config_file": "/root/.config/opencode/opencode.json",
215
- "mcp_file": "/root/.config/opencode/mcp.json",
189
+ "mcp_file": "/root/.config/opencode/opencode.json", # `mcp` key, merged at authorize
216
190
  "rules_file": "/root/.config/opencode/AGENTS.md",
217
191
  "env_file": "/root/.config/opencode/credentials.env",
218
192
  }
@@ -227,7 +201,7 @@ def agent_remote_paths(agent_type: str) -> Dict[str, str]:
227
201
  return {
228
202
  "config_dir": "/root/.claude",
229
203
  "config_file": "/root/.claude/settings.json",
230
- "mcp_file": "/root/.mcp.json",
204
+ "mcp_file": "/root/.claude.json", # `mcpServers` key, merged at authorize
231
205
  "rules_file": "/root/.claude/CLAUDE.md",
232
206
  "env_file": "/root/.claude/credentials.env",
233
207
  }
@@ -274,31 +248,18 @@ def ensure_agent_scaffold(
274
248
  )
275
249
  if written:
276
250
  created.append(written)
277
- cfg_dir = os.path.join(rig_dir, ".opencode")
278
- mcp_path = os.path.join(cfg_dir, "mcp.json")
279
- if force or not os.path.exists(mcp_path):
280
- _write_json(mcp_path, OPENCODE_MCP)
281
- created.append(".rig/.opencode/mcp.json")
282
251
  elif agent == "cursor":
283
252
  cfg_dir = os.path.join(rig_dir, ".cursor")
284
253
  config_path = os.path.join(cfg_dir, "cli-config.json")
285
- mcp_path = os.path.join(cfg_dir, "mcp.json")
286
254
  if force or not os.path.exists(config_path):
287
255
  _write_json(config_path, CURSOR_CLI_CONFIG)
288
256
  created.append(".rig/.cursor/cli-config.json")
289
- if force or not os.path.exists(mcp_path):
290
- _write_json(mcp_path, CURSOR_MCP)
291
- created.append(".rig/.cursor/mcp.json")
292
257
  else:
293
258
  cfg_dir = os.path.join(rig_dir, ".claude")
294
259
  config_path = os.path.join(cfg_dir, "settings.json")
295
- mcp_path = os.path.join(cfg_dir, "mcp.json")
296
260
  if force or not os.path.exists(config_path):
297
261
  _write_json(config_path, CLAUDE_SETTINGS)
298
262
  created.append(".rig/.claude/settings.json")
299
- if force or not os.path.exists(mcp_path):
300
- _write_json(mcp_path, CLAUDE_MCP)
301
- created.append(".rig/.claude/mcp.json")
302
263
 
303
264
  return created
304
265
 
File without changes