MCP

MCP is the Model Context Protocol. An agent (a coding assistant, a script that drives the build) uses it to call tools and read structured results. Histos speaks MCP so that agent asks for the same operations you type at the terminal, and reads the same report.

You do not start a second build tool for the agent. The client's configuration names histos as the program and mcp as its argument. The process speaks JSON on standard input and standard output. There is no port to open.

{
  "mcpServers": {
    "histos": {
      "command": "histos",
      "args": ["mcp"]
    }
  }
}

The tools are the commands

Each tool is one operation you could have typed. The set is graph, run, cancel, compile, test, publish, version, assembly, clean, resolve, workflow, fmt, reload, reboot, cachePath, cacheList, cacheClean, cacheForget, cacheVerify, watch, preview, observe, and doctor. A tool's description, next to its name in the source, says which arguments it takes. tools/list returns this set and nothing else, so an agent cannot invent a command Histos does not have.

histos.mcp.HistosMcp.toolNames
  /** Names passed to `tool`. `tools/list` must equal this set. */
  val toolNames: Set[ToolName] = Names.all
histos.mcp.HistosMcp.tools
def tools(
      repo: Path,
      apiJar: Path,
      machine: Machine,
      desk: Session.Desk,
  ): Either[
    NonEmptyChunk[McpBuildError],
    Mcp[Loader & Scope & Resolve & ContentStore & IvyRoot & DoctorSurface.Reads],
  ] =
    val ask     = (call: Call) => Session.deliver(Session.perform(repo, apiJar, machine, desk, call))
    val refused = (reason: Rejection) => Session.CallProblem.Fault(BuildFault.Rejected(reason))
    for
      base    <- Mcp.from()
      listed  <- base.tool[NoArgs](Names.graph, "Show the project graph")(_ => ask(Call.Graph))
      running <- listed.tool[RunArgs](
        Names.run,
        "Run a main, or inspect, versions, or a plugin task. platform is jvm, js, or native. scala is one series (2.13 or 3) or one full version. A module run starts one process. texts and flags are the plugin arguments. env overlays the server environment and is omitted as empty. directory must already exist inside the repo, and an omitted directory stays under .histos/run. args are the program arguments. stdin is not attached.",
      )(args =>
        val asked = arguments(args.texts, args.flags).left
          .map(BuildFault.Rejected(_))
          .flatMap(parsed => programDirectory(args.directory).map(dir => (parsed, overlay(args.env), dir, args.args)))
        ZIO
          .fromEither(asked)
          .mapError(Session.CallProblem.Fault(_))

…

The agent is not sitting at a keyboard

Some Histos commands ask a question, for example whether to accept a default. A person at a terminal can answer. An MCP client has no keyboard unless it has negotiated a way to ask. When it has not, Histos returns the question as a diagnosis instead of waiting forever. The agent can then decide, or tell you.

histos.mcp.McpConsent.unnegotiated
def unnegotiated(offer: LockOffer, call: Call): ConsentDecision =
    ConsentRoute.decide(ClientSurface.Mcp(false), offer, call)

A failed compile is still a result

If the compile or the test actually ran, the tool returns the report, including a report that says the build failed. That is a result the agent can read. If the request was refused before it started, because the arguments were not a real command, the tool call itself fails. The agent can tell those apart: one means "I ran it, and it failed", the other means "I did not run it".

histos.cli.Help.render
def render(words: List[String]): Either[HelpError, String] =
    val key = words.map(_.trim).filter(_.nonEmpty).mkString(" ")
    if key.isEmpty then Right(grouped)
    else
      family(key) match
        case Some(text) => Right(text)
        case None       => Left(HelpError.Unknown(key))