Skip to content

feat(cli): os mcp connect registers your environment's MCP server with Claude Code - #31149

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-30889-os-mcp-connect
Nov 7, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-30889-os-mcp-connect

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by 田騏 · project thread
Fixes #30889
Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:新增 os mcp connect:自动找到 os deploy 用的那个云端环境(--env → 当前激活环境 → 组织唯一环境),读出它的地址,执行 claude mcp add --transport http 环境名 https://环境域名/api/v1/mcp;--print 只打印不执行,--url 连自托管或本地服务。os dev 横幅的 Connect 行改为用同一个拼写函数。
  • 为什么改:以前开发者要连云端环境的 MCP,得自己找环境地址、手拼命令;本地 os dev 有提示,云端没有。现在一条命令完成,登录授权交给 Claude Code 按环境自己的 OAuth 在浏览器里做。
  • 风险与回滚:命令不保存、不写入任何 MCP token,只把 URL 交给客户端;环境解析复用 deploy 的同一函数,多个环境且未给 --env 时同样拒绝。回滚即 revert 本 PR,os dev 横幅输出字节不变。
  • 先看:packages/cli/src/commands/mcp/connect.ts(命名与 --url 规则、执行 claude 的分支);packages/cli/src/utils/served-version.ts(环境详情读取改成可报错的 readCloudEnvironment,deploy 的 fetchEnvironmentOrigin 包在它外面);packages/cli/test/mcp-connect.test.ts。
  • 两分钟验证:pnpm --filter @objectstack/cli exec vitest run test/mcp-connect.test.ts,预期 14 个用例全过;或本地 os dev 起服务后跑 os mcp connect --url http://localhost:3000 --print,打印的 Connect 行与 os dev 横幅那行一字不差。
  • 需要你做的:无,席位落地。

