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
fix(servers): address PR review on flatten (#1359)
- Single-source the Inspector-extension key list with `satisfies`
(finding 1). `INSPECTOR_FIELD_KEY_MAP satisfies Record<keyof
StoredInspectorFields, true>` in serverList.ts means a new field on
the type forces a compile error here. The set is exported and
re-used by the server route's smuggle guard, so adding `proxy` or
similar in the future updates all three sites in lockstep. The PUT
preserve path now uses a new `stripInspectorFields` helper that
derives from the same source instead of hand-destructuring.
- Add read-path shape validation in `normalizeMcpServers` (finding 2):
`headers: "oops"` / `metadata: 42` / `oauth: []` / non-numeric
timeouts are dropped individually with a warn, so a hand-edited
malformed file can't put garbage rows into the form. Mirrors the
write-side `validateSettings` symmetry. New integration test covers
each malformed shape with a partial fixture so a single bad key
doesn't take out the whole entry.
- Align new warns to the `fileLogger || console.warn` fallback pattern
(finding 3) via a small `logWarn` helper, so the legacy-drop and
smuggle warns are visible in `npm run dev` where the logger is
often unconfigured.
- Spec doc tweak: the CLI/TUI out-of-scope note's "writes to
`settings.headers`" reference now reads "writes to the entry's
top-level `headers` field on disk (post-#1358 flat shape)" (finding
4). Avoids confusion for future readers.
- Nits: replace `current.mcpServers[originalId]!` with explicit
narrowing; add a comment on the OAuth truthiness drop in
`storedFieldsToInspectorSettings` mirroring the write-side comment.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
"Dropping legacy `settings` node from mcp.json entry — fields now live at the top level. Re-enter via the settings form or hand-edit the file into the flat shape.",
822
869
);
823
-
const{settings: _legacy, ...rest}=valObj;
824
-
out[id]=normalizeServerType(
825
-
restasRecord<string,unknown>&{type?: string},
826
-
)asStoredMCPServer;
827
-
continue;
870
+
deletevalObj.settings;
828
871
}
872
+
873
+
// Per-field shape validation on the Inspector-extension keys. The
874
+
// write path (validateSettings) is symmetric — same checks. Drop
875
+
// bad shapes individually so a single malformed key doesn't take
876
+
// out the rest of the entry; log so the user can fix the file.
"Stripping Inspector-extension keys from request body's `config` — those must travel through the top-level `settings` field, not nested inside `config`.",
886
978
);
@@ -1154,29 +1246,30 @@ export function createRemoteApp(
1154
1246
// malformed settings node on *other* servers in the file — a
1155
1247
// deliberate side-effect of using `readMcpConfig` + full rewrite
1156
1248
// here.
1157
-
constexisting=current.mcpServers[originalId]!;
1249
+
constexisting=current.mcpServers[originalId];
1250
+
if(!existing){
1251
+
// The `in` check above guarantees this branch is unreachable;
1252
+
// narrowing without the non-null assertion keeps TS happy and
1253
+
// makes the contract explicit for future refactors.
1254
+
returnc.json(
1255
+
{error: `Server '${originalId}' not found`},
1256
+
404,
1257
+
);
1258
+
}
1158
1259
// Split the existing entry into its SDK-only config (no Inspector-
1159
1260
// extension fields) and its lifted settings, then apply patch
1160
1261
// semantics from the body to each. The flat-on-disk Inspector
1161
1262
// fields are sliced off `existing` so the preserve-on-omit `config`
1162
1263
// path doesn't accidentally carry them through as raw disk keys —
1163
1264
// they need to flow through `buildStoredEntry` so empty `settings`
Copy file name to clipboardExpand all lines: specification/v2_servers_file.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -261,4 +261,4 @@ Each server entry may carry these Inspector-extension fields at the top level:
261
261
- File watching for hot reload of external edits.
262
262
- Per-server tags / folders / groups.
263
263
- Export current list as JSON.
264
-
- CLI/TUI: switch their default `--config` to `getDefaultMcpConfigPath()` when no `--config` flag is given. Touch when those clients are wired up to v2. While porting, re-add a `--header` flag that writes to `settings.headers` rather than to `MCPServerConfig`.
264
+
- CLI/TUI: switch their default `--config` to `getDefaultMcpConfigPath()` when no `--config` flag is given. Touch when those clients are wired up to v2. While porting, re-add a `--header` flag that writes to the entry's top-level `headers` field on disk (post-#1358 flat shape) rather than to `MCPServerConfig`.
0 commit comments