Skip to content

Add the Mojito CLI spawn adapter - #1090

Open
ehoogerbeets wants to merge 1 commit into
mcp-02-scaffoldfrom
mcp-03-cli-adapter
Open

ehoogerbeets wants to merge 1 commit into
mcp-02-scaffoldfrom
mcp-03-cli-adapter

Conversation

@ehoogerbeets

Copy link
Copy Markdown
Contributor

Transferred from ehoogerbeets#11 onto box/mojito (rebased onto master).

Stack note: this PR targets mcp-02-scaffold — merge bottom-up.

What this adds

The spawn layer every later MCP tool sits on. This PR does not yet expose any Mojito APIs to an agent; it is the plumbing that lets the MCP server talk to Mojito through the operator's existing CLI instead of inventing its own auth or HTTP client.

Why spawn the CLI

Mojito already has a CLI (mojito-prod / mojito-dev) whose api subcommand is authenticated against the right host. Reusing that CLI means:

  • credentials and host stay in the engineer's CLI config, never in MCP env vars
  • one MCP package can target prod or a local instance just by changing MOJITO_CLI
  • HTTP errors from Mojito surface as the CLI's stderr, which is what the agent actually sees

What it does

On each tool call the server will spawn {MOJITO_CLI} <argv>, capture stdout/stderr (never inherit them onto MCP stdio — that would corrupt the JSON-RPC transport), and apply a hard timeout (default 10 minutes). If the child hangs, it gets SIGTERM then SIGKILL two seconds later. Failures become a MojitoCliError that carries exit code, both streams, and a timeout flag so the agent can tell "CLI not installed" apart from "Mojito returned HTTP 400".

Config is two env vars: MOJITO_CLI (wrapper name or path; blank/whitespace falls back to mojito-prod) and MOJITO_CLI_TIMEOUT_MS (positive whole milliseconds only; anything else, including 0 or "Infinity", falls back to the default so a typo cannot disable the timer).

Stack

Depends on the scaffold PR. Next: the first real tools — repository list/view and pollable-task get.

Test plan

  • cd mojito-mcp && pnpm test
  • Confirm child stdout is captured, not inherited onto MCP stdio

Made with Cursor

Made with Cursor

@ehoogerbeets
ehoogerbeets added this pull request to stack #1102 September 24, 2026 23:04
Pin env parsing, captured stdio, timeouts, and spawn failures before any REST mapping is introduced.

Co-authored-by: Cursor <cursoragent@cursor.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant