For agents
MarkdownOne 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.
| Item | Value |
|---|---|
| Base URL | https://api.mirabase.io |
| Authentication | Authorization: Bearer mb_live_... |
| MCP endpoint | https://api.mirabase.io/mcp, Streamable HTTP |
| OpenAPI | https://api.mirabase.io/v2/openapi.yaml |
| Guide for agents | https://api.mirabase.io/llms.txt |
Get an API key
- Ask the person you work for to give you a key of your own. Do not use their root key.
- They create the key in the console, or issue it with
POST /v2/api-keys, limited to the capabilities and Spaces you need withgrant_capabilitiesandallowed_space_ids. The secret is shown once. - Read the key from the
MIRABASE_API_KEYenvironment variable. Never write it to a file, a log, a memory, or a conversation.
free plan (1 GiB of storage, and 10,000 writes and 1,000,000 model tokens each month).| Capability | Allows |
|---|---|
knowledge:read | Read Spaces, files, Entries, memories, and the change feed; call search and context |
knowledge:answer | Call POST /v2/retrieval/answer, together with knowledge:read |
knowledge:write | Write and edit files, ingest content, work on branches, and write the agent's own memory |
memory:confirm | Write 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 mcp add --transport http mirabase https://api.mirabase.io/mcp \
--header "Authorization: Bearer $MIRABASE_API_KEY"| Address | Toolset |
|---|---|
/mcp | The full toolset; tool names start with mira. |
/mcp/lean | Six tools: mira_search, mira_read, mira_save, mira_forget, mira_list_spaces, and mira_history |
- After connecting, call
mira.whoamifirst (GET /v2/whoamiwithout 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/listreturns only the tools this key can call.- Each tool makes one
/v2request, 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.
# 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"]}'| Goal | Call |
|---|---|
| Store something with a path: a document, notes, a table | PUT /v2/spaces/{space_id}/files |
| Store text, a URL, or a conversation without a path | POST /v2/spaces/{space_id}/ingest |
| Store one statement that stays true | POST /v2/memories |
| Read what is known before a task | POST /v2/retrieval/context: the service picks passages within a token budget |
| Pick the passages yourself | POST /v2/retrieval/search |
| Get a finished answer with citations | POST /v2/retrieval/answer |
| Fix a memory | POST /v2/memories/{memory_id}/correct: the old memory is kept as history |
- Search, context, and answer without
space_idsread 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}withext:<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}ormira.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, andRateLimit-Reset. GET /v2/limitsreturns the account's plan and its limits, andGET /v2/usagereturns the remaining quota. These two responses are the source of truth for the numbers.- 429
rate_limited: wait forRetry-After, then retry. Whenlimitisconcurrency, 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 thequotafield to the person. - A tool call over MCP counts as two requests: the
/mcpcall and the/v2request 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 code | Meaning | What to do |
|---|---|---|
401 unauthorized | The key is missing, invalid, expired, or revoked | Ask the person for a new key |
403 forbidden | The key's capabilities or its role in the Space are insufficient | Call GET /v2/whoami and report the missing capability to the person |
403 proposal_required | You are changing a file you do not own | Send Prefer: handling=proposal to submit the change as a proposal |
404 not_found | The resource does not exist, or you cannot see it | Check the id, the path, and the Space |
412 precondition_failed | The file changed after you read it | Read it again, then edit from the new version |
422 validation_error | A parameter, header, or body field is invalid or unknown | Fix the request using field and errors |
429 rate_limited | The request rate or the concurrency limit was reached | Wait for Retry-After, then retry |
429 quota_exceeded | A plan quota is used up | Stop retrying and tell the person |
503 answer_not_configured | The deployment has no answer model | Do 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
| Address | Contents |
|---|---|
| https://api.mirabase.io/llms.txt | The guide for agents, served by the API itself: setup steps, every route, and the conventions |
| https://api.mirabase.io/v2/openapi.yaml | The OpenAPI document: every operation an API key can call, with examples |
| https://mirabase.io/developers/llms.txt | The index of these docs, one Markdown link per page |
| https://mirabase.io/developers/llms-full.txt | All the guides in one file |
Any docs page address plus .md | That page as Markdown, for example https://mirabase.io/developers/quickstart.md |
| https://mirabase.io/llms.txt | The 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
- Write, search, and answer with the quickstart.
- See the MCP tools and the recommended call order.
- Issue the agent a narrowly scoped API key.
- Read how the official skills guide an agent to the right tool for each task.