Verified 2026-08-05 against VS Code 1.132.0 (commit df53daab), connecting to lorepack mcp
speaking MCP 2026-07-28.
lorepack dev ./project-context
lorepack connect vscodeThe first command builds and serves; the second configures the workspace and then proves the server answers.
lorepack connect verifies the intended active build and reads a known cited source before
reporting success. Wrong builds and unreadable context fail verification; JSON output carries
the build ID and citation without source text. Client trust remains a separate step.
See the shared verification contract for bounded reads, startup
ordering and the automated verification date. External-client version records here are unchanged.
| Scope | File | When |
|---|---|---|
| workspace (default) | <project>/.vscode/mcp.json |
lorepack connect vscode |
| user | ~/.config/Code/User/mcp.json, and the platform equivalent |
--scope user, never implied |
The default is the workspace, and connect all never writes the user profile. A profile
entry configures every window on the machine to read one project's documents, which for a
private corpus is worse than merely surprising.
.vscode/mcp.json is shareable, source-controlled configuration. People commit it
deliberately, and the plan says so before writing, so committing it is a choice you make
knowingly rather than one you discover in a diff.
The top-level key is servers, not the Claude-style mcpServers. The wrong key produces
a file VS Code ignores without a word, which looks exactly like a connect that worked.
--ensure-current means a fresh clone works without a prior lorepack build.
VS Code's schema gives sandboxEnabled default: false, so leaving it out is exactly the
unsandboxed behaviour. Turning it on is not claimed as supported, because it cannot be verified
without driving the real sandbox from inside the editor, and --ensure-current writes .lore/
on first run, which is precisely what a filesystem sandbox would stop. Shipping it on an
untested guess would turn a working connect into a server that starts and then fails.
Architecture §6.6 step 5 prefers a client's own CLI when it can express the chosen scope
safely. Measured against 1.132.0, code --add-mcp cannot, twice over:
- Its own help says it "Adds a Model Context Protocol server definition to the user
profile". There is no workspace option, and it resolves the profile from the real home even
when
$HOMEpoints elsewhere. - Given a hand-written
mcp.jsonwith comments, it deleted every comment, reformatted the whole document, and added"type": "stdio"to a server that was configured by hand.
Writing the file ourselves is only worth doing because it does better than that. code --version is the only invocation this adapter makes.
.vscode/mcp.json is JSON with comments: VS Code's own schema for it declares
allowComments: true and allowTrailingCommas: true, so // the args took ages to get right
is a legal line and JSON.parse would refuse the whole file over it.
- Edits are minimal. Only the Lorepack entry changes. Comments, unrelated servers, other settings, your indentation and your line endings survive as they were.
- Nothing is written until you have agreed to it.
connectplans every client first, prints the plan, and asksApply these changes? [y/N]. Without a terminal, in a script or CI job, it prints the plan, writes nothing and exits 1 unless you pass--yes.--dry-runprints the plan and touches nothing. - The file is backed up first, with a timestamp, beside the original.
- Writes are atomic. An interrupted run leaves the old file, not half of a new one.
- Permissions are kept. The rewritten file and its backup keep the original's mode, so a 0600 file holding tokens stays 0600. A user-scope file Lorepack creates is 0600.
- Links are never followed out of a project. If a project configuration file, or any
directory on the way to it, is a symbolic link,
connectanddisconnectrefuse withLORE_E_PATH_ESCAPEand read, back up and write nothing: a repository could otherwise link it to your home configuration and have your tokens copied into the project. A user-scope file that is a link (a dotfile manager's) is edited at its target, and the link stays. - A file that will not parse is refused, not overwritten. So is one whose
serversis not an object. Every edit is parsed again before it is written, and refused if anything but the Lorepack entry would change. - The ownership comment marks what we created, so
lorepack disconnectremoves exactly that. A server calledlorepackthat you wrote yourself is left alone. It is a comment rather than a key because VS Code's schema for a server isadditionalProperties: false, so an extra key would put a permanent error squiggle in a file we wrote.
Connect followed by disconnect restores the exact original bytes for existing inline neighbours,
trailing comments and empty servers objects, including BOM and CRLF. New ownership comments
include the logical entryPath, so an inline neighbour cannot acquire Lorepack ownership.
Existing property-local markers remain readable. Configuration containers created for the entry
remain empty after disconnect, as before; disconnect removes the server entry.
Automated byte/semantic round trips were driven on 2026-10-16 using Node 24.21.0 on macOS arm64, the actual built CLI and an isolated VS Code version stand-in. This verifies file edits and the real MCP probe, not a new real-client trust-dialog verification. See the recorded tests below.
lorepack connect spawns the server exactly as VS Code will, calls server/discover and
tools/list, and reports which step failed if one does. When one does, connect exits 3, so a script can
tell.
VS Code then asks you to confirm you trust the server the first time it starts, and chat runs without these tools until you do. That is a step you take, not a bug, so it is printed rather than left to surprise you. VS Code cannot be asked from outside the editor what it has loaded, so the connect output names the step instead of guessing:
Verified: Answered with 7 tools on protocol 2026-07-28. VS Code will ask you to confirm you
trust this server the first time it starts; run `MCP: List Servers` from the Command Palette
to see it.
MCP: List Servers, MCP: Add Server and MCP: Open User Configuration in the Command
Palette are the client-side equivalents.
Trust dialogs cannot be automated, so the flow was driven against the real binary. This is the record (working agreement §7).
| Date | Client | What was driven, and what it proved |
|---|---|---|
| 2026-08-05 | VS Code 1.132.0 | A workspace with a hand-written .vscode/mcp.json holding two comments and another MCP server. lorepack connect vscode backed the file up, added the entry, and kept both comments and left the other server without the "type" key code --add-mcp injects. It reported Verified: Answered with 7 tools on protocol 2026-07-28 plus the trust step. Re-running said Update and left exactly one entry and one ownership comment. VS Code's own CLI then read the file we wrote and extended it, returning ['lorepack', 'notes', 'probe'] with our entry intact. lorepack disconnect vscode left the file byte for byte identical to the original. |
lorepack disconnect vscodeRemoves the Lorepack entry and leaves every other server, comment and setting where they were.
A file saved with a byte order mark, which Windows editors write, keeps it. In the user
profile's mcp.json, which every window shares, disconnect --scope user removes only the
entry this project created and names the project that owns any other.
lorepack connect vscode --snippetprints the exact JSON to paste and changes nothing.
VS Code 1.132.0 commit df53daab, MCP protocol 2026-07-28, verified 2026-08-05.
packages/connect-clients/test/jsonc-config.test.ts compares independent parsed values and
exact buffers for inline neighbours, trailing comments, empty objects, BOM and CRLF. It also
covers multiple managed paths, existing markers, unrelated edits and refused ownership.
packages/cli/test/connect.e2e.test.ts drives the built CLI through actual connect and disconnect
against temporary config files, with isolated client detection and the real built MCP server.
The whole connection suite still covers permission, symlink, ownership and consent behavior.
{ "servers": { // Managed by Lorepack. `lorepack disconnect vscode` removes exactly this entry. // x-lorepack {"projectRoot":"/absolute/path","entryPath":["servers","lorepack"],"createdAt":"..."} "lorepack": { "type": "stdio", "command": "lorepack", "args": ["mcp", "--project", "/absolute/path", "--ensure-current"] } } }