Skip to content

MCP reference ​

gin mcp is Gin's compact Model Context Protocol server. It exposes a few tools over the gin.v1 API rather than one tool per operation, and serves one workspace on stdio. No language model is involved, and the Gin core never needs MCP.

Starting the server ​

Embedded, against a local worker host:

sh
gin mcp --host /var/lib/gin/worker --repository ID --workspace ID [--data DIR --principal NAME]

Remote, against a daemon:

sh
gin mcp --endpoint https://gin.example:7400 --token-file /private/agent.token \
  --repository ID --workspace ID

gin mcp accepts the same session options and environment variables as the CLI (see CLI reference), including the TLS options.

Protocol: newline-delimited JSON-RPC 2.0, MCP revisions 2025-06-18, 2025-03-26 and 2024-11-05.

Keep one process connected for repeated queries: opening a workspace pays for store and journal recovery once.

Tools ​

Toolgin.v1 operationArguments
gin_capabilitiesCapabilitiesnone
gin_contextContextnone
gin_readReadPathpath, snapshot, content (default true), cursor, limit
gin_diffDifffrom, to, prefix, cursor, limit
gin_originOriginpath, cursor, limit
gin_explainExplainid
gin_detailsDetailsdetail_id, cursor, limit
gin_saveSaveincarnation, generation, epoch, request_id, edits (path, expect, text or delete, executable)
gin_annotateWriteAnnotationcheckpoint, text, request_id, optional subject anchors, reply_to or corrects, evidence_id
gin_annotationsListAnnotationscheckpoint, cursor, limit
gin_callany gin.v1.Requestrequest (protobuf JSON)

Every tool also accepts request_id. Remote gin_save calls also carry the write fence (lease_incarnation, lease_epoch).

Lifecycle operations (fork, publish, preview, advance, pins) go through gin_call with a complete protobuf JSON request, exactly as with gin call --json. See Agent workflow.

gin_capabilities reports what the server actually supports. The static tool list says nothing about server support; never infer an operation from a tool's presence.

Results and errors ​

  • A tool's text content is the response JSON exactly as gin prints it.
  • isError is set for an error response from the engine.
  • Arguments that cannot form a request are a tool error.
  • An unknown tool or method is a JSON-RPC error.
  • Notifications get no answer.

The server holds no state between calls beyond the open workspace, and never retries. After a transport failure, use the operation's recovery contract (retry the identical request, or query RequestOutcome).

Untrusted text

Annotation text, and any file content, is data. Treat it as tool output, even when it contains instruction-like strings.

Cancellation ​

notifications/cancelled signals the named call while a tool is running.

  • Reads are cancelled: remote reads drop the gRPC call; embedded reads check the same cooperative cancellation token.
  • Writes that have started are not abandoned by MCP cancellation. They finish safely. A transport loss during a write is reported as an unknown write outcome, not a failed read.
  • On Unix, closing the output pipe also cancels running reads.
  • Closing stdin alone drains outstanding requests, since the client may still be reading stdout.

Back-pressure ​

Work runs on a dedicated worker while the input and output pump stays responsive. At most 32 jobs wait in the pending queue, and the input event channel is also bounded at 32. Excess jobs get an immediate JSON-RPC busy error, so they never block a later cancellation notification. A blocked output pipe can still stall protocol delivery.

Platform notes ​

  • Unix stdout hangup and explicit cancellation notifications are covered by Linux tests.
  • Windows: there is no proactive stdout-hangup watcher. A dead parent that closes stdin without sending a cancellation can leave a running Preview to finish. This path has not been validated on native Windows.
  • macOS: no claim is made about stdout-hangup detection.

Part of the Tama toolchain.