What changes

  • New command os mcp connect (packages/cli/src/commands/mcp/connect.ts).
    • Target: resolveInstallTarget, the function os deploy and os package publish --install use (--env / $OS_ENVIRONMENT_ID, then the active environment for this control plane, then the organization's only environment). None or several ⇒ the same refusal naming --env, exit 1. The only edit to it is an optional purpose so the refusal reads "needs an environment to connect to"; the default wording is unchanged.
    • URL: the environment's hostname from GET /api/v1/cloud/environments/ID, plus /api/v1/mcp. The read is readCloudEnvironment in utils/served-version.ts; deploy's fetchEnvironmentOrigin now wraps it, so the hostname-to-origin rule stays in one place. An unreadable environment or one with no hostname is refused before anything runs.
    • Name: the environment's slug, else its display name, else its id, lower-cased with other characters folded to -. So several environments can be registered side by side. --name overrides it and must be letters, digits, - and _.
    • --url BASE skips the control plane (self-hosted or local os dev). The name defaults to objectstack, the name os dev's banner and the served SKILL.md already use. A URL that already ends in /api/v1/mcp, carries a query, or is not http(s) is refused rather than guessed.
    • Client: Claude Code. Without --print it runs claude mcp add --transport http NAME URL (argv, no shell except on Windows for the .cmd shim). claude missing ⇒ exit 1 with the line to paste. claude failing ⇒ its exit code. --print prints the endpoint and the line and runs nothing. --client accepts only claude-code today.
    • After registering it prints: authenticate with /mcp in Claude Code (the browser shows the environment's sign-in and consent; no token was stored); revoke in the environment's console under Account → Connect an AI Assistant; and the epic's model line (MCP reads the environment for context; a managed package's content changes through its source and os deploy, not through MCP).
  • No token anywhere. The CLI's cloud credential is used only to list and read the environment. It is never put in the client argv or printed, and the command writes no file.
  • os dev's Connect row now prints through the same claudeMcpAddLine builder and MCP_ENDPOINT_PATH. Its output is byte-identical. The existing source pin in dev-mcp-connect-hint-origin.test.ts now asserts the builder call instead of the inline literal.
  • Changeset: @objectstack/cli patch.

Tests

packages/cli/test/mcp-connect.test.ts, 14 cases. It uses the same harness shape as test/deploy.test.ts: the real command, real cloud.json under a redirected $HOME, fetch as the control plane, and the client runner standing in for claude.

  • Acceptance: one environment + --print ⇒ that environment's MCP URL and claude mcp add line, named for the environment, nothing run.
  • Acceptance: --url http://localhost:3000 ⇒ the local line, no control-plane call. The test also asserts that printMcpConnectHint({ boundPort: 3000 }) prints the identical line.
  • Acceptance: two environments and no --env ⇒ exit 1 with deploy's refusal, nothing registered.
  • Acceptance: the run path hands claude exactly mcp add --transport http acme https://acme.example.test/api/v1/mcp. No argument carries the cloud token or a header, the output never prints the token, and every file under $HOME and the working directory is byte-identical before and after.
  • Also covered: --env with the name from the detail read, no hostname / 404 refusals, not logged in, claude not on PATH, claude exit-code passthrough, --name override and refusal, and the name / base-URL helpers.

Acceptance notes

  • Other clients are a follow-up. No config shape for another client (Cursor, VS Code, Claude Desktop, Codex) was written, because none could be cited from that client's docs inside this run. --print covers them: add the printed endpoint as a remote HTTP MCP server in the client's settings. Adding one later means a new --client value with a cited config shape.
  • The staging manual check was not run. This container has no staging login. Steps: os cloud login against staging, then os mcp connect, then /mcp in Claude Code and one browser consent; Claude Code should list the environment's tools. Then revoke the assistant under Account → Connect an AI Assistant; the next tool call should fail.
  • Docs are a follow-up. content/docs/deployment/cli.mdx is not touched because it is outside the claim's file surface. The command's --help carries the description, the examples and every flag.
  • The revoke hint names a console path, not a URL. It points to Account → Connect an AI Assistant, where AuthorizedAccessList lists and revokes the person's authorized assistants. No stable console URL for that page could be confirmed.

Verification

Local runs on head df58740 (all exit codes captured before any pipe):

Derived gate families: 63 of 63 exit 0 on df58740 (dispatch-gates --ran: 63 run, 0 NOT-MEASURED, a derived zero)
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-adoption.mjs :: exit 0
node scripts/check-comment-mask-adoption.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-dts-emitted.mjs --self-test :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-issue-citations.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 0
node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0
node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0
node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/docs-audit/check-affected-docs.mjs :: exit 0
node scripts/docs-audit/check-drift-comment.mjs :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:ci-filter-parity :: exit 0
pnpm check:cli-test-child-env :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:doc-authoring :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:dts-closure :: exit 0
pnpm check:dual-build-cjs-loads :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:i18n :: exit 0
pnpm check:i18n-coverage :: exit 0
pnpm check:i18n-walk-parity :: exit 0
pnpm check:issue-citations :: exit 0
pnpm check:keyed-text-bounds :: exit 0
pnpm check:lean-entry-closure :: exit 0
pnpm check:logger-receiver-detach :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:objectql-double-limit :: exit 0
pnpm check:org-identifier :: exit 0
pnpm check:page-declaration-shape :: exit 0
pnpm check:platform-object-tenancy-census :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:slot-lookup :: exit 0
pnpm check:sourcemap-no-sources-content :: exit 0
pnpm check:system-context-census :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:vouch-for-reference-callers :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
Package runs on df58740
pnpm --filter @objectstack/cli exec vitest run --project unit --maxWorkers=2 :: exit 0 — Test Files 397 passed (397), Tests 5593 passed (5593)
pnpm --filter @objectstack/cli typecheck :: exit 0 — check:test-typecheck OK, 3 file(s) / 28 error(s) held in test-typecheck-debt.json (unchanged)
node --stack-size=4000 node_modules/eslint/bin/eslint.js packages/cli --no-inline-config :: exit 0

The integration tier is left to CI: the diff touches no integration-tier file and no spawn entry.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ihL2dLQEXWGsE2SZ3Qn5F
… Claude Code

Resolves the environment the way os deploy does, reads its hostname from the
control plane, and runs (or with --print, prints) claude mcp add with the URL
alone, named after the environment. --url covers a self-hosted or local server.
No token is stored or handed to the client. os dev's Connect row now prints
through the same line builder.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ihL2dLQEXWGsE2SZ3Qn5F
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/cli, touching 24 documentable anchor(s).

39 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 9f61e06e6fe4d28c0fcc6ef66b3fcfef6067e51b.

⛔ 7 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 1 anchor(s) matched too much of the corpus to be a work list: os dev (command, 43 pages)
  • 4 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 63 of 226 client-bound route-ledger rows — the other 163 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 163: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 104 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 35 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 9f61e06e6fe4d28c0fcc6ef66b3fcfef6067e51b → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 3df1d140b5216d8c4772dc8d151f45bba201490c — the merge of head df587407a11631e548aa03e9b6873f3f226f7e72 into base 9f61e06e6fe4d28c0fcc6ef66b3fcfef6067e51b, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 3df1d140b5216d8c4772dc8d151f45bba201490c && git checkout 3df1d140b5216d8c4772dc8d151f45bba201490c
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 9f61e06e6fe4d28c0fcc6ef66b3fcfef6067e51b df587407a11631e548aa03e9b6873f3f226f7e72 && git checkout -B drift-repro 9f61e06e6fe4d28c0fcc6ef66b3fcfef6067e51b && git merge --no-ff df587407a11631e548aa03e9b6873f3f226f7e72

node scripts/docs-audit/affected-docs.mjs --json 9f61e06e6fe4d28c0fcc6ef66b3fcfef6067e51b

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 9f61e06e6fe4d28c0fcc6ef66b3fcfef6067e51b → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#4 · marchtian · session_017ihL2dLQEXWGsE2SZ3Qn5F

席位核对 — ACCEPT · domain:server#4 · Head-sha: df587407a11631e548aa03e9b6873f3f226f7e72

  • Shape: draft → main, first line attribution, Fixes #30889 once, Clause-②: no, Metadata-protocol: none line-initial in body and changeset. 7 files, +686/−18, all under packages/cli/** + one .changeset; no governed path (check-governed-merges: 0 of 7), under the 3000-line threshold; local git merge-tree against current origin/main clean.
  • Diff read by the seat: commands/mcp/connect.ts (target from resolveInstallTarget, the same resolver os deploy uses, with only an optional purpose for the refusal wording; URL from the environment's hostname; --print prints, --url skips the cloud lookup; no token is stored or written, the URL alone goes to claude mcp add --transport http), utils/served-version.ts (readCloudEnvironment answers its failure; fetchEnvironmentOrigin for deploy wraps it, behaviour unchanged), commands/dev.ts (banner Connect line now built by the shared formatter, bytes unchanged — pinned by dev-mcp-connect-hint-origin.test.ts). No second copy of target resolution.
  • Gates (check-runs on the head): 48 runs — 35 success, 13 skipped, 0 failed. Dev's local dispatch-gates all exit 0 (report 6708449016).
  • Accepted deviations: --client supports Claude Code only; other MCP clients answer a refusal naming the supported one (card asked for Claude Code first).
  • Out of scope: docs + skill mention of os mcp connect → rides docs + skill: teach os environments use-runtime and the self-hosted os deploy target (follow-up owed by #30888 / PR #31137) #31143 (scope extended, comment 6708465377).
  • Landing: Tier: none (non-governed). Seat lands: pr_ready + automerge_enable through the relay.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 7, 2026 15:14
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 42385456389 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Test Core (3/8) — 失败步骤: Run this shard's tests

    @objectstack/runtime:test:  FAIL   local  src/domains/mcp-object-schema-mask.test.ts > [ADR-0106 D1] a standalone or object-less action entry is served as the object door projects it — /meta action do
      ↳ 失败原因: @objectstack/runtime:test: AssertionError: st_rename: expected '{"status":200,"body":{"type":"action"…' to be '{"status":200,"body":{"type":"action"…' // Object.is equality
    

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 19 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#4 · marchtian · session_017ihL2dLQEXWGsE2SZ3Qn5F

Queue ejection read · build 42385456389 · Test Core (3/8) · packages/runtime/src/domains/mcp-object-schema-mask.test.ts:785 (AssertionError), anchor #31171.

  • The expected and received wire texts are identical except the Last-Modified header: 15:19:24 GMT vs 15:19:23 GMT. The assertion compares two responses taken in sequence with second-precision stamps, so it is a timing measurement that crossed a second boundary, not a product difference (the triage comment's timestamp exception).
  • Import closure disjoint: this diff is packages/cli/** + one changeset; the failing file is in packages/runtime and imports nothing from the CLI.
  • The seat re-arms auto-merge once on the same head df587407a11631e548aa03e9b6873f3f226f7e72; a second ejection on this signature stops the re-queue. Diagnosis posted on Queue-flake anchor: src/domains/mcp-object-schema-mask.test.ts #31171.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants