Troubleshooting

The failures people run into, what causes each one, and the fix. If you have an error code, search this page for it first.

Read the body, not just the status

json
{ "content": [{ "type": "text", "text": "{\"error\":{\"code\":\"INSUFFICIENT_SCOPE\",\"message\":\"...\"}}" }] }

Only auth and routing problems use HTTP status codes. If your client only checks response.ok, it will treat half of these failures as success. Parse content[0].text and look for error.code every time.

Authentication

SymptomWhat it isFix
401 UNAUTHORIZED, "Missing or invalid Authorization header"The header is absent or not shaped Bearer mk_...Send Authorization: Bearer mk_...
401 UNAUTHORIZED, "Invalid or expired API key"The key does not match a live key. A truncated, wrapped or quoted key fails here. An mk_ key is exactly 35 charactersRe-mint the key at /api-keys and store it without reformatting
Everything 401s even though the key is definitely rightYou are calling the apex domain. It redirects, and the redirect strips your Authorization headerAlways use https://www.monofile.ai
403 ORG_MISMATCH, "Workspace mismatch"You sent an X-Monofile-Org-Id header that disagrees with the workspace your credential belongs toDrop the header. A key already carries its own workspace, and no header can change it
200 with INSUFFICIENT_SCOPE, "Missing required scopes: ..."The key is valid but lacks a scope the tool needsMint a key with the scopes listed in the message. See Scopes

Shell commands

SymptomWhat it isFix
SANDBOX_NOT_ENTITLEDThe command needs the full shell, which is part of the paid plans: Pro for a personal workspace, Team for an organizationUpgrade, or stay inside the built-in commands, which keep working on every plan
"pipes are not supported in this environment" with exit code 2The built-in shell refuses operators it cannot honour. The same applies to <, 2>, backticks, $(...) and background &Use command flags instead, for example grep -n "pattern" /path, or move to the full shell
SANDBOX_BUSYOne command runs per workspace at a timeWait and retry. This is expected under concurrency
RATE_LIMITED, "Daily sandbox limit reached"You have used the day's allowance of full-shell commandsWait for the window, or use read-only commands, which are not capped
INSUFFICIENT_CREDITSThe full shell is per-use compute billed against AI creditsWait for the next billing period, or top up
INSUFFICIENT_SCOPE, "The sandbox was restored and nothing was written"Scopes apply to what the command changed, not to the command text. The whole set of changes was rejected togetherUse a key with files:write, or files:delete for removals
OUT_OF_FOLDER_SCOPEA folder-restricted key changed files outside its folderKeep the command's writes inside the folder
DIFF_TOO_LARGEThe command changed more than 200 files, so nothing was writtenSplit it into several smaller commands
TIMEOUTThe command exceeded its timeout, 60 s by defaultPass a longer timeout, up to 240 s. Changes made before the timeout are still written back

More in File and Shell Tools, and the numbers in Limits.

Editing files

SymptomWhat it isFix
NO_MATCH, "The text to replace was not found"old_string does not appear in the file, usually because you retyped it instead of copying itRead the file again and copy old_string verbatim from that output
MULTIPLE_MATCHES, "Found N occurrences"The text appears more than once and the edit would be ambiguousInclude more surrounding context, or pass replace_all: true
EDIT_CONFLICT, "File was modified at ..."Someone or something else wrote the file after you read itRead it again, then retry the edit against the new content
INVALID_INPUT, "Cannot read a folder"The path is a folderUse bash ls or bash tree for folders
FILE_NOT_FOUNDThe path does not exist, or a parent folder does notCheck with bash ls. write creates parent folders for you by default
IS_DIRECTORY on create_share_linkShare links are per fileUse share_folder for a folder. See Public Folders

Reverting

SymptomWhat it isFix
CONFLICT, "Files were modified after this changeset"A newer write landed on a file the changeset touched, so reverting would discard it silentlyInspect the newer version, then pass force if you still want the revert
CHANGESET_NOT_FOUND or VERSION_NOT_FOUNDThe id is wrong or belongs to another workspaceList them first with list_changesets or list_versions
CAP_EXCEEDED on checkpointEither the file already has 10 checkpoints, or the folder holds more than 200 filesReuse or remove an old checkpoint, or checkpoint a smaller subfolder

The AI assistant

All three of these are 403 with code ACCESS_DENIED, distinguished by reason:

reasonWhat it isFix
no_subscriptionThe assistant needs the Pro planSubscribe to Pro
no_creditsYou have spent this period's AI creditsThey reset at the start of the next billing cycle
org_plan_requiredYou are in an organization workspace, and AI there is billed to the organizationAn organization admin subscribes to Team, or switch back to your personal workspace to use your own Pro plan

More in AI Credits and Usage.

The CLI

SymptomWhat it isFix
Not logged in to <origin>, exit code 3The CLI stores credentials per API origin, so a login against one environment does not authenticate anothermonofile login for that origin, or set MONOFILE_API_KEY
monofile login hangs and then times out, with "Failed to fetch" in the browser consoleRecent Chromium versions require permission before an https page may reach a loopback server, and headless browsers deny it automaticallyClick Allow when prompted. Headless: monofile login --no-browser and open the printed URL, or pipe an existing key into monofile login --with-key
monofile api GET /api/users/me complains about a path like C:/Program Files/Git/api/users/meGit Bash and other MSYS shells rewrite Unix-looking arguments before the CLI ever sees themUse //api/users/me, or set MSYS_NO_PATHCONV=1
Every command fails with "is not valid JSON"A hand-edited or truncated config or credentials fileDelete the named file and log in again
monofile grep exits 1 with no outputZero matches is a non-zero exit, as in Unix grepTreat exit 1 from grep as "no match"
monofile sync reports the folder is locked, exit code 6One sync per folder at a timeWait for the other run to finish. The CLI clears a lock left behind by a dead process
"Not a Monofile folder" or "was cloned from a different origin", exit code 2The directory has no sync state, or its state points at another environmentmonofile clone it, or point the CLI at the origin it was cloned from

Exit codes are a stable contract: 0 ok, 1 error, 2 usage, 3 auth, 4 not found, 5 forbidden, 6 conflict, 7 network. More in CLI Commands.

Installing a fresh release

If npx @monofile/cli cannot find a version you know exists, the cause is almost always local. A stale npm cache is the usual one, and a min-release-age setting in your npm configuration also hides any release newer than its threshold.

Terminal
npm cache clean --force
npx --min-release-age=0 -y @monofile/cli@latest --version

MCP clients

SymptomWhat it isFix
The server starts but every tool call returns UNAUTHORIZEDThe stdio server starts even with no key, and says so on stderrPass the key: -e MONOFILE_MCP_API_KEY=mk_..., or an env block in the client config
The hosted endpoint returns 401 "Unauthorized: Invalid or missing API key"A missing or malformed bearer header, or the apex domain againAuthorization: Bearer mk_... against https://www.monofile.ai/api/mcp
The hosted endpoint returns 405 "Method not allowed. This server operates in stateless mode"The client opened a GET for a server-sent-event stream. The endpoint is stateless and POST-onlyUse a client that speaks POST Streamable HTTP, or switch to the stdio server
A tool you can call over REST is missing from the client's tool listThe hosted endpoint advertises only the tools your key's scopes allow. A key minted without an explicit scope list gets a narrow default, which hides sharing, social and search toolsMint the key with an explicit scope list. GET /api/tools is unfiltered, so a difference between the two is always a scope gap
The stdio server reports an unknown tool the API clearly hasThe stdio server lists a snapshot taken when it was published, so it can lag the live registryUpgrade @monofile/mcp, or use the hosted endpoint
Tools work but touch the wrong environment's dataThe server defaults to production when no API URL is setSet MONOFILE_API_URL

More in Connecting MCP Clients.

In the editor

SymptomWhat it isFix
The editor will not accept input, or a drawing has lost its toolbarRead mode is on. The same happens in the non-focused pane when one file is open in two panesToggle read and write mode from the pane's menu
A panel shows stale content after another surface changed the fileAnother client wrote the file while it was openReopen the tab to pick up the current content

Semantic search can fail with a generic search error while embeddings are being generated or throttled upstream. Retry after a minute. Filename search and grep are unaffected.

Next steps

  • LimitsSizes, counts, timeouts and rate limits in one table.

  • Errors and LimitsEvery error code, what causes it, and how to recover.

  • ScopesEvery scope, what it unlocks, and the presets.

  • Docs for Agentsllms.txt, /docs.md and the raw markdown render of every page.

1659 words