Skip to content

Commit be67283

Browse files
fix(server): bidirectional _meta.ui<->flat resourceUri sync (v1 parity)
1 parent 47f4cdf commit be67283

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/server/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,15 @@ function normalizeAppToolMeta(
107107
meta: McpUiAppToolConfig["_meta"],
108108
): Record<string, unknown> {
109109
const out: Record<string, unknown> = { ...meta };
110-
// Promote nested form to flat key for hosts that only check the legacy key.
111-
const nested = (meta as { ui?: McpUiToolMeta }).ui;
112-
if (nested?.resourceUri && !(RESOURCE_URI_META_KEY in out)) {
113-
out[RESOURCE_URI_META_KEY] = nested.resourceUri;
110+
const ui = { ...((meta as { ui?: McpUiToolMeta }).ui ?? {}) } as McpUiToolMeta;
111+
const flat = out[RESOURCE_URI_META_KEY];
112+
// Sync both directions so hosts checking either format see the resource URI.
113+
if (ui.resourceUri && !(RESOURCE_URI_META_KEY in out)) {
114+
out[RESOURCE_URI_META_KEY] = ui.resourceUri;
115+
} else if (typeof flat === "string" && !ui.resourceUri) {
116+
ui.resourceUri = flat;
114117
}
118+
out.ui = ui;
115119
return out;
116120
}
117121

0 commit comments

Comments
 (0)