Skip to documentation
Documentation

Code Mode MCP

Drive Keiki from an MCP client by writing one JavaScript program instead of calling tools one by one.

https://onkeiki.com/mcp/codemode serves the same operations as the Keiki MCP server at https://onkeiki.com/mcp, as a JavaScript API instead of one tool per operation. The client sees two tools, so its context does not fill up with every operation's schema, and one program can make many calls, combine their results, and return only what the model needs.

Connect it like /mcp: add the URL to any MCP client (Claude, Cursor, Codex, ChatGPT) and sign in with OAuth. The same token works on both servers, and a call is allowed exactly when it would be on /mcp: the same organization, the same role checks and the same audit trail.

Tools

search finds operations. Pass query (words or an exact path such as agents.get_by_id), and optionally group, limit (up to 50) and offset. Each result has the operation's path, its TypeScript signature, and whether it is read-only or destructive.

execute runs an async arrow function. Inside it, every operation is a call on keiki, grouped by the API route it comes from:

JavaScript
async () => {
  const { agents } = await keiki.agents.get()
  const details = await Promise.all(agents.map((a) => keiki.agents.get_by_id({ id: a.id })))
  return details.map((d) => d.agent.name)
}

Operations that are not API routes sit directly on keiki, such as keiki.talk_to_agent(...), keiki.check_job(...) and keiki.current_context(...). keiki.search(...) is also available inside a program, so a program can look up a signature and call it in one run.

The result has the program's return value as result, up to 200 lines of console.log output as logs, and calls: every operation the program made, with how long it took and whether it failed. A failed call throws inside the program, so try/catch works; an uncaught one ends the run with its error and the calls made so far.

Limits

  • A program runs for at most 120 seconds and makes at most 100 calls.
  • The result is cut to 60,000 characters.
  • The program has no network access: fetch and sockets fail. It can only reach Keiki through keiki, and it never sees your token.

A call that takes longer than the client would wait, usually talk_to_agent, returns a jobId instead of its result, exactly as on /mcp. Read it from a later program with keiki.check_job({ jobId, waitMs }). Jobs belong to the token that started them.

Destructive operations

search marks destructive operations (deleting, spending, changing access), and execute is marked as a tool that can be destructive, so clients that ask before running such tools ask before every execute. The model writing the program is told to show you what a destructive call will do and get your confirmation first.