diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 137dd516..dae00344 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -127,7 +127,11 @@ cd workspace-server && go test -race ./... cd canvas && npm test # Workspace runtime (Python) -cd workspace && python -m pytest -v +# Runtime code is SSOT in molecule-ai-workspace-runtime, not molecule-core/workspace. +cd ../molecule-ai-workspace-runtime +python -m venv .venv && source .venv/bin/activate +pip install --index-url https://git.moleculesai.app/api/packages/molecule-ai/pypi/simple/ -e . pytest pytest-asyncio +pytest -q # E2E API tests (requires running platform) bash tests/e2e/test_api.sh @@ -159,6 +163,19 @@ and run CI manually. | review-check-tests | `review-check.sh` evaluator regression suite (13 scenarios) | | ops-scripts | Python unittest suite for `scripts/*.py` | +### Workspace runtime SSOT + +Runtime code lives in +[`molecule-ai-workspace-runtime`](https://git.moleculesai.app/molecule-ai/molecule-ai-workspace-runtime). +Do not reintroduce `molecule-core/workspace/` or vendored `molecule_runtime/` +copies in consumers. Core and templates consume the published runtime package +from the Gitea package registry. + +For local external MCP agents, multi-workspace config is +`MOLECULE_WORKSPACES=[{"id":"...","token":"...","platform_url":"..."}]`. +`platform_url` selects the tenant; `org_id` is not part of this config. +Workspace IDs can differ across orgs. + ## Local Testing ### review-check.sh diff --git a/docs/guides/external-agent-registration.md b/docs/guides/external-agent-registration.md index 5c7f25bd..4db4a42b 100644 --- a/docs/guides/external-agent-registration.md +++ b/docs/guides/external-agent-registration.md @@ -285,6 +285,39 @@ Canvas requests (no `X-Workspace-ID` header) and system callers --- +## Multiple Workspaces From One Local MCP Bridge + +The standalone runtime package includes `molecule-mcp`, a local MCP bridge for +external agents such as Claude Code, Codex, Hermes, and other tools that run +outside the platform container fleet. One local bridge can serve multiple +external workspaces by setting `MOLECULE_WORKSPACES`: + +```json +[ + { + "id": "workspace-id-local-to-hongming-org", + "token": "...", + "platform_url": "https://hongming.moleculesai.app" + }, + { + "id": "different-workspace-id-local-to-agents-team-org", + "token": "...", + "platform_url": "https://agents-team.moleculesai.app" + } +] +``` + +`platform_url` is the tenant routing key. The bridge registers, heartbeats, +polls inboxes, and sends outbound A2A calls against the URL attached to the +workspace that is doing the work. + +Do not add `org_id` to this config. The tenant already comes from +`platform_url`, and the bearer token is issued by that tenant. Workspace IDs +also do not need to be shared across orgs; each tenant can return its own +workspace ID and token for the same local agent process. + +--- + ## Canvas Appearance External workspaces appear on the canvas with a purple **REMOTE** badge diff --git a/docs/guides/external-workspace-quickstart.md b/docs/guides/external-workspace-quickstart.md index c83c90d6..fdf36b2f 100644 --- a/docs/guides/external-workspace-quickstart.md +++ b/docs/guides/external-workspace-quickstart.md @@ -135,6 +135,33 @@ The `id` field is your workspace ID — remember it. --- +## Optional — one local MCP bridge, multiple tenants + +If your local agent runtime uses `molecule-mcp`, one process can serve more +than one external workspace: + +```bash +export MOLECULE_WORKSPACES='[ + { + "id": "workspace-id-local-to-you-org", + "token": "...", + "platform_url": "https://you.moleculesai.app" + }, + { + "id": "different-workspace-id-local-to-team-org", + "token": "...", + "platform_url": "https://team.moleculesai.app" + } +]' +molecule-mcp +``` + +Use the workspace ID and token returned by each tenant. The IDs may differ +across orgs. `org_id` is not required here because `platform_url` selects the +tenant and the token is tenant-scoped. + +--- + ## Step 4 — Chat with it 1. Open your Molecule canvas at `https://` diff --git a/docs/guides/remote-workspaces.md b/docs/guides/remote-workspaces.md index a6740665..fddbc267 100644 --- a/docs/guides/remote-workspaces.md +++ b/docs/guides/remote-workspaces.md @@ -125,6 +125,33 @@ The agent appears on the canvas with a **purple REMOTE badge** within seconds. F --- +## Multi-Tenant Local MCP Bridge + +For local MCP-driven agents, use the standalone runtime's `molecule-mcp` +entrypoint. A single local bridge can serve multiple external workspaces by +setting `MOLECULE_WORKSPACES`: + +```json +[ + { + "id": "workspace-id-local-to-acme", + "token": "...", + "platform_url": "https://acme.moleculesai.app" + }, + { + "id": "different-workspace-id-local-to-ops", + "token": "...", + "platform_url": "https://ops.moleculesai.app" + } +] +``` + +`platform_url` selects the tenant for registration, heartbeat, inbox polling, +and outbound A2A routing. `org_id` is not required in this config, and the +workspace IDs do not need to match across tenants. + +--- + ## What Phase 30 Covers | Phase | What shipped | Endpoint |