Lines 2–16 at 318 (were 2–15 at 18)
22// command, run by the same code as the command line and answering with the 33// same text, so the CLI and the tools can't drift apart and an agent learns 44// one set of words. The folder and the token come from where the server runs, 5−// as for the CLI: .avcs/config.json, and AVCS_TOKEN or ~/.avcs/token.
5+// as for the CLI: .avcs/config.json, and ABSO_TOKEN or ~/.abso/token. 7−// claude mcp add avcs -- node <repo>/client/avcs.ts mcp
7+// claude mcp add abso -- abso mcp 99// The protocol is JSON-RPC 2.0, one message per line, with no library: the 1010// 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"; 1314import { clientVersion } from "./client-version.ts"; 1415import { commandTable, main } from "./main.ts"; Lines 35–42 at 318 (were 34–41 at 18)
37− "sync",
38− "publish",
Lines 48–65 at 318 (were 47–55 at 18)
5565const PROTOCOLS = ["2025-06-18", "2025-03-26", "2024-11-05"]; Lines 78–96 at 318 (were 68–82 at 18)
6878 return MCP_COMMANDS.map((command) => { 6979 const def = table[command]!; 7080 const flags = Object.fromEntries( 71− Object.entries(def.flags).map(([flag, kind]) => [
72− flag,
73− kind === "boolean"
74− ? { type: "boolean", description: `--${flag}` }
75− : {
76− type: "string",
77− description: kind === "optional" ? `--${flag} "<value>"; "" gives --${flag} alone` : `--${flag} <value>`,
78− },
79− ]),
81+ // No --token-file: a tool signs in with its folder's key, never this machine's token file. 82+ Object.entries(def.flags) 83+ .filter(([flag]) => flag !== "token-file") 84+ .map(([flag, kind]) => [ 87+ ? { type: "boolean", description: `--${flag}` } 91+ kind === "optional" ? `--${flag} "<value>"; "" gives --${flag} alone` : `--${flag} <value>`, 8296 name: toolName(command), Lines 105–112 at 318 (were 91–97 at 18)
94− description: "The abso folder to run in (default: the folder this server started in).",
109+ "The abso folder to run in: the folder this server started in (the default), or one inside it.", 96111 json: { type: "boolean", description: "Answer with the command's JSON (as --json) instead of its text." }, Lines 117–172 at 318 (were 102–107 at 18)
120+/** A path as it really is (through links), or as given when it doesn't exist. */ 121+function real(path: string): string { 123+ return realpathSync.native(path); 129+/** Whether `path` is `start` or inside it, after links are followed. */ 130+function inside(start: string, path: string): boolean { 131+ const rel = relative(real(start), real(path)); 132+ return rel === "" || (rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel)); 135+/** The tool inputs that name files or folders on this machine to read or write, comma-separated: each is confined like the folder. */ 136+export const FILE_INPUTS = ["attach", "clean", "save-attachments"] as const; 139+ * Where a tool call runs, and what it may read: its folder and 140+ * every file a FILE_INPUTS input names stay inside the folder the server 141+ * started in. A relative path that climbs out (..), an absolute one elsewhere, 142+ * or a link out is refused, so no tool reads a file outside the project. 143+ * Answers the folder, or why the call is refused. 145+export function confineCall( 147+ input: Readonly<Record<string, unknown>>, 148+): { folder: string } | { refused: string } { 149+ const named = typeof input.folder === "string" && input.folder !== "" ? input.folder : undefined; 150+ const folder = named === undefined ? start : resolve(start, named); 151+ if (!inside(start, folder)) 153+ refused: `folder ${JSON.stringify(named)} is outside ${start}, the folder this server started in; tools run there or below`, 155+ for (const flag of FILE_INPUTS) { 156+ const value = input[flag]; 157+ if (typeof value !== "string") continue; 158+ for (const p of value 160+ .map((x) => x.trim()) 161+ .filter((x) => x !== "")) 162+ if (!inside(start, resolve(folder, p))) 164+ refused: `--${flag} ${p} is outside ${start}, the folder this server started in; a tool reads and writes files only there or below`, 105170/** The command line a tool call stands for: flags as --name=value, then the words after --. */ 106171export function argvFor(command: string, input: Readonly<Record<string, unknown>>): string[] { 107172 const def = commandTable()[command]!; Lines 222–230 at 318 (were 157–163 at 18)
157222 const command = MCP_COMMANDS.find((c) => toolName(c) === name); 158223 if (command === undefined) return fail(id, -32602, `no tool ${JSON.stringify(name)}; tools/list names them`); 159224 const args = (params.arguments ?? {}) as Record<string, unknown>; 160− const folder = typeof args.folder === "string" && args.folder !== "" ? resolve(cwd, args.folder) : cwd;
225+ const where = confineCall(cwd, args); 226+ if ("refused" in where) return reply(id, { content: [{ type: "text", text: where.refused }], isError: true }); 227+ const folder = where.folder; 161228 let streamed = ""; 162229 const result = await main(argvFor(command, args), {