Acme
MCP Server

Code Mode

Run JavaScript that combines multiple application tool calls in one request.

Code Mode lets an MCP client combine several application tool calls in a single JavaScript program. The server executes the program inside a sandboxed QuickJS runtime and invokes the authorized API procedures in-process.

Write a program

Provide an async JavaScript function. Await tool calls and return a JSON-compatible value.

For example, the included notification tools can be combined like this:

async () => {
	const notifications = await tools.list_notifications({ take: 20 });
	const unread = notifications.filter((notification) => !notification.read);
	if (unread.length === 0) return { count: 0 };
	return await tools.mark_notifications_read({
		ids: unread.map((notification) => notification.id),
	});
};

Only the supplied tools methods and console capture are available. There is no filesystem, shell, Node global, module loader, or arbitrary network access.

Execution limits

Limits are configured in apps/mcp/config.ts.

LimitDefault
Total execution time10 seconds
Guest memory64 MiB
JavaScript source64 KiB
Captured logs64 KiB
Each argument/result transfer1 MiB
Tool calls per execution50
Concurrent tool calls4

The deadline covers guest computation and asynchronous waits, including promises that never settle.

Cancellation and partial results

Cancellation or a limit failure stops new tool dispatch and passes an abort signal to running procedures. A procedure may have already committed a change before it receives that signal. Cancellation does not undo completed writes.

Programs and mutations are never automatically retried. When a program fails, check the application's current state before deciding whether to submit another request.

The result includes the program's value, bounded logs, and host-recorded invalidates tags.

On this page