Skip to content

fix(mcp): the objectstack://objects resources serve labels in the locale the object tools speak - #35072

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-34995-object-resources-caller-locale
Nov 18, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-34995-object-resources-caller-locale

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

Fixes #34995

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:stdio 下的 MCP 资源 objectstack://objects 与 objectstack://objects/{name} 现在和 list_objects / describe_object 工具一样,按工作区默认语言返回对象名、字段名、说明和选项名。
  • 为什么改:之前资源返回作者原文,工具返回译文,AI 读同一个对象可能拿到两种语言的标签(卡上的完成判据:资源和工具对同一对象返回相同标签)。
  • 风险与回滚:只改展示文本,不改名字、字段集合和权限;无权读取的字段照旧不出现。回滚即撤销本 PR,资源回到原文。
  • 先看:packages/mcp/src/stdio-data-bridge.ts 的 servedLocaleObjectView(工具与资源共用的唯一翻译入口);packages/mcp/src/plugin.ts 中交给资源的视图套上这层;测试文件 stdio-data-bridge.object-locale-34872.test.ts 末尾的 [#34995] 三条用例。
  • 两分钟验证:pnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2 src/stdio-data-bridge.object-locale-34872.test.ts,预期 8/8 通过。
  • 需要你做的:无,席位落地。

What changes

  • stdio-data-bridge.ts: the mcp: list_objects and describe_object serve labels and descriptions in the caller's locale, as the REST metadata door does #34872 translation (inServedLocale over translateMetaList, with defaultLocaleSources) moves out of createStdioDataBridge to module scope, unchanged, and is wrapped as servedLocaleObjectView(view, { i18n, protocol }): an McpObjectView whose listObjects / getObject answer the wrapped view's objects in the transport's locale, and whose declared-object read hands on the untranslated declaration (only readonly is read off it). list_objects and describe_object now read through this wrapper; the dataset path calls the same module-scope defaultLocaleSources. No second translation routine.
  • plugin.ts: the view handed to the object resources (setRuntimeObjectView, the call site right before bridgeResources) is wrapped in servedLocaleObjectView over the same served view (callerObjectView under a stdio principal), with the same i18n service and protocol reads. The served view is what is translated, never the declaration, so a masked field stays absent (ADR-0106 D3/D5).
  • mcp-server-runtime.ts: doc comment only. buildObjectListResource / buildObjectSchemaResource translate nothing themselves; they serve labels as the view serves them.
  • servedLocaleObjectView is not exported from the package entry (index.ts); no published surface changes.
  • Changeset: @objectstack/mcp patch.

Why

The object tools were localized in #34872 (PR #34922); the two resources still served authored text, so a resource read and a tool call for one object could name it in two languages.

Tests

New [#34995] block in packages/mcp/src/stdio-data-bridge.object-locale-34872.test.ts, booting the real MCPServerPlugin and reading over an in-memory MCP client:

  • zh-CN workspace default: the schema resource serves the bundle's object label, description, field labels and descriptions, and option labels; the list resource serves the translated object label; the schema resource equals describe_object's answer byte-for-byte, and the list resource's labels equal list_objects's (the card's done-when).
  • A field the principal cannot read stays absent from the translated schema resource, and neither its name nor its authored or translated text appears in the raw text; fieldCount counts only served fields.
  • en default with no entry, and no i18n service on the host: authored labels on the resources and the tools alike.

Acceptance notes

  • HTTP door: out of scope by construction. Resources are registered only on the long-lived stdio server (bridgeResources, this.mcpServer.registerResource, mcp-server-runtime.ts); handleHttpRequest builds a per-request server that registers tools and prompts and no resources, so there is no HTTP resource to localize.
  • File surface: the claim names mcp-server-runtime.ts "and where the resources are registered". The resources' view is handed over and bridgeResources is called in plugin.ts (setRuntimeObjectView at the resource registration call site), so the wrap lands there. It is the only place the resources' view is set.
  • The engine double in the new test block declares find and getSchema only (the verbs the stdio principal resolution reads); a first draft carried an unused update that check:engine-double-contract flagged.

Verification

All readings on head 689463fd78 (after merging origin/main at eb7b09d4d2) unless noted.

@objectstack/mcp tests and typecheck

pnpm --filter '@objectstack/mcp^...' build then pnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2 and pnpm --filter @objectstack/mcp typecheck, under the verify lock: VERDICT command-exit 0; Test Files 71 passed (71), Tests 1261 passed (1261); check:test-typecheck: OK (53 errors / 8 pinned signatures held, unchanged).

Ablation (one-shot, not kept)

Committed fix first, then node scripts/ablation-replace.mjs on packages/mcp/src/plugin.ts, anchor { i18n: () => optionalService('i18n'), protocol: protocolReads }, replaced by {}, (the resources' view keeps the wrapper but loses its locale source; the tools are untouched). Anchor x1 to x0, blob 9169554f98 to 85772e895f. Test file run: Tests 2 failed | 6 passed (8), the zh-CN case (expected { name: 'deal', label: 'Deal', … } to match … label: '交易') and the masked-field case (expected 'Deal' to be '交易'); the authored-label case stays green, as expected. Restored: blob equals HEAD (9169554f98), git diff HEAD empty. The test imports ./plugin.js from source, so no rebuild leg applies.

Targeted gates

node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --commands (no paths): 69 commands, all run; --ran with recorded exit codes: 69 derived famil(ies) accounted for — 68 run, 1 NOT-MEASURED.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes. (Repo-wide lint is CI's run; not run locally.)
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (Not touched.)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English. (The 维护者速读 section is Chinese by the fleet's PR rule.)
  • The Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code

@github-actions github-actions Bot added size/m 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 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/mcp, 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/ai/agents.mdx (via MCPServerRuntime (symbol, a top-level class))
What this run could not see
  • 3 name(s) were too generic to anchor anything (single lowercase words)
  • 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 — 12 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 1282a464e9d27c2f8b86e69026087d1a1ff9b2df → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 391e25be331a53aee1b8a168e1e75f757a40296e — the merge of head 689463fd78db407702ca6113b4b9b05984557811 into base 1282a464e9d27c2f8b86e69026087d1a1ff9b2df, 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 391e25be331a53aee1b8a168e1e75f757a40296e && git checkout 391e25be331a53aee1b8a168e1e75f757a40296e
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 1282a464e9d27c2f8b86e69026087d1a1ff9b2df 689463fd78db407702ca6113b4b9b05984557811 && git checkout -B drift-repro 1282a464e9d27c2f8b86e69026087d1a1ff9b2df && git merge --no-ff 689463fd78db407702ca6113b4b9b05984557811

node scripts/docs-audit/affected-docs.mjs --json 1282a464e9d27c2f8b86e69026087d1a1ff9b2df

⚠️ 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 1282a464e9d27c2f8b86e69026087d1a1ff9b2df → 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-18T01:34Z

Head-sha: 689463f
Reviewer: seat 3 L1-c, for card #34995 (os-dev report 6966266996).

席位核对

PR shape. Fixes #34995, base main, with main merged in at the head. Five paths, +256/-47:

  • stdio-data-bridge.ts, plugin.ts, and a docblock in mcp-server-runtime.ts;
  • the pin file;
  • an @objectstack/mcp patch changeset.

Not governed. plugin.ts is where the resources' view is set, so the claim's "where the resources are registered" covers it. I read it the same way o3-E does.

Clause-②: no holds under the seat's ruling. servedLocaleObjectView is exported from stdio-data-bridge.ts only. @objectstack/mcp's index does not re-export that module, so no published export is added. The resources keep the same fields. Only the language of the label and description values changes, so no field is added, removed or renamed.

CI. It was still running when I read it (21 pending, nothing failed). This verdict holds on the condition that Lint & Repo Gates, TypeScript Type Check and Test Core finish green on this head.

One routine, moved as is. defaultLocaleSources and inServedLocale move from inside createStdioDataBridge to module scope. The body is unchanged: translateMetaList, with metaRequestLocale(undefined, i18n) as the locale, and a throwing i18n resolver treated as none. The bridge's own dataset translation now passes deps.i18n explicitly, the one call site the closure used to cover.

The new wrapper. servedLocaleObjectView localizes listObjects and getObject over the view it wraps. It registers its own declared read, so readObjectWithDeclaration returns the localized served object beside the untranslated declaration, which is read for readonly alone. The tools and the resources now read the same wrapper over the same caller view:

  • The tools. createStdioDataBridge builds localizedView = servedLocaleObjectView(servedView, …). list_objects and describe_object read it.
  • The resources. plugin.ts wraps the view it hands setRuntimeObjectView the same way: over callerObjectView when a stdio principal exists, else the bare view, with the same optionalService('i18n') and protocol reads. That view is read only by the two object-resource builders (bridgeResources, the objects() closure), so nothing else is affected.

The mask holds. The translator rewrites text on the fields it is given and adds none. It is applied to the served object, never the declaration, so a masked field stays absent along with its translated text.

The pins drive the real wiring. The #34995 block boots MCPServerPlugin over a host, with i18n registered or not, and reads the two resources through an MCP client:

  • under a zh-CN default, both resources equal describe_object and list_objects, label for label;
  • a masked field is absent from the translated resources;
  • with an en default and no entry, or no i18n service, the tools and the resources both serve the authored text.

The #34872 block still holds over the moved routine. The ablation turns the resource pin red.

HTTP. Streamable HTTP registers no resources, so it is out of scope by construction, as the changeset says.

Must-fix

None.

Should-fix

None.

Notes

  • N1. The stdio locale is still the i18n service's default, the workspace default. The stdio transport carries no request, so a per-caller locale cannot exist here. The tools and the resources now agree on that one locale, which is what the card asked. Not owed.

Next: o3-E lands once the three aggregates are green. 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_01WGufzfR33NbV51QQU6R6bm

Landing · 2026-11-18T01:55Z

Probe Reading
Governed check-governed-merges.mjs --pr 35072: NOT governed, 303 changed lines
Head 689463fd78db407702ca6113b4b9b05984557811, 7 first-parent commits behind main (under 15, so no merge). It includes the merge of main at eb7b09d4d2
Review L1-c ACCEPT 6966314981 at 689463fd, with no must-fix and no should-fix. No seat L2 is owed (L1-c, non-governed). Claim 6964754221
Checks All 53 check-runs on 689463fd succeeded or were skipped
Scope The stdio object resources read the same localized served view as list_objects / describe_object (#34872's routine, moved unchanged). The mask holds. HTTP registers no resources. Clause-②: no, which L1-c confirmed under the seat's MCP-surface ruling

State: ready + auto-merge armed. Fixes #34995.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 18, 2026 01:56
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit 80d474b Nov 18, 2026
54 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-34995-object-resources-caller-locale branch November 18, 2026 02:18
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/m 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: the stdio object resources serve labels and descriptions in the workspace default locale, as the object tools now do

2 participants