Basics
Your server runs at http://127.0.0.1:8080 unless you chose another address. Every route under /v1 and /mcp needs an API key, sent as a header:
Authorization: Bearer <your API key>Create a key with musclememory key where the server runs, or on the dashboard's API keys page. A key belongs to one scope (a workspace, such as default), and routes that list or change things take that scope as visibility_scope. Lists accept limit (1–100, default 20) and offset.
Errors always look like {"error": {"code": "...", "message": "..."}}: 401 for a missing or wrong key, 403 for a scope the key can't use, 404 for something that doesn't exist, 409 for a conflict, 422 for invalid input (field names only, never your values) and 429 when rate limited. Requests from a web page on another site are refused.
Agents can use the same calls over MCP at /mcp: the tools musclememory_recall, musclememory_observe, musclememory_learn, musclememory_evaluate and musclememory_inspect match the five core routes below.
The five core calls
| Route | What it does |
|---|---|
| POST/v1/recall | Asks for a skill that fits a task. Send intent_text, runtime_profile (the agent and its tools) and visibility_scope; optionally match_limit (1–20, default 5). Returns ranked matches and guidance, the short note an agent receives, or no_match: true when nothing fits. |
| POST/v1/observe | Records a batch of steps from a session: tool calls with their arguments, results and timings. Reports how many were accepted, rejected or duplicates. |
| POST/v1/learn | Turns a finished session into a skill. Needs proof that it succeeded: the ids of the steps that show it, such as a passing test. |
| POST/v1/evaluate | Reports how a later session went with a skill. A pass counts as a check toward Ready; a failure flags the skill. |
| POST/v1/inspect | Returns a skill in full: every step, its history, its checks and the failed sessions it was compared with. |
/v1/recall also takes an optional X-MuscleMemory-Run header to tie the lookup to a session that is still recording.
Sessions
| Route | What it does |
|---|---|
| POST/v1/runs | Starts recording a session: run_token, intent_text (the task), runtime_profile and visibility_scope. |
| GET/v1/runs | Lists recorded sessions in a scope. |
| GET/v1/runs/{run_token} | One session with all its steps. |
| DELETE/v1/runs/{run_token} | Deletes a session and what was recorded in it. |
| POST/v1/runs/{run_token}/auto-learn | What hooks call when a session stops: if its tests passed after the last change, it becomes a check for a matching skill or a new skill waiting for your approval. |
| POST/v1/runs/{run_token}/usage | Records a session’s tokens, tool calls and time, as reported by the agent. |
Skills
| Route | What it does |
|---|---|
| GET/v1/procedures | Lists skills in a scope with their status and checks. |
| GET/v1/procedures/{procedure_token} | One skill: what it changes, how it was checked and who checked it. revision_selector picks a version (default latest). |
| GET/v1/procedures/{procedure_token}/revisions | Every version of a skill. |
| POST/v1/procedures/{procedure_token}/approve | Keeps a learned skill (the dashboard’s Keep button). |
| POST/v1/procedures/{procedure_token}/retire | Turns a skill off. Agents stop getting it. |
| DELETE/v1/procedures/{procedure_token} | Deletes a skill. |
| POST/v1/procedures/{procedure_token}/export | Writes the skill as a SKILL.md for agent=codex or agent=claude. |
Usage, keys and the server
| Route | What it does |
|---|---|
| GET/v1/usage | Totals for a scope: operations, checks, sessions and the measured savings. |
| GET/v1/usage/sessions | Usage session by session. |
| GET/v1/keys | API keys in a scope. Keys themselves are never shown again. |
| DELETE/v1/keys/{key_id} | Revokes a key. |
| GET/v1/session | Who the key belongs to and which scopes it can use. |
| GET/v1/retrieval/config | The settings recall uses: the embedding model, the similarity floor and the guidance size limit. |
| POST/auth/sign-in | Swaps the one-time code from musclememory dashboard for a dashboard key. |
| GET/health | Whether the server is up. Needs no key. |
| GET/openapi.json | This API as an OpenAPI file, straight from your server. |
Example
Ask for a skill the way a hook does before an agent starts:
curl -s http://127.0.0.1:8080/v1/recall \
-H "Authorization: Bearer $MM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"intent_text": "Fix the financial CSV export",
"visibility_scope": "default",
"match_limit": 1,
"runtime_profile": {"agent_name": "codex",
"bindings": {"shell.execute": "Bash", "filesystem.patch": "apply_patch"}}
}'A skill only matches an agent that has the tools it needs, so bindings names the tools your agent has. The answer's guidance is exactly what MuscleMemory adds to the agent's prompt; the dashboard's Playground shows the same thing without writing any code.