Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
blame on this site's /mcp
CLI
abso blame client/src/mcp.ts --json
JSON
/christopher/abso-core/blame/client/src/mcp.ts?format=json
277 linesFirst import 69% · pinch 22% · readspeed 5% · review 1% · speed 1% · groups 1% · Last change readspeed in version 271,

277 lines from 16 changes in 16 versions.

init0Start the project1// abso mcp: an MCP server on stdin and stdout (#42, #44). Each tool is one avcs
2// command, run by the same code as the command line and answering with the
3// same text, so the CLI and the tools can't drift apart and an agent learns
4// one set of words. The folder and the token come from where the server runs,
review27Client: ABSO_ environment names (AVCS_ still read), .absoignore (.avcsignore still read), .abso-export.json, shot files; READMEs say abso (abso 224)Compare5// as for the CLI: .avcs/config.json, and ABSO_TOKEN or ~/.abso/token.
init0Start the project6//
speed71Help text: abso mcp's line gives the install command for an npm install (claude mcp add abso -- abso mcp, or cmd /c abso mcp on Windows), the unknown-command answer lists mcp, and the help no longer cites internal tracker numbers.Compare7// claude mcp add abso -- abso mcp
init0Start the project8//
9// The protocol is JSON-RPC 2.0, one message per line, with no library: the
10// client uses nothing outside Node.
pinch21MCP 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. 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.Compare12import { realpathSync } from "node:fs";
13import { isAbsolute, relative, resolve, sep } from "node:path";
init0Start the project14import { clientVersion } from "./client-version.ts";
15import { commandTable, main } from "./main.ts";
17/**
18 * The commands served as tools: reading, and the writes an agent makes every
19 * day. The box commands (run, shot, bisect, prep, logs, fetch) stream for
20 * minutes and stay in the shell, as do setting a folder up (init, join) and
21 * the ones that rewrite history or move between drafts.
22 */
23export const MCP_COMMANDS = [
24 "status",
25 "log",
26 "show",
27 "diff",
28 "files",
29 "who",
30 "where",
31 "blame",
32 "why",
33 "ci",
34 "news",
35 "announce",
36 "start",
37 "record",
rename100abso publish is now abso push, abso sync is now abso pull (abso 427) Commands, help, flags, messages, MCP tool names and descriptions, hook text, README, SKILL.md and tests say push and pull; "shared" stays the noun ("Pushed version N"). No aliases, no notices. A queued push that was "pulled" is now "turned back", so pull means one thing. push -f/--force/-u/--all/--tags and pull --rebase/--ff-only/--squash refuse with one plain line naming the abso way; push and pull take no remote or branch. Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare38 "pull",
39 "push",
init0Start the project40 "unqueue",
41 "restore",
42 "settle",
43 "check-ignore",
44 "labels",
45 "mv",
46 "review",
47 "note",
48 "notes",
49 "issues",
50 "issue",
devops20Add abso search: find a project's issues by words or meaning `abso search "<words>" [--limit <N>]` lists the project's issues that match, best first, and is served as an MCP tool as well. - Each hit shows the issue, then where it matched: the title, the description, a comment, or "by meaning". - "#N" or "N" puts issue N first. - Where the server also searches by meaning, an issue worded unlike the search still turns up; the hit says so.Compare51 "search",
init0Start the project52 "ask",
53 "waiting",
54 "answer",
pinch53abso ack <ask> ["note"]: the one asked says they have an ask and will answer later. The ask stays open and keeps blocking; abso issue shows it as acknowledged with the note, and the asker hears it. The Ask wire type gains ack, the API client gains ack(), and the skill mentions the command.Compare55 "ack",
pinch72Asks become threads: abso reply <ask> "..." adds to an ask from either side, open or answered, and --question hands the turn to the asker until they reply. abso ask <N> shows one ask with its whole thread and whose turn it is; abso waiting --asked lists the asks you sent. An ack's note is the thread's first reply. reply is an MCP tool too. Needs an Issues server with the reply, ask and asked routes.Compare56 "reply",
groups256groups: abso groups and abso group, for a project's named groups of agents and people with one shared history. abso group <name> reads its settings, members and history (newest first; --before, --limit, --kind). --post adds a message, with news for every other member unless --news names some, --except leaves some out, or --news none keeps it in the history only. --join, --leave, --add, --remove, --rename, --private on|off and --joinable on|off change it; abso group new makes one. A retried post never posts twice (the Idempotency-Key every POST sends). Both are MCP tools; a visitor folder refuses them. Tests: client/test/group-commands.test.ts, visitor.test.ts.Compare57 "groups",
58 "group",
pinch34Client: abso orgs and abso org <name>, reading as the person who approved this box's sign-in (abso login): your organizations and roles, invitations waiting for you, and an org's projects, people (by name, never id), settings and open invites. Changes (--invite, --role, --remove, --leave, --members, --projects-by), abso org new and abso init --org are made on the website for now; each says where and sends nothing. One change at a time. MCP serves orgs and org. Client tests 283/283, tsc and biome clean.Compare59 "orgs",
60 "org",
speed76abso whoami and abso doctor, and plainer errors. - abso whoami: this box's sign-in as the server sees it (a revoked one shows as revoked), its projects, roles and expiry, and this folder's project, agent and kind of key. It names who approved the box when the server says. - abso doctor: one line per check, ok, fail or skip: Node's version (20 or later for the npm package, 24 for a checkout), that the server answers, this box's sign-in (present, unexpired, accepted), and this folder's key against its project (a GET of the project's head, which the server answers only after checking the key). A failed check gives the next step, and the exit is 1. - Neither prints a credential. Both are MCP tools too. - The commonest failures now say what to do: a 401 with no credential reads 'You're not signed in. Run abso login, then abso join <project>.'; a refused key points to abso doctor; a server that can't be reached reads 'Can't reach <server>...' with the next step, unless the message already gives one; and outside a folder, 'You're not in an abso folder' says how to make one.Compare61 "whoami",
62 "doctor",
init0Start the project63] as const;
65const PROTOCOLS = ["2025-06-18", "2025-03-26", "2024-11-05"];
67interface Tool {
68 readonly name: string;
69 readonly description: string;
70 readonly inputSchema: Record<string, unknown>;
73/** A tool's name: the command, with _ for - (check-ignore is check_ignore). */
74const toolName = (command: string): string => command.replace(/-/g, "_");
76export function mcpTools(): Tool[] {
77 const table = commandTable();
78 return MCP_COMMANDS.map((command) => {
79 const def = table[command]!;
80 const flags = Object.fromEntries(
readspeed271No command picks up a credential from a file nobody asked for Follows "abso init signs in with the box sign-in" (issue 25), and applies it to every command. - A folder with a key signs in with that key and nothing else: not ABSO_TOKEN, not ~/.abso/token, even when the server refuses the key. A key file that can't be read is now an error ("abso key install puts a key back") instead of a quiet fall back to another credential. - With no key, a command signs in with ABSO_TOKEN (or a pipeline run's ABSO_KEY_FILE). This machine's ~/.abso/token is used only by a command given --token-file, which every command that talks to a server now takes. Without it, a refused call says "You're not signed in. Run abso login, then abso join <project>. ~/.abso/token is used only with --token-file." abso doctor says the same about a token file it finds unused. The edit hook and MCP tools never read it. - The admin token (ABSO_ADMIN_TOKEN, or ~/.abso/admin-token) is read only by abso key and abso flag. Each says "Using the admin token, from ..." every time it uses it. A test holds that no other module reads the file. What changes for you: a folder with no key that relied on ~/.abso/token needs --token-file on each command, or ABSO_TOKEN, or a key (abso login, then abso join). Tests: client/test/token-file.test.ts (3, new); client/test/client.test.ts's MCP check covers --token-file. All client tests pass (443).Compare81 // 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]) => [
85 flag,
86 kind === "boolean"
87 ? { type: "boolean", description: `--${flag}` }
88 : {
89 type: "string",
90 description:
91 kind === "optional" ? `--${flag} "<value>"; "" gives --${flag} alone` : `--${flag} <value>`,
92 },
93 ]),
init0Start the project94 );
95 return {
96 name: toolName(command),
97 description: `${def.usage}\n${def.about}`,
98 inputSchema: {
99 type: "object",
100 properties: {
101 args: {
102 type: "array",
103 items: { type: "string" },
104 description: "The words after the command, as on the command line: files, versions, text.",
105 },
106 folder: {
107 type: "string",
pinch21MCP 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. 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.Compare108 description:
109 "The abso folder to run in: the folder this server started in (the default), or one inside it.",
init0Start the project110 },
111 json: { type: "boolean", description: "Answer with the command's JSON (as --json) instead of its text." },
112 ...flags,
113 },
114 additionalProperties: false,
115 },
116 };
117 });
pinch21MCP 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. 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.Compare120/** A path as it really is (through links), or as given when it doesn't exist. */
121function real(path: string): string {
122 try {
123 return realpathSync.native(path);
124 } catch {
125 return path;
126 }
129/** Whether `path` is `start` or inside it, after links are followed. */
130function inside(start: string, path: string): boolean {
131 const rel = relative(real(start), real(path));
132 return rel === "" || (rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));
pinch29Client: abso issue N --save-attachments <dir> saves each attachment on an issue and its comments once (an SVG's own file beside its drawing), outside the abso folder unless the place is ignored; MCP confines the folder like attach. abso export now stamps its folder with .abso-export, one line of JSON in a file with no extension, so the exported project's own formatter and linter pass it by; a folder stamped .abso-export.json or .avcs-export.json still counts as an export.Compare135/** The tool inputs that name files or folders on this machine to read or write, comma-separated: each is confined like the folder. */
136export const FILE_INPUTS = ["attach", "clean", "save-attachments"] as const;
pinch23abso issue <N> --copy-to <project>: copy an issue into another project, with its comments, answered asks and labels, each keeping its author and time. The Issues server reads the source issue itself; the client sends only which issue, and any cleaned texts. - --dry-run shows what the copy would make (title, how many comments and asks, which were edited, labels) and what's left behind. It writes nothing. - --clean <file> gives cleaned texts by source id, as JSON: {title, description, comments: [{id, text}], asks: [{id, question, answer}]}. A comment left out of a given list isn't copied. - --copy-to goes alone, so a copy is never half an edit. Copying into the project the issue is already in is refused before any call. - When a live server refuses the copy (copying out of a project there takes an owner of it), the message says --dry-run still works. - The MCP issue tool's clean input is a file too, so it's confined to the server's start folder like attach. Tests: client/test/issues.test.ts, against a stand-in Issues server. The run --parallel test that sometimes times out under a full run passed when rerun.Compare137
pinch21MCP 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. 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.Compare138/**
pinch22abso skill install: the abso skill for Claude Code now comes with the client. It writes ~/.claude/skills/abso/SKILL.md (--dir names another skills folder), says when the copy there is already current, and touches nothing else in the folder. abso skill show prints it. The skill tells an agent how to work in an abso folder (sync, start, publish, settle, issues and asks) and what never to share. It's instructions only: it names no tools to allow, and installing it changes no settings. Its source is client/skills/abso/SKILL.md; the client carries the same text, and a test keeps the two equal, so the one-file client includes it. The client README gains a section on it, and its MCP section now says a tool call stays inside the folder the server started in.Compare139 * Where a tool call runs, and what it may read: its folder and
pinch23abso issue <N> --copy-to <project>: copy an issue into another project, with its comments, answered asks and labels, each keeping its author and time. The Issues server reads the source issue itself; the client sends only which issue, and any cleaned texts. - --dry-run shows what the copy would make (title, how many comments and asks, which were edited, labels) and what's left behind. It writes nothing. - --clean <file> gives cleaned texts by source id, as JSON: {title, description, comments: [{id, text}], asks: [{id, question, answer}]}. A comment left out of a given list isn't copied. - --copy-to goes alone, so a copy is never half an edit. Copying into the project the issue is already in is refused before any call. - When a live server refuses the copy (copying out of a project there takes an owner of it), the message says --dry-run still works. - The MCP issue tool's clean input is a file too, so it's confined to the server's start folder like attach. Tests: client/test/issues.test.ts, against a stand-in Issues server. The run --parallel test that sometimes times out under a full run passed when rerun.Compare140 * 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.
pinch21MCP 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. 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.Compare144 */
145export function confineCall(
146 start: string,
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))
152 return {
153 refused: `folder ${JSON.stringify(named)} is outside ${start}, the folder this server started in; tools run there or below`,
154 };
pinch23abso issue <N> --copy-to <project>: copy an issue into another project, with its comments, answered asks and labels, each keeping its author and time. The Issues server reads the source issue itself; the client sends only which issue, and any cleaned texts. - --dry-run shows what the copy would make (title, how many comments and asks, which were edited, labels) and what's left behind. It writes nothing. - --clean <file> gives cleaned texts by source id, as JSON: {title, description, comments: [{id, text}], asks: [{id, question, answer}]}. A comment left out of a given list isn't copied. - --copy-to goes alone, so a copy is never half an edit. Copying into the project the issue is already in is refused before any call. - When a live server refuses the copy (copying out of a project there takes an owner of it), the message says --dry-run still works. - The MCP issue tool's clean input is a file too, so it's confined to the server's start folder like attach. Tests: client/test/issues.test.ts, against a stand-in Issues server. The run --parallel test that sometimes times out under a full run passed when rerun.Compare155 for (const flag of FILE_INPUTS) {
156 const value = input[flag];
157 if (typeof value !== "string") continue;
158 for (const p of value
pinch21MCP 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. 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.Compare159 .split(",")
160 .map((x) => x.trim())
161 .filter((x) => x !== ""))
162 if (!inside(start, resolve(folder, p)))
163 return {
pinch29Client: abso issue N --save-attachments <dir> saves each attachment on an issue and its comments once (an SVG's own file beside its drawing), outside the abso folder unless the place is ignored; MCP confines the folder like attach. abso export now stamps its folder with .abso-export, one line of JSON in a file with no extension, so the exported project's own formatter and linter pass it by; a folder stamped .abso-export.json or .avcs-export.json still counts as an export.Compare164 refused: `--${flag} ${p} is outside ${start}, the folder this server started in; a tool reads and writes files only there or below`,
pinch21MCP 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. 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.Compare165 };
pinch23abso issue <N> --copy-to <project>: copy an issue into another project, with its comments, answered asks and labels, each keeping its author and time. The Issues server reads the source issue itself; the client sends only which issue, and any cleaned texts. - --dry-run shows what the copy would make (title, how many comments and asks, which were edited, labels) and what's left behind. It writes nothing. - --clean <file> gives cleaned texts by source id, as JSON: {title, description, comments: [{id, text}], asks: [{id, question, answer}]}. A comment left out of a given list isn't copied. - --copy-to goes alone, so a copy is never half an edit. Copying into the project the issue is already in is refused before any call. - When a live server refuses the copy (copying out of a project there takes an owner of it), the message says --dry-run still works. - The MCP issue tool's clean input is a file too, so it's confined to the server's start folder like attach. Tests: client/test/issues.test.ts, against a stand-in Issues server. The run --parallel test that sometimes times out under a full run passed when rerun.Compare166 }
pinch21MCP 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. 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.Compare167 return { folder };
init0Start the project170/** The command line a tool call stands for: flags as --name=value, then the words after --. */
171export function argvFor(command: string, input: Readonly<Record<string, unknown>>): string[] {
172 const def = commandTable()[command]!;
173 const argv = [command];
174 for (const [flag, kind] of Object.entries(def.flags)) {
175 const value = input[flag];
176 if (value === undefined || value === null || value === false) continue;
177 if (kind === "boolean") argv.push(`--${flag}`);
178 else argv.push(`--${flag}=${String(value)}`);
179 }
180 const words = Array.isArray(input.args) ? input.args.map(String) : [];
181 if (words.length > 0) argv.push("--", ...words);
182 return argv;
185type Message = { jsonrpc?: string; id?: string | number | null; method?: string; params?: Record<string, unknown> };
187/**
188 * Serve MCP on `lines` (each one JSON-RPC message), answering through `send`.
189 * Calls run one at a time, since a command's news is gathered process-wide.
190 */
191export async function serveMcp(
192 input: AsyncIterable<Buffer | string>,
193 send: (line: string) => void,
194 cwd: string,
195 env: Readonly<Record<string, string | undefined>>,
196): Promise<void> {
197 let queue: Promise<void> = Promise.resolve();
198 const reply = (id: Message["id"], result: unknown) => send(JSON.stringify({ jsonrpc: "2.0", id, result }));
199 const fail = (id: Message["id"], code: number, message: string) =>
200 send(JSON.stringify({ jsonrpc: "2.0", id: id ?? null, error: { code, message } }));
202 const handle = async (msg: Message): Promise<void> => {
203 const { id, method, params = {} } = msg;
204 const isRequest = id !== undefined && id !== null;
205 switch (method) {
206 case "initialize": {
207 const asked = typeof params.protocolVersion === "string" ? params.protocolVersion : "";
208 return reply(id, {
209 protocolVersion: PROTOCOLS.includes(asked) ? asked : PROTOCOLS[0],
210 capabilities: { tools: {} },
review16The client says abso, not avcs, in everything a person reads: the hints after an issue view and abso issue new, the help for issue, issues, ask, answer and waiting, the 'abso:' prefix on notices from run, publish --check, the queue and serve, the 'News from abso' header, the MCP server's name and the claude mcp add example, and the view mod's status line. Only printed words changed: file and folder names (avcs.json, .avcs/, ~/.avcs/token), environment variables and wire headers are as they were, and the tests were updated to the new words (704 pass, biome ci clean).Compare211 serverInfo: { name: "abso", version: clientVersion() },
init0Start the project212 instructions:
review16The client says abso, not avcs, in everything a person reads: the hints after an issue view and abso issue new, the help for issue, issues, ask, answer and waiting, the 'abso:' prefix on notices from run, publish --check, the queue and serve, the 'News from abso' header, the MCP server's name and the claude mcp add example, and the view mod's status line. Only printed words changed: file and folder names (avcs.json, .avcs/, ~/.avcs/token), environment variables and wire headers are as they were, and the tests were updated to the new words (704 pass, biome ci clean).Compare213 "abso, the agent-first version control client. Each tool is the abso command of the same name and answers with the command line's text. Box runs (abso run, shot, bisect) stay in the shell.",
init0Start the project214 });
215 }
216 case "ping":
217 return reply(id, {});
218 case "tools/list":
219 return reply(id, { tools: mcpTools() });
220 case "tools/call": {
221 const name = typeof params.name === "string" ? params.name : "";
222 const command = MCP_COMMANDS.find((c) => toolName(c) === name);
223 if (command === undefined) return fail(id, -32602, `no tool ${JSON.stringify(name)}; tools/list names them`);
224 const args = (params.arguments ?? {}) as Record<string, unknown>;
pinch21MCP 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. 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.Compare225 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;
init0Start the project228 let streamed = "";
229 const result = await main(argvFor(command, args), {
230 cwd: folder,
231 env,
232 write: (t) => (streamed += t),
233 writeErr: (t) => (streamed += t),
234 });
235 // Text only: Claude Code shows the model structuredContent in place of the text when both are there,
236 // and the point is the command line's words. json: true answers with the JSON instead.
237 const text =
238 args.json === true && result.data
239 ? JSON.stringify({ ...result.data, exit: result.exit }, null, 2)
240 : [streamed, result.stdout, result.stderr]
241 .map((t) => t.replace(/\n+$/, ""))
242 .filter((t) => t !== "")
243 .join("\n");
244 return reply(id, {
245 content: [{ type: "text", text: text === "" ? "(no output)" : text }],
246 // Exit 1 is a failure; 2 (refused) and 3 (still queued) are answers the text explains.
247 isError: result.exit === 1,
248 });
249 }
250 default:
251 // Notifications (no id) need no answer; an unknown request does.
252 if (isRequest) fail(id, -32601, `abso mcp doesn't know ${JSON.stringify(method)}`);
253 }
254 };
256 let buffer = "";
257 for await (const chunk of input) {
258 buffer += typeof chunk === "string" ? chunk : chunk.toString("utf8");
259 let nl: number;
260 while ((nl = buffer.indexOf("\n")) >= 0) {
261 const line = buffer.slice(0, nl).trim();
262 buffer = buffer.slice(nl + 1);
263 if (line === "") continue;
264 let msg: Message;
265 try {
266 msg = JSON.parse(line) as Message;
267 } catch {
268 fail(null, -32700, "not JSON");
269 continue;
270 }
271 queue = queue
272 .then(() => handle(msg))
273 .catch((e: unknown) => fail(msg.id, -32603, e instanceof Error ? e.message : String(e)));
274 }
275 }
276 await queue;