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 serves Keiki's whole MCP tool catalog 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.

Code Mode is the server to give a coding agent. Add the URL to any MCP client and sign in with OAuth:

ClientAdd Keiki
Claude Codeclaude mcp add --transport http keiki https://onkeiki.com/mcp
Codexcodex mcp add keiki --url https://onkeiki.com/mcp
CursorAdd { "mcpServers": { "keiki": { "url": "https://onkeiki.com/mcp" } } } to .cursor/mcp.json
VS Codecode --add-mcp '{"name":"keiki","type":"http","url":"https://onkeiki.com/mcp"}'

The same token works on both servers: a call is allowed exactly when the same action would be allowed for you in the dashboard, with the same organization, role checks and 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.

What the catalog covers

Most dashboard API endpoints are operations, including paginated audit reads and verification, connected-app listing and revocation, SSO administration, secrets writes, payment-account and payee management, webhook tests and signing-secret rotation, external harness setup, sandbox-provider availability, early-access requests, and Kapso setup. Eval-case editing, simulated eval runs and version diffs are tools too.

These administrative operations do not expand Copilot's permissions: operations reserved for MCP are neither discoverable nor callable by Copilot or its delegated programs. Secret values cannot be read back; writing a secret sends the value supplied by your MCP client.

Browser authentication, OAuth consent/callback and token-link redemption flows, multipart document uploads, interactive streams/terminals, wallet connection/decision flows, cross-organization agent transfers and provider-account key imports remain outside this endpoint catalog. Reading an agent's authored tool source remains dashboard-only. Coding agents can save and test authored-tool drafts with POST /agents/:id/tools/:toolId/test, passing { input } in the body. Testing runs authored code in the agent's sandbox and is marked destructive: the MCP client must obtain confirmation before calling it. The normal dashboard role and organization checks apply; viewers cannot run drafts and another organization's agent is not accessible. Tool Builder can also save and test drafts and return their source inside its delegated workflow. Link-producing tools such as SSO tests and Kapso signup return a URL; completing the external flow still requires a browser.

Owners/admins can also claim and DNS-verify domains (post_sso_domains, get_sso) and configure a customer's extension identity (put_agents_card_app) entirely through Code Mode, without an SSO plan. See the iMessage app-card setup sequence. These operations are not Copilot tools; they are keiki.sso.post_domains and keiki.agents.put_card_app.

These operations are not API endpoints and sit at the root of keiki:

ToolWhat it does
talk_to_agentSends one message to one of your agents as a real user and returns its reply.
code_taskDelegates a self-contained task to Coder; destructive proposals are returned, not run.
consult_oracleAsks Oracle to analyze organization telemetry, with optional engineering escalation. No repository access.
build_toolWrites and tests a disabled authored-tool draft on an owned agent.
publish_toolEnables a draft only when its stored source matches the supplied approved source.
check_jobReads a long call that returned a jobId: its status, progress so far, and result.
cancel_jobStops a long call and the work behind it.
current_contextWho the token acts as, its organization and role, and the current time.
read_resultReads a window of an oversized program result, or searches it for case-insensitive substring matches.
connect_mcpChecks a saved MCP preset and returns a browser authorization link or credential-entry page when needed.
switch_organizationLists your organizations, or moves the connection to one of them.
escalateFiles a bug report or feature request about the Keiki platform itself with the engineering team. Offered only where escalation is configured.
deploy_agentCreates or updates a partner deployment, with the same body as POST /api/v1/developer/deployments.
get_deployment, delete_deploymentReads or deletes one deployment by externalRef.
list_agent_templates, list_channel_typesWhat a deployment can be built from and which fields each channel needs.

Oversized results

An execute result over 60,000 serialized characters is stored whole, not clipped. The Worker stores it with your token, outside the sandbox, and returns { resultId, sizeChars, preview, note } instead of the large value. preview contains the first 4,000 characters of the serialized content; it is not the complete result. The size check and stored content both use JSON.stringify without indentation. If storage fails or the result is over 5,000,000 characters, execution returns an error: narrow the program or paginate its source data.

Read it from a later program:

JavaScript
async () => keiki.read_result({ : "mres_…", : 0, : 50000 })

