MCP tools stay inside the folder the server started in. A tool call's folder, and each file the issue tool's attach names, must be that folder or inside it. A relative path that climbs out (..), an absolute path elsewhere, or a link that leads out is refused with a plain message, so no tool reads a file outside the project. The text flags' -file twins were never served as tool inputs, and a test now keeps it that way. Version 21 of shared· pinch· Oct 9 (2026-10-09 06:47 UTC) · Not checked
Also: abso login, box and logout outside an abso folder act on https://api.abso.dev when --server isn't given, so a fresh machine can run abso login bare. Inside a folder they still use the folder's server.
Version 20 · Files at version 21
3 files, 108 lines added, 9 removed.
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -37,6 +37,7 @@
38 38 } from "./commands.ts"; 39 39 import { configPath, findRoot, installKey, readConfig, readToken } from "./config.ts"; 40 + import { TOKEN_SERVERS } from "./core.ts"; 40 41 import { runDraftSync, runLand, runSwitch } from "./drafts.ts"; 41 42 import { runExport } from "./export.ts"; 42 43 import { runBlame, runWhere, runWho, runWhy } from "./history.ts"; @@ -56,12 +57,12 @@
56 57 readonly run: (args: Parsed, env: Env) => Promise<Output>; 59 − /** The server login, box and logout act on: --server, or the folder's. */
60 − function boxServer(args: Parsed, env: Env): string {
60 + /** The server login, box and logout act on: --server, the folder's, or outside a folder abso.dev's (TOKEN_SERVERS[0]). */ 61 + export function boxServer(args: Parsed, env: Pick<Env, "cwd">): string { 61 62 const flag = str(args, "server"); 62 63 if (flag) return flag; 63 64 const root = findRoot(env.cwd); 64 − if (!root) throw new UsageError("give --server <url>, or run this inside an agent's folder");
65 + if (!root) return TOKEN_SERVERS[0]!; 65 66 return (JSON.parse(readFileSync(configPath(root), "utf8")) as { server: string }).server; @@ -166,7 +167,7 @@
166 167 flags: { server: "string" }, 167 168 usage: "abso login [--server <url>]", 169 − "Sign this box in once (abso issue 108): it shows a code and a link, and waits while a person approves the code on the website, choosing the projects, the highest role and how many agents. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. Without --server, the folder's server.",
170 + "Sign this box in once (abso issue 108): it shows a code and a link, and waits while a person approves the code on the website, choosing the projects, the highest role and how many agents. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. Without --server, the folder's server, or https://api.abso.dev outside a folder.", 170 171 run: async (args, env) => { 171 172 const server = boxServer(args, env); 172 173 const record = await login(server, { say: (line) => process.stderr.write(`${line}\n`) }); --- a/client/src/mcp.ts
+++ b/client/src/mcp.ts
@@ -9,7 +9,8 @@
9 9 // The protocol is JSON-RPC 2.0, one message per line, with no library: the 10 10 // client uses nothing outside Node. 12 − import { resolve } from "node:path";
12 + import { realpathSync } from "node:fs"; 13 + import { isAbsolute, relative, resolve, sep } from "node:path"; 13 14 import { clientVersion } from "./client-version.ts"; 14 15 import { commandTable, main } from "./main.ts"; @@ -92,7 +93,8 @@
95 − description: "The abso folder to run in (default: the folder this server started in).",
97 + "The abso folder to run in: the folder this server started in (the default), or one inside it.", 97 99 json: { type: "boolean", description: "Answer with the command's JSON (as --json) instead of its text." }, @@ -103,6 +105,50 @@
108 + /** A path as it really is (through links), or as given when it doesn't exist. */ 109 + function real(path: string): string { 111 + return realpathSync.native(path); 117 + /** Whether `path` is `start` or inside it, after links are followed. */ 118 + function inside(start: string, path: string): boolean { 119 + const rel = relative(real(start), real(path)); 120 + return rel === "" || (rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel)); 124 + * Where a tool call runs, and what it may read (Security on 233): its folder and 125 + * every --attach file stay inside the folder the server started in. A relative 126 + * path that climbs out (..), an absolute one elsewhere, or a link out is 127 + * refused, so no tool reads a file outside the project. Answers the folder, or 128 + * why the call is refused. 130 + export function confineCall( 132 + input: Readonly<Record<string, unknown>>, 133 + ): { folder: string } | { refused: string } { 134 + const named = typeof input.folder === "string" && input.folder !== "" ? input.folder : undefined; 135 + const folder = named === undefined ? start : resolve(start, named); 136 + if (!inside(start, folder)) 138 + refused: `folder ${JSON.stringify(named)} is outside ${start}, the folder this server started in; tools run there or below`, 140 + if (typeof input.attach === "string") 141 + for (const p of input.attach 143 + .map((x) => x.trim()) 144 + .filter((x) => x !== "")) 145 + if (!inside(start, resolve(folder, p))) 147 + refused: `--attach ${p} is outside ${start}, the folder this server started in; a tool attaches files from there or below`, 106 152 /** The command line a tool call stands for: flags as --name=value, then the words after --. */ 107 153 export function argvFor(command: string, input: Readonly<Record<string, unknown>>): string[] { 108 154 const def = commandTable()[command]!; @@ -158,7 +204,9 @@
158 204 const command = MCP_COMMANDS.find((c) => toolName(c) === name); 159 205 if (command === undefined) return fail(id, -32602, `no tool ${JSON.stringify(name)}; tools/list names them`); 160 206 const args = (params.arguments ?? {}) as Record<string, unknown>; 161 − const folder = typeof args.folder === "string" && args.folder !== "" ? resolve(cwd, args.folder) : cwd;
207 + const where = confineCall(cwd, args); 208 + if ("refused" in where) return reply(id, { content: [{ type: "text", text: where.refused }], isError: true }); 209 + const folder = where.folder; 162 210 let streamed = ""; 163 211 const result = await main(argvFor(command, args), { --- a/client/test/client.test.ts
+++ b/client/test/client.test.ts
@@ -48,8 +48,8 @@
48 48 import { absolute, writeFileAtomic } from "../src/folder.ts"; 49 49 import { runHook } from "../src/hook.ts"; 50 50 import { tryFolderLock } from "../src/lock.ts"; 51 − import { commandTable, main } from "../src/main.ts";
52 − import { argvFor } from "../src/mcp.ts";
51 + import { boxServer, commandTable, main } from "../src/main.ts"; 52 + import { argvFor, confineCall, mcpTools } from "../src/mcp.ts"; 53 53 import { pulledText } from "../src/queue.ts"; 54 54 import { noteText, titleLine } from "../src/review.ts"; 55 55 import { screenAnswer, throughLink, unsafeLink, unsafePath } from "../src/safety.ts"; @@ -2641,6 +2641,56 @@
2641 2641 assert.deepEqual(parsed.positionals, ["--server=x"]); 2644 + it("keeps a tool call's folder and --attach files inside the folder the server started in (Security on 233)", async () => { 2645 + const { folders } = await project({ "a.txt": "one\n" }, "alice"); 2646 + const start = folders.alice!; 2647 + const refused = (input: Record<string, unknown>) => { 2648 + const r = confineCall(start, input); 2649 + return "refused" in r ? r.refused : ""; 2651 + assert.deepEqual(confineCall(start, {}), { folder: start }); 2652 + assert.deepEqual(confineCall(start, { folder: "sub" }), { folder: join(start, "sub") }); 2653 + assert.deepEqual(confineCall(start, { attach: "a.txt, sub/b.png" }), { folder: start }); 2654 + assert.match(refused({ folder: ".." }), /^folder "\.\." is outside .*, the folder this server started in/); 2655 + assert.match(refused({ folder: dirname(start) }), /is outside/); 2656 + assert.match(refused({ folder: "sub/../.." }), /is outside/); 2657 + assert.match(refused({ attach: "a.txt,../x.png" }), /^--attach \.\.\/x\.png is outside/); 2658 + assert.match(refused({ attach: join(tmpdir(), "x.png") }), /is outside/); 2659 + assert.match(refused({ folder: "sub", attach: "../../x.png" }), /is outside/); 2660 + assert.deepEqual(confineCall(start, { folder: "sub", attach: "../a.txt" }), { folder: join(start, "sub") }); 2661 + const server = mcp(start); 2663 + const up = await server.call("tools/call", { name: "status", arguments: { folder: ".." } }); 2664 + assert.equal(up.result.isError, true); 2665 + assert.match(up.result.content[0].text, /is outside/); 2666 + const attach = await server.call("tools/call", { 2668 + arguments: { args: ["1"], comment: "see", attach: "../../secret.png" }, 2670 + assert.equal(attach.result.isError, true); 2671 + assert.match(attach.result.content[0].text, /^--attach \.\.\/\.\.\/secret\.png is outside/); 2677 + it("serves no -file twin, so no tool reads its text from a file", () => { 2678 + for (const tool of mcpTools()) 2679 + for (const key of Object.keys(tool.inputSchema.properties as object)) 2680 + assert.ok(!key.endsWith("-file") && key !== "file", `${tool.name} takes ${key}`); 2683 + it("abso login, box and logout outside a folder act on https://api.abso.dev", () => { 2684 + const outside = mkdtempSync(join(tmpdir(), "abso-login-")); 2686 + assert.equal(boxServer(parseArgs("login", [], { server: "string" }), { cwd: outside }), "https://api.abso.dev"); 2687 + const given = parseArgs("login", ["--server", "https://example.test"], { server: "string" }); 2688 + assert.equal(boxServer(given, { cwd: outside }), "https://example.test"); 2690 + rmSync(outside, { recursive: true, force: true }); 2644 2694 it("publish --done takes the start note back once it is published", async () => { 2645 2695 const { folders } = await project({ "a.txt": "one\n" }, "alice"); 2646 2696 assert.equal((await avcs(folders.alice!, "start", "Two", "a.txt")).exit, 0);