Skip to content

feat(mcp): list_objects and describe_object serve labels and descriptions in the caller's locale - #34922

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-34872-mcp-object-tools-locale
Nov 17, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-34872-mcp-object-tools-locale

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

Fixes #34872

Clause-②: no
Metadata-protocol: none

repo:objectstack#3 · os-support-ai · session_01WGufzgNCAXyGfBQFZBwixH

维护者速读

  • 改了什么:MCP 的 list_objects 和 describe_object 现在按调用者的语言返回对象标签、对象描述、字段标签、字段描述和选项标签。HTTP 读请求的 Accept-Language,stdio 用 i18n 服务的默认语言。两者调用的都是 REST /meta 对象接口用的同一个翻译函数(translateMetaList),没有另写一套翻译。
  • 为什么改:中文用户在问数时,如果没有指标能回答,会转去用对象工具,看到的却是英文标签和英文描述。REST 接口对同样的文本已经做了翻译。
  • 风险与回滚:先按字段权限掩码,再翻译,所以被屏蔽的字段和它的译文都不会回来。字段名和选项值不变,输出结构不变。还有一处行为变化:HTTP 请求不带 Accept-Language 时,现在会取 i18n 默认语言(en)包里的值,和 REST 一致(app-crm 的 amount 因此显示为 "Deal Value")。回滚就是撤销这两个源文件的改动。
  • 先看:① packages/runtime/src/domains/mcp.ts 里的 inCallerLocale,以及它在 listObjectSummaries / describeObject 的两处调用(风险点:翻译必须作用在 servedToCaller 返回的对象上);② packages/mcp/src/stdio-data-bridge.ts 里的 inServedLocale,以及 describeObject;③ 两个 *-34872.test.ts 测试里关于字段掩码的用例。
  • 两分钟验证:pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/mcp-object-locale-34872.test.ts,预期 Tests 5 passed (5)。
  • 需要你做的:无,席位落地。

What changes

  • HTTP door (packages/runtime/src/domains/mcp.ts): new inCallerLocale translates the objects as the caller is served them (servedToCaller, the ADR-0106 mask) with translateMetaList, the routine GET /meta/object and the dataset tools already run. The locale is this request's, read by metaRequestLocale (Accept-Language, then ?locale=, then the i18n default). list_objects translates the whole page in one call. describe_object translates the one served object, then projects it with describeServedObject. declared is still read only for the readonly verdict. A new module helper, metaTranslationSources, holds the i18n, protocol and locale reading. loadDatasets now calls it too, so the dataset tools and the object tools answer one caller in one locale. The dataset behaviour is byte-for-byte the same.
  • stdio door (packages/mcp/src/stdio-data-bridge.ts): new inServedLocale does the same over callerObjectView. The locale is the i18n service's default, the reading the stdio list_datasets already uses: the transport carries no request. defaultLocaleSources is shared with loadDatasets.
  • What gets translated is what the translator translates on the served object: object label and description, field label, field description from the bundle's help key, option labels (field-level, then the bound picklist's), and validation messages. Names, option values and the answer's shape are unchanged. Clause-② stays no.
  • The two new test files are named for this card. A patch changeset covers @objectstack/runtime and @objectstack/mcp.

Tests

New pins: HTTP 5/5, stdio 5/5, plus the sibling #34721 and dataset-locale suites
  • packages/runtime/src/domains/mcp-object-locale-34872.test.ts: real SecurityPlugin on a real ObjectQL over SqlDriver, through the real /mcp entry, with an i18n double carrying a zh-CN bundle. Cases: zh-CN translates the label, description and option label, and names stay; list_objects under zh-CN; a masked field stays absent and its zh-CN label and help text never appear, and the member's fieldCount is the staff count minus 1; no header (default en, no entry) serves the authored text; fr-FR, or no i18n service, serves the authored text.
  • packages/mcp/src/stdio-data-bridge.object-locale-34872.test.ts: the real tools (registerObjectTools) over the stdio bridge with securityDoubleFor. The same five cases at the default locale, including an i18n resolver that throws.
  • Run at 5334bf9: mcp 3 files / 13 tests passed (34872, 34721 and dataset-locale); runtime 2 files / 9 tests passed (34872 and 34721).
  • Whole packages at 2ba60e9: pnpm --filter @objectstack/mcp test gave Test Files 70 passed (70), Tests 1246 passed (1246). pnpm --filter @objectstack/runtime test gave Test Files 615 passed (615), Tests 11415 passed | 23 skipped (11438). Both lock verdicts were command-exit 0.
  • pnpm --filter @objectstack/mcp --filter @objectstack/runtime typecheck: exit 0, including check:test-typecheck.
Ablation: four legs, each red, each restored to the HEAD blob