A slice returns { ok, id, chars, offset, text }. length defaults to 50,000 and cannot exceed it. Windows can be shorter to keep their serialized response below the Worker's inline cap (escaping quotes or control characters takes extra space). Continue at offset + text.length until more is false. Offsets count UTF-16 code units; durable reads round to Unicode character boundaries rather than splitting a surrogate pair. Durable windows and substring searches run in Postgres, so reading a window or excerpt does not download the full stored result to the API. Search instead with { id, pattern, maxMatches? }: the substring match is case-insensitive, the default is 10 matches (maximum 100), and the response includes bounded excerpts, offsets and more. The serialized-response budget can also reduce the match count; more signals further matches.

Results are private to the user and organization that stored them, last one hour, and may be evicted earlier when that user's live results exceed 20,000,000 characters across organizations. The oldest live results are evicted first. A missing, expired or evicted result returns an error; rerun the program if needed. The internal root tool store_result({ content }) implements storage, but is excluded from programs and search. Copilot for Slack retains its separate in-memory result store and existing limits.

Connecting a saved MCP preset

After saving a preset, call keiki.connect_mcp({ agentId, presetId }). It uses the same connection-status handler and role checks as the dashboard. Viewers cannot use it.

  • connected: the connection is ready.
  • needs_consent: open authorizationUrl in the user's browser. This is the dashboard's stable authorize link, which mints a fresh provider URL when opened, including for reconnection after an authentication failure. Then call again with waitMs (at most 30,000) to poll for connection.
  • needs_credentials: open agentUrl and enter the header credential on that page. Never put a credential in chat or tool arguments.

Public MCP presets need no consent; pending or failed public MCP connections return their status and an agent page link for configuration. OpenAPI presets can require credentials even with authMode: public: these use the same browser authorization link as the dashboard. Status-check errors include the reconnect URL in the error text so it survives clients' error handling. This tool neither saves a preset nor completes consent on the user's behalf.

Specialists

The specialists use the same runners as Copilot for Slack. Spent model tokens are charged even when a run is cancelled or fails. Their model usage is charged to the organization per model, including Oracle and Tool Builder usage on both surfaces. Publishing calls the dashboard handler directly and makes no model call, parent trace or billing settlement. Model-backed invocations record a parent trace; long jobs expose its trace id and their current step through check_job.

code_task can make non-destructive writes under the caller's role checks. If it returns approvalProgram and approvalReason, that program was not run. Show the proposal to the user, then carry out the approved change yourself with keiki.* calls after confirmation. There is no MCP tool that executes the proposed program.

build_tool saves disabled drafts and can run authored code in the agent's sandbox. Viewers cannot build or publish; Oracle is allowed and Coder's API calls retain normal role checks. Before calling publish_tool, show the exact source to the user and obtain confirmation. A changed stored source is refused. Confirmation belongs to the client, not a server-issued approval receipt; the source comparison and subsequent enable are not an atomic compare-and-enable operation.

Talking to an agent

talk_to_agent takes agent (a name or id), message, and optionally fresh: true to start the thread over. Calling it again continues the same conversation. The turn runs on the agent's real configuration: nothing is sent to a real line, but every tool the agent calls (MCP integrations, sandbox, browser, loops, payments) runs for real. Use it to check an agent after changing it, or to reproduce something a user reported. Files the agent sends come back with download links that last up to 15 minutes.

Viewers are read-only: a change is refused with 403 viewer_read_only, and so is talk_to_agent, because the agent's own tools run for real.

Limits

  • A program runs for at most 120 seconds and makes at most 100 calls.
  • Results over 60,000 serialized characters return a durable handle; storage limits are described above.
  • 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 (40 seconds), such as talk_to_agent, code_task, consult_oracle or build_tool, returns a jobId instead of its result and keeps running. Read it from a later program with keiki.check_job({ jobId, waitMs }). Jobs are scoped to the user and organization that started them.

Completion and failure are final: a late worker cannot change that decision or its result. Cancellation only requests a stop if it wins against completion. A cancelled job stays cancelled, but can retain a result that was already in flight. cancel_job requests cancellation of a specialist's parent trace and delegated runs, checked at model-step boundaries. On the owning replica it also aborts in-flight model requests. It does not roll back completed API calls.

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.