You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 80d474b
Browse filesBrowse the repository at this point in the historyBrowse files
fix(mcp): the objectstack://objects resources serve labels in the locale the object tools speak (#35072)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_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 #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.
<details><summary>@objectstack/mcp tests and typecheck</summary>
`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).
</details>
<details><summary>Ablation (one-shot, not kept)</summary>
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 9169554 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
(9169554), `git diff HEAD` empty. The test imports `./plugin.js` from
source, so no rebuild leg applies.
</details>
<details><summary>Targeted gates</summary>
`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`.
- NOT MEASURED: `pnpm check:dual-build-cjs-loads`, exit 3 `PREREQUISITE
NOT MET` (reads every package's `dist/`; only the mcp closure is built
here). CI runs it.
- `pnpm check:engine-double-contract` was red (exit 1) on the first run
against the test's unused `update` double; green (exit 0) after it was
dropped, and again on the merged head.
- Re-run on the merged head: `check:engine-double-contract`,
`check:type-check-debt`, `check:type-check-coverage`,
`check:test-source-alias`, `check:nul-bytes`, `check-empty-changeset`,
`check-changeset-no-major`, `check-adr-0087-registration`.
- `check-governed-merges --branch`: NOT governed; 304 changed lines,
under 3000. `dispatch-gates --tier`: no path-derived mandate.
- `overlap-check`: clean against origin/main, #35043 and #35060.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (Repo-wide lint is CI's
run; not run locally.)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (Not touched.)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English. (The 维护者速读 section is
Chinese by the fleet's PR rule.)
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm)_
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzfR33NbV51QQU6R6bm -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(mcp): the `objectstack://objects` resources serve labels in the locale the object tools speak
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
Over the stdio transport, the `objectstack://objects` and `objectstack://objects/{name}` resources now answer an object's label, description, field labels, field descriptions and option labels in the workspace's default locale, as `list_objects` and `describe_object` have since the object tools were localized. Before, the resources served the authored text, so a resource read and a tool call for the same object could name it in two languages.
11
+
12
+
- The resources read the same localized view the two tools read, through the same translation the HTTP door's `/meta` answers use. A resource read and a tool call for one object answer the same labels.
13
+
- A field the caller cannot read stays absent from the resources, its translated text with it.
14
+
- With no default locale, or a key the bundle does not carry, the authored text is served, as before. Names never change.
15
+
- The Streamable HTTP door registers no resources, so nothing changes there.
0 commit comments