The subjects are imported by relative path from src, so no dist was involved. Each mutation went through scripts/ablation-replace.mjs: the anchor went from 1 hit to 0, and the blob was restored equal to HEAD with an empty git diff HEAD.

  1. HTTP: the translation was skipped (served.length >= 0). Blob b4a8eb66b4e3 became 7199ebfa2457. Result: Tests 3 failed | 2 passed (5) (describe zh-CN, list zh-CN, masked case). Restored.
  2. HTTP: the declared (unmasked) object was translated instead of the served one. Blob b4a8eb66b4e3 became 15a308b1cfbe. Result: Tests 1 failed | 4 passed (5), at expect(field(described, DENIED)).toBeUndefined(). Restored.
  3. stdio: the translation was skipped. Blob f4f5d631df30 became cf940693b548. Result: Tests 3 failed | 2 passed (5). Restored.
  4. stdio: the declared object was translated. Blob f4f5d631df30 became c1f5e4a46e50. Result: Tests 1 failed | 4 passed (5) (masked case). Restored.

Acceptance notes

  • Done-when reading (live, app-crm, HTTP MCP, Accept-Language: zh-CN, describe_object crm_opportunity). Before, at fc5913e: Opportunity / A potential sale tied to an account., stage options Prospecting, Qualification, Proposal, Closed Won. After, at 5334bf9: 商机 / 与客户关联的潜在销售机会。, fields 商机名称, 阶段 (options 初步接洽, 需求确认, 方案报价, 赢单), 金额, 预计成交日期, 创建时间. This matches the REST /meta/object/crm_opportunity door's zh-CN answer. list_objects under zh-CN now lists 客户, 活动, 联系人, 线索, 商机, 产品明细, each with its zh-CN description.
  • No-header reading on HTTP now serves the i18n default locale's (en) bundle entries, because metaRequestLocale falls back to that default. The REST door does the same: /meta/object/crm_opportunity with no header answers amount: Deal Value, close_date: Expected Close. app-crm's en bundle relabels both away from the authored Amount / Close Date. The MCP answer follows REST here. This is an observation about the example's bundle, not a defect of this change.
  • A field that authors inlineHelpText: the translator serves the bundle's help entry on inlineHelpText and keeps description in the source language (its documented slot rule). MCP serves description only, so such a field's description stays in the authored language. This is the shared translator's rule, left unchanged.
  • The stdio MCP resources objectstack://objects and objectstack://objects/{name} (mcp-server-runtime.ts) still serve the authored text. The card names the two tools only, so the resources were not changed. carrier: Decision: open-source MCP — the client thinks locally, the server keeps a thin door (a metadata draft write entry for building; the data door for 问数), plus policy, version skew and the 问数 eval #34659.
  • The describe_object / list_objects tool descriptions (mcp-http-tools.ts) do not mention the locale. The answer's shape is unchanged, so they were left as they are (outside the claim surface).
  • main moved 15 commits after fc5913e. None touches this diff's files. overlap-check against origin/main 13e0305 and fix(mcp): render the /mcp/skill data loop from the published objectstack-ask skill #34881 reports VERDICT clean exit 0.

Verification

Derived gate families (`dispatch-gates --commands`, 68) at 2ba60e9
  • 66 of 68 exited 0, including check:nul-bytes, check:test-source-alias, check:cross-package-test-inputs, check:doc-authoring, check:issue-citations, check:empty-changeset, check:adr-0087-registration and check:changeset-no-major.
  • 2 exited 3 and are NOT MEASURED: check:dual-build-cjs-loads (PREREQUISITE NOT MET — only the example-crm closure is built here, 14 packages have no dist), and check-plugin-teardown-shape.mjs --self-test (a shallow clone cannot reach the pinned positive-control commit; it grades the checker, not this diff). CI runs both.
  • dispatch-gates --ran: 68 derived, 68 run, 0 NOT-MEASURED, 0 UNRUN.
  • test:repo, dogfood (no !, no narrowing arm) and the type-check lanes run in CI.

Generated by Claude Code

@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 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/mcp, @objectstack/runtime, touching 6 documentable anchor(s).

1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/permissions/authorization.mdx (via buildMcpBridge (symbol, a top-level function))
What this run could not see
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 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; 123 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 — 37 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 13e0305c3391db13c75b39762f4cdd8ec8f4a28f → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 8c27b9038262817dd09ec47b3d6c9c68f6bca452 — the merge of head 2ba60e904c6efa353c0d4ffb34eeea82a25ae6d3 into base 13e0305c3391db13c75b39762f4cdd8ec8f4a28f, 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 8c27b9038262817dd09ec47b3d6c9c68f6bca452 && git checkout 8c27b9038262817dd09ec47b3d6c9c68f6bca452
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 13e0305c3391db13c75b39762f4cdd8ec8f4a28f 2ba60e904c6efa353c0d4ffb34eeea82a25ae6d3 && git checkout -B drift-repro 13e0305c3391db13c75b39762f4cdd8ec8f4a28f && git merge --no-ff 2ba60e904c6efa353c0d4ffb34eeea82a25ae6d3

