Grain / Docs / MCP setup and tools

Docs

MCP setup and tools

Grain exposes eleven MCP tools over stdio so a coding agent can create, inspect, edit, publish, run and share workspace artifacts. Initialization writes the recognized agent config, while the agent calls tools with the grain_ prefix.

Updated 2026-09-04Facts verified 2026-09-04By the Grain team

Configure the stdio server

The initialization command recognizes .mcp.json for Claude Code, .codex/config.toml for Codex and .cursor/mcp.json for Cursor. Existing recognized files are updated; when none exists, .mcp.json is created. The server command has no flags.

grain mcp

Expected behavior is a long-running stdio process that responds to MCP requests. It does not print a share URL by itself. Extra arguments fail with Usage: grain mcp.

Available tools

ToolInputsUse
grain_listOptional folder, queryRead the folder tree and visible workspaces before selecting or creating one.
grain_newRequired name; optional template, folderCreate a hidden new workspace and return a checkout path. Templates are empty, HTML, Next.js or React with Vite.
grain_checkoutOptional workspaceMaterialize or reuse the temporary local editing copy for an existing workspace.
grain_pushOptional workspace, reloadPublish completed edits. Reload defaults to true; force is not available through MCP.
grain_pullOptional workspaceRecover remote drift or intentionally receive remote changes while preserving local work.
grain_checkpointOptional workspace, messageRecord a durable history revision after a successful push.
grain_execOptional workspace; required command arrayRun a bounded foreground command inside the workspace runtime.
grain_openOptional workspaceOpen an existing ready workspace. Do not open a new workspace before its first successful push.
grain_shareOptional workspace, action, mode, password, shareId, regenerateSlug, name, pathCreate, list, update or revoke shares and return both public and canonical URLs.
grain_upgradeOptional workspace, targetEnable a React with Vite or Next.js runtime for a clean, pushed HTML workspace.
grain_releaseOptional workspaceRemove only a clean, validated checkout after wanted work is safely pushed or preserved.

Safe agent workflow

  1. Call grain_list when the person refers to an existing workspace by name or asks for a folder placement. Use grain_new only when the person explicitly asks to create a workspace.
  2. For an existing workspace, call grain_checkout before editing. The returned local path is an editing copy, not the runtime.
  3. Edit files with ordinary file tools. Do not install, build or test at the checkout path.
  4. Call grain_push before any runtime check so the workspace receives the edits. On remote drift, call grain_pull, review the local result and retry the push.
  5. Call grain_exec with an argv array to install, build, test or inspect inside the runtime. Persistent development servers are not supported by this tool.
  6. After a successful push, call grain_checkpoint to preserve a named revision and grain_share to return an audience-facing URL.
  7. Call grain_release only when the checkout is clean and all wanted work is pushed or otherwise preserved.

Expected results and failures

SituationResultRecovery
Successful tool callA text rendering plus structured envelope with ok: trueRead returned ids, paths and URLs rather than inferring them.
Invalid inputAn error tool result with the CLI error envelopeCorrect the named field or enum and retry.
Remote drift on pushNothing uploads and the result says the remote workspace changedPull, inspect preserved local changes, then push again.
Static workspace receives execThe result says the HTML workspace has no compute runtimeUpgrade the clean, pushed workspace if an app runtime is actually needed.
Open before first pushThe new workspace is not ready to viewFinish editing and push successfully before opening.
Dirty releaseThe checkout remains in placePush wanted work or otherwise preserve it before releasing.

Sharing through MCP

The share tool defaults to the create action. It can create a public or password share, target a site path, reuse the existing share, update its visible state, regenerate its slug, list shares or revoke one. A successful create returns a shareUrl shaped like https://<slug>.share.rungrain.com and a canonical workspace URL.

Frequently asked questions

Which MCP tools does Grain provide?

List, new, checkout, push, pull, checkpoint, exec, open, share, upgrade and release, each rendered with the configured grain_ prefix.

Can an MCP agent force a push?

No. The MCP push tool intentionally omits force. Pull and review remote drift before retrying.

Where does an MCP agent run tests?

It pushes edits first, then calls grain_exec so tests run in the workspace sandbox rather than the local checkout.

Does the MCP server for Grain support persistent development servers?

No. The exec tool is for bounded foreground commands. The workspace runtime serves the published app.

Give your agent a publishing surface

Initialize a folder, confirm the generated MCP config and let the agent publish its first artifact.

Free forever. No card. Bring your own agent.

Sources · facts verified 2026-09-04