Skip to main content
Docs menu

For agents

Markdown

One page for an agent setting itself up with Mirabase: get an API key, connect over MCP, make the basic calls, stay within limits, handle errors, and find the machine-readable files.

Mirabase keeps files, knowledge, and memory in one data model, reached by path, by id, or by meaning. If you are an agent reading this page, take the steps below in order. When a step requires a credential or a permission you do not have, stop and ask the person you work for.

ItemValue
Base URLhttps://api.mirabase.io
AuthenticationAuthorization: Bearer mb_live_...
MCP endpointhttps://api.mirabase.io/mcp, Streamable HTTP
OpenAPIhttps://api.mirabase.io/v2/openapi.yaml
Guide for agentshttps://api.mirabase.io/llms.txt

Get an API key

  1. Ask the person you work for to give you a key of your own. Do not use their root key.
  2. They create the key in the console, or issue it with POST /v2/api-keys, limited to the capabilities and Spaces you need with grant_capabilities and allowed_space_ids. The secret is shown once.
  3. Read the key from the MIRABASE_API_KEY environment variable. Never write it to a file, a log, a memory, or a conversation.
Sign-up is self-serve: once the person signs in to the console with GitHub, the account is active at once, on the free plan (1 GiB of storage, and 10,000 writes and 1,000,000 model tokens each month).
CapabilityAllows
knowledge:readRead Spaces, files, Entries, memories, and the change feed; call search and context
knowledge:answerCall POST /v2/retrieval/answer, together with knowledge:read
knowledge:writeWrite and edit files, ingest content, work on branches, and write the agent's own memory
memory:confirmWrite a confirmed memory directly, or correct a memory

For the full list and how to narrow a key, see Authentication and API keys.

Connect over MCP

Prefer MCP when your client supports it. The credential is the same API key, sent as a header. MCP authorization (OAuth 2.1) is not enabled yet, so a client that supports only OAuth cannot connect for now.

Claude Code
claude mcp add --transport http mirabase https://api.mirabase.io/mcp \
  --header "Authorization: Bearer $MIRABASE_API_KEY"
AddressToolset
/mcpThe full toolset; tool names start with mira.
/mcp/leanSix tools: mira_search, mira_read, mira_save, mira_forget, mira_list_spaces, and mira_history
  • After connecting, call mira.whoami first (GET /v2/whoami without MCP) to confirm your principal, your capabilities, and the Spaces you can read and write. If it fails, report the error code to the person; do not retry with another key.
  • tools/list returns only the tools this key can call.
  • Each tool makes one /v2 request, so permissions, limits, and error codes are the same as REST.

For the tool list, parameters, and the recommended call order, see Connect an Agent (MCP).

Basic calls

Without MCP, call REST directly. These five requests cover files, memory, search, and answers. default stands for your default Space, or the only Space the key can access.

curl
# 1. Write a file by path. The body is the file. Needs knowledge:write.
curl -X PUT "https://api.mirabase.io/v2/spaces/default/files?path=/notes/plan.md" \
  -H "Authorization: Bearer $MIRABASE_API_KEY" \
  -H "Content-Type: text/markdown" \
  -H "Prefer: wait=10" \
  --data-binary "We ship on Friday."

# 2. Store one lasting statement as a memory. Needs memory:confirm.
curl -X POST https://api.mirabase.io/v2/memories \
  -H "Authorization: Bearer $MIRABASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"scope": "project", "space_id": "default", "kind": "preference", "text": "Releases go out on Fridays."}'

# 3. Store a conversation; memories are distilled from it in the background. Needs knowledge:write.
curl -X POST https://api.mirabase.io/v2/spaces/default/ingest \
  -H "Authorization: Bearer $MIRABASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"kind": "conversation", "session_id": "chat-42", "messages": [{"role": "user", "content": "We ship on Friday."}]}'

# 4. Search. Needs knowledge:read.
curl -X POST https://api.mirabase.io/v2/retrieval/search \
  -H "Authorization: Bearer $MIRABASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "when do we ship", "space_ids": ["default"]}'

# 5. An answer that cites what it used, or status "abstained". Needs knowledge:read and knowledge:answer.
curl -X POST https://api.mirabase.io/v2/retrieval/answer \
  -H "Authorization: Bearer $MIRABASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"question": "When do we ship?", "space_ids": ["default"]}'
GoalCall
Store something with a path: a document, notes, a tablePUT /v2/spaces/{space_id}/files
Store text, a URL, or a conversation without a pathPOST /v2/spaces/{space_id}/ingest
Store one statement that stays truePOST /v2/memories
Read what is known before a taskPOST /v2/retrieval/context: the service picks passages within a token budget
Pick the passages yourselfPOST /v2/retrieval/search
Get a finished answer with citationsPOST /v2/retrieval/answer
Fix a memoryPOST /v2/memories/{memory_id}/correct: the old memory is kept as history
  • Search, context, and answer without space_ids read every Space the key can read, not the default Space. Name the Space when a call concerns a single user.
  • Give each end user a Space of their own: PUT /v2/spaces/{space_id} with ext:<your id> as the Space id returns the Space mapped to your own id for the user, creating it if it does not exist.
  • Citations point to a specific version of an Entry (entry_id, version_id, path). Check the citation before you state a fact.

Actions that require approval

These actions cannot be undone. Ask the person you work for before you take one:

  • Forgetting a memory: DELETE /v2/memories/{memory_id} or mira.memory.forget. When a memory is wrong, correct it instead.
  • Permanently erasing an Entry, or deleting a Space. Deleting a file only moves it to the trash, where it can be restored.
  • Revoking or rotating an API key.

For which actions can be undone, see Undo rules.

Limits

  • Every authenticated response carries RateLimit-Limit, RateLimit-Remaining, and RateLimit-Reset.
  • GET /v2/limits returns the account's plan and its limits, and GET /v2/usage returns the remaining quota. These two responses are the source of truth for the numbers.
  • 429 rate_limited: wait for Retry-After, then retry. When limit is concurrency, send fewer requests at the same time.
  • 429 quota_exceeded: one of the plan's quotas is used up, and retrying does not help. Report the quota field to the person.
  • A tool call over MCP counts as two requests: the /mcp call and the /v2 request it makes.
  • Direct writes accept files up to 16 MiB. Use uploads for larger files.

For the rules and the default limits, see Rate limits and quotas.

Errors

A failed request returns an error object: code, type, status, message, request_id, retryable, and, where a fixed next step exists, remediation.action. Branch on code and remediation.action; do not parse message. Over MCP, a failed call is a result with isError: true, and the error envelope is in _meta["dev.mirabase/error"].

Status and codeMeaningWhat to do
401 unauthorizedThe key is missing, invalid, expired, or revokedAsk the person for a new key
403 forbiddenThe key's capabilities or its role in the Space are insufficientCall GET /v2/whoami and report the missing capability to the person
403 proposal_requiredYou are changing a file you do not ownSend Prefer: handling=proposal to submit the change as a proposal
404 not_foundThe resource does not exist, or you cannot see itCheck the id, the path, and the Space
412 precondition_failedThe file changed after you read itRead it again, then edit from the new version
422 validation_errorA parameter, header, or body field is invalid or unknownFix the request using field and errors
429 rate_limitedThe request rate or the concurrency limit was reachedWait for Retry-After, then retry
429 quota_exceededA plan quota is used upStop retrying and tell the person
503 answer_not_configuredThe deployment has no answer modelDo not retry. Use POST /v2/retrieval/context and write the answer with your own model

Every code is listed in Error codes, and the retry rules are in API conventions.

Machine-readable files

AddressContents
https://api.mirabase.io/llms.txtThe guide for agents, served by the API itself: setup steps, every route, and the conventions
https://api.mirabase.io/v2/openapi.yamlThe OpenAPI document: every operation an API key can call, with examples
https://mirabase.io/developers/llms.txtThe index of these docs, one Markdown link per page
https://mirabase.io/developers/llms-full.txtAll the guides in one file
Any docs page address plus .mdThat page as Markdown, for example https://mirabase.io/developers/quickstart.md
https://mirabase.io/llms.txtThe site index: product pages and links to the files above

For the base URL, routes, and fields, the OpenAPI document and the API's own llms.txt are the authority. For SDK versions, use the latest release on npm and PyPI; do not guess a version number.

Contact

Send integration questions through the contact page. Include the request_id from the error response when you report a problem.

Next steps