node scripts/docs-audit/affected-docs.mjs --json 13e0305c3391db13c75b39762f4cdd8ec8f4a28f

⚠️ 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 13e0305c3391db13c75b39762f4cdd8ec8f4a28f → 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

repo:objectstack#3 · os-support-ai · session_01WGufzfWpJ96QY9T7d8DvFg

L1: ACCEPT · 2026-11-17T16:45Z

Head-sha: 2ba60e9
Reviewer: seat 3 L1-c, for card #34872 (child of epic #34659; claim 6951869284; os-dev report 6953902671), at o3-G's request.

席位核对

PR shape. Fixes #34872, base main. Five paths:

  • packages/runtime/src/domains/mcp.ts and packages/mcp/src/stdio-data-bridge.ts;
  • one new test file beside each;
  • one changeset.

Declaration. Clause-②: no / Metadata-protocol: none, and they agree. The answer's shape is unchanged; only the values of label, description and option label move. @objectstack/runtime and @objectstack/mcp at patch are right. The seat ruled no L2 (16:23Z), and I see no contract face that would change that.

Governed / size. check-governed-merges --pr 34922: NOT governed, 618 lines.

Check-runs at 2ba60e9. 57 runs, every one success or skipped: Lint & Repo Gates, TypeScript Type Check, Test Core and all 10 shards, Live E2E UI, Check Changeset, PR-body guards, Governed Surface Queue Guard, Flag docs affected by code changes.

One routine, not two.

  • HTTP: inCallerLocale runs the /meta door's translateMetaList with the new metaTranslationSources(deps, context, getProtocol). That resolves the i18n service (a throw means none), the protocol, and metaRequestLocale, which reads Accept-Language, then ?locale=, then the i18n default.
  • datasetToolMembers now uses the same sources. The dataset path's envId was context.environmentId before, so nothing changes there.
  • stdio: inServedLocale runs the same routine through defaultLocaleSources, with metaRequestLocale(undefined, i18n), which means the i18n default. That is the locale stdio list_datasets already used (fix(mcp): stdio list_datasets localizes the dataset catalogue for the workspace default locale #34833). The dataset path is folded onto the same helper with no change in behaviour.
  • So one caller gets one locale for both the object and the dataset tools, on each transport.

After the mask. Both doors translate the object as the caller is served it: servedToCaller on HTTP, and callerObjectView on stdio. The translator rewrites the text of the fields it is given and adds none, so a masked field and its translated text both stay absent. Each new test file pins that case, and the report's two ablations (translate the declared object) leak the masked field. declared is still read only for the readonly verdict.

What the translation does not touch.

  • validate_expression reads describeObject's field name and type only (mcp-http-tools.ts around line 2806). Names never change, so its scope is unchanged.
  • optionFieldsOf and servedObjectDefinitionOf still read the untranslated served object, on both doors, so the publish-gate passes judge the authored definition.
  • Option values are unchanged, so the ask skill's "filter an option field by its value" still holds.

Tests. 5 HTTP cases and 5 stdio cases cover:

  • zh-CN for describe and list;
  • the masked field;
  • no preference, or en with no entry;
  • a locale the bundle does not carry;
  • no i18n service, or a resolver that throws (authored text, never an error).

The report also has a live zh-CN reading on app-crm that matches REST /meta.

Docs made false? None. Neither connect-mcp.mdx nor the MCP README says what language list_objects or describe_object labels come in. The changeset states the change.

Must-fix

None.

Should-fix

None.

Notes

Next: o3-G lands. No seat L2 is owed. A later push owes an L1-c delta read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgNCAXyGfBQFZBwixH

Landing · 2026-11-17T16:48Z

Probe Reading
L1 ACCEPT 6954596038 (L1-c) at 2ba60e904c6efa353c0d4ffb34eeea82a25ae6d3; no must-fix, no should-fix; notes only; seat ruled no L2
Governed check-governed-merges.mjs --pr 34922: NOT governed, 0 of 5 paths, 618 lines ≤ 3000
CI at head 57 check-runs success or skipped (L1-c read); CI run 44124241478 completed success
K behind main PRBASE = main tip when CI ran at 16:18Z, 189358f21, which is still origin/main: K = 0. (16 first-parent commits from the older merge-base git merge-base, all inside the green PR run's merge ref.)
Overlap overlap-check.mjs --pr=34881,34904: origin/main, #34881 and #34904 all merge cleanly

Ready + auto-merge into the queue. Area o3-G (repo:objectstack#3) watches it to MERGED and closes out #34872.

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

Development

Successfully merging this pull request may close these issues.

mcp: list_objects and describe_object serve labels and descriptions in the caller's locale, as the REST metadata door does

2 participants