Repository navigation
Commit 4588406
feat(app): MCP server add/edit/remove UI on the settings-v2 MCP tab (#40)
* feat(config): MCP server editing -- split Patch to make secret loss inexpressible
Foundational piece for MCP config editing (TKT-323, operator priority):
adds add/edit/remove for MCP servers through the existing typed config-
document Patch mechanism. Caught before any consumer existed: the obvious
shape (mcp.server.set takes a full ConfigMCP.Server, whole-value write)
would have silently destroyed a server's credentials on every connection-
detail edit that didn't also resupply them -- and the client structurally
cannot resupply them, since every read response redacts secret fields by
design (the anomalyco#191 fix). Verified directly: modify()'s whole-value replace
at ["mcp","servers",name] discards any field absent from the incoming
value, and there is no way for an editor working from a redacted view to
correctly round-trip a value it never held.
THE FIX (lead ruling): split the op at the schema level rather than merge
at write time from client-supplied data.
- mcp.server.set's value narrows to ConfigMCP.ServerNonSecret -- a type
that structurally cannot mention environment/headers/oauth.client_secret,
so a connection-detail edit cannot destroy what it cannot carry. Applied
server-side via mergeNonSecretPatch: the EXISTING secret fields (read
fresh from the current on-disk text, never from the patch) are carried
forward onto the merged write, but only when the server's own `type` is
unchanged (local's environment and remote's headers/oauth are different
shapes -- a type change has nothing compatible to carry over).
- New mcp.server.credential.set(name, key, value) / .credential.remove
write or delete exactly one named secret slot, never reading the old
value back. CredentialKey reuses the same three-location allowlist
mcpSecretPaths already enumerates for redaction, so read-side and
write-side allowlists cannot drift into naming different fields.
- patchWritesRedactedSentinel narrows to credential.set only -- the other
three ops cannot carry a secret value at all post-split, so there's
nothing left for the sentinel-rejection check to catch on them.
Delete-the-fix proof, as required: "applyPatch: editing a server's command
preserves its existing secret fields" confirmed RED against a temporarily
reverted whole-value-replace write (the secret came back as `undefined`
after an unrelated command edit -- concrete, not hypothetical), GREEN under
the split. Also covers: type-change doesn't carry over incompatible secret
shapes, credential.set/.remove work standalone, and the sentinel-rejection
test moved onto credential.set.
Client: mcp-catalog-client.ts renamed mcp-client.ts and widened in place
(lead ruling: same file, not a 5th bounded importer, since MCP editing is
the same feature this file already serves) to add configDocument.target
Read/Validate/Apply. All three sibling headers + FORK.md's ledger updated
to describe the widened scope; the boundary is stated explicitly (MCP tab
only -- skills/plugins/profiles editing gets its own widen-or-new decision
when a second real consumer exists, not before).
Wire change: packages/client regenerated (Patch's mcp.server.set payload
narrowed, two new ops added) -- drift guard verified clean in the same
commit. Full monorepo typecheck 32/32, core suite 1199/1199, app suite
754+41/0 fail, httpapi-exercise effect mode 236/0.
App UI (add/edit/remove forms on the MCP tab) follows in a subsequent
commit on this branch.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JJQrqYMv43CrdbjpTT7884
* feat(app): MCP server add/edit/remove UI on the settings-v2 MCP tab
Operator scope change (Sean via Ethan): the MCP tab was read-only. Wires
add/edit/remove through the config-document Patch mechanism split in
ed3140f -- non-secret fields via mcp.server.set, credentials via their
own credential.set/remove ops, so a plain edit (e.g. a command change)
never round-trips or risks a secret.
- mcp-server-form.ts: form controller. Edit mode prefills non-secret
fields plus existing credential KEY NAMES only (never values); submit
chains targetRead -> targetApply(set) -> targetApply(credential ops)
per row, threading the returned hash forward each time.
- dialog-mcp-server.tsx: the add/edit dialog UI.
- mcp.tsx: Add server / per-row Edit + Remove wiring, resolveAddTarget()
(targetList, prefers a project target) for servers with no existing
catalog entry to read a target off of.
- mcp-client.ts (renamed from mcp-catalog-client.ts): widened from
mcp.list/mcp.status to add the four config-document verbs this tab
needs -- still the same 4th bounded client-next importer, not a 5th.
- i18n: new settings.mcp.action/dialog.* keys, KNOWN_MISSING bumped to
1844 pending-first-attempt entries under TKT-373.
- e2e: add/edit/remove specs against a route-level config-document mock.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JJQrqYMv43CrdbjpTT7884
* fix(app): split the KNOWN_MISSING pin by kind, not one combined total
Henry's review on #40: pending-first-attempt now dominates (83% of the
list) and spikes with every feature that adds locale keys, so a future
PR quietly adding a handful of verified-failed entries inside a
thousand-entry pending bump would be invisible against a single total
-- and that handful is exactly the signal this mechanism exists to
catch. verified-failed stays near-static; pending-first-attempt is
expected to breathe with feature work. Two numbers, each bumped
deliberately for its own reason.
319 verified-failed (unchanged), 1525 pending-first-attempt (was 1844
combined).
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JJQrqYMv43CrdbjpTT7884
* fix(config): preserve a remote server's oauth block on unrelated edits
Copilot review, PR #40 (suppressed comments -- expanded per the /work
skill, not the inline comment): mergeNonSecretPatch's oauth
carry-forward only fired when the incoming mcp.server.set patch value
already had a truthy `oauth` object. The current dialog never sends
`oauth` at all (editing it is out of scope for this cut), so every
edit to a remote server -- url, disabled, timeout, anything -- silently
wiped the whole existing oauth block, including client_secret. Exactly
the secret-loss shape this PR exists to make inexpressible, missed for
this one field.
Fixed by distinguishing three cases on the incoming value: explicit
`oauth: false` (deliberate disable, wipes on purpose), a real oauth
object (a future oauth-editing UI -- carries the existing secret
forward onto the new shape, as it did before), and omitted entirely
(the only case the current UI produces -- now carries the whole
existing block forward untouched, same treatment as headers/
environment). Delete-the-fix regression test added and confirmed red
under the old code, green under the fix.
Also from the same review: two more findings, both genuine --
- FORK.md's importer ledger said "five calls", missing targetList
(used to resolve a target for a brand-new server). Now six.
- config-document.ts's patch-union comment still said "chunk 1 only
needs MCP server set/remove", stale since the credential ops split.
- Two more hard-coded English error strings (mcp.tsx, mcp-server-form.ts)
moved to i18n, same as the rest of this tab's UI text -- pin bumped
183->1525->1647 pending-first-attempt (+122 = 2 keys x 61 locales).
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JJQrqYMv43CrdbjpTT7884
* docs(config): cross-reference ServerNonSecret and its dependent guard
Ethan's ruling (ledger-49 shape, third instance this week, Henry's
generalization): whenever a guard narrows because a type or invariant
makes the rest unreachable, the narrowing and the invariant reference
each other in comments -- so widening one without touching the other
fails loudly in review, not silently in production.
patchWritesRedactedSentinel shrank to covering only
mcp.server.credential.set because ServerNonSecret structurally cannot
express a secret field on mcp.server.set at all. Widening
ServerNonSecret to carry one again would silently un-cover that op
with no type error and no test failure until someone writes
[redacted] back through it. Each site now points at the other.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JJQrqYMv43CrdbjpTT7884
---------
Co-authored-by: opencode <[email protected]>
Co-authored-by: Claude Sonnet 5 <[email protected]>1 parent d6a7f1a commit 4588406
19 files changed
Lines changed: 2922 additions & 135 deletions
File tree
- packages
- app
- e2e/user-story
- src
- components/settings-v2
- hooks
- i18n
- utils
- client/src/generated
- core
- src/config
- test/config
- schema/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
0 commit comments