Skip to content

Commit c56f66f

Browse files
committed
refactor(mcp): the query_records page helpers sit above withDelegationNotice
Claude-Session: https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi Co-authored-by: Claude <noreply@anthropic.com>
1 parent d854348 commit c56f66f

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

‎packages/mcp/src/mcp-http-tools.ts‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,26 +1799,6 @@ function wireCodeOf(err: unknown, thrownCode: string): string {
17991799
return typeof armCode === 'string' ? armCode : thrownCode;
18001800
}
18011801

1802-
/**
1803-
* [ADR-0090 D10 — ruling 2026-09-08, consequence 2] Attach the D10 narrowing
1804-
* notice to a query result WITHOUT reshaping it.
1805-
*
1806-
* The bridge's `query` is typed `Promise<unknown>`, and the shape that ships is
1807-
* the protocol's `{ object, records, total }` — so the object case adds two
1808-
* keys beside the existing ones, mirroring `list_objects`' `partial` / `warning`
1809-
* pair so a client branches on the same vocabulary on both tools. Anything that
1810-
* is NOT a plain object (a bare array from some future bridge) keeps its own
1811-
* shape and carries the notice alongside: inventing a `records` wrapper there
1812-
* would break a caller to deliver a warning about breaking callers.
1813-
*/
1814-
function withDelegationNotice(value: unknown, statement: string): unknown {
1815-
const notice = { delegationNarrowed: true as const, warning: statement };
1816-
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
1817-
return { ...(value as Record<string, unknown>), ...notice };
1818-
}
1819-
return { result: value, ...notice };
1820-
}
1821-
18221802
/**
18231803
* [#35138] May `query_records` read one row past its page, to learn whether
18241804
* the page was capped?
@@ -1867,6 +1847,26 @@ function servedQueryPage(result: unknown, page: number, probed: boolean): unknow
18671847
};
18681848
}
18691849

1850+
/**
1851+
* [ADR-0090 D10 — ruling 2026-09-08, consequence 2] Attach the D10 narrowing
1852+
* notice to a query result WITHOUT reshaping it.
1853+
*
1854+
* The bridge's `query` is typed `Promise<unknown>`, and the shape that ships is
1855+
* the protocol's `{ object, records, total }` — so the object case adds two
1856+
* keys beside the existing ones, mirroring `list_objects`' `partial` / `warning`
1857+
* pair so a client branches on the same vocabulary on both tools. Anything that
1858+
* is NOT a plain object (a bare array from some future bridge) keeps its own
1859+
* shape and carries the notice alongside: inventing a `records` wrapper there
1860+
* would break a caller to deliver a warning about breaking callers.
1861+
*/
1862+
function withDelegationNotice(value: unknown, statement: string): unknown {
1863+
const notice = { delegationNarrowed: true as const, warning: statement };
1864+
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
1865+
return { ...(value as Record<string, unknown>), ...notice };
1866+
}
1867+
return { result: value, ...notice };
1868+
}
1869+
18701870
function jsonText(value: unknown): string {
18711871
try {
18721872
return JSON.stringify(value, null, 2);

0 commit comments

Comments
 (0)