§ /docs — mcp · rest · admin

The interaction surface,
every endpoint.

Seven MCP tools. A REST surface for core operations and administration. Entra OAuth, API-key, and local profiles share the same memory engine.

transport · MCP · streamable HTTPrest · FastAPI · OpenAPI 3.1auth · Entra OAuth · API key · local
§ 01 — MCP TOOLS

Seven tools,
explicit schemas.

Every MCP client invokes these by name. All take JSON arguments matching the schema below.

borg_thinkcompile

Classify the query, retrieve across strategies, rank on 4 dimensions, compile a token-budgeted context package.

// arguments
{
  query: string,
  namespace?: string,
  model?: "claude" | "gpt" | "local" | "copilot",
  task_hint?: "debug" | "architecture" | "compliance" | "writing" | "chat"
}

borg_learnrecord

Store an episode. Extraction runs async so this returns in milliseconds and never blocks the agent loop.

// arguments
{
  content: string,
  source: string,
  namespace: string,
  metadata?: object
}

borg_recallbrowse

Direct memory search without compilation. Raw episodes, facts, and procedures — for UI, audits, or the developer at the console.

// arguments
{
  query: string,
  namespace: string,
  memory_type?: "episodic" | "semantic" | "procedural"
}

borg_get_episodefetch

Fetch the complete stored body and metadata for an episode returned by recall.

// arguments
{ episode_id: string }

borg_forgetdelete

Soft-delete an episode, fact, entity, or procedure. Episode deletion can cascade to derived memory.

// arguments
{
  target_type: "episode" | "fact" | "entity" | "procedure",
  target_id: string, namespace: string,
  reason?: string, cascade?: boolean
}

borg_guardrisk check

Check a proposed action against known failures, constraints, and related memory.

// arguments
{
  action: string, namespace: string,
  files?: string[], proposed_change?: string,
  task_hint?: string
}

borg_project_summarysummarize

Build deterministic Markdown from active decisions, constraints, recent work, procedures, conflicts, and failed attempts.

// arguments
{ namespace: string }
§ 02 — REST MIRROR

Same tools,
plain HTTP.

Not every upstream speaks MCP. The REST mirror gives you the same surface for webhooks, CI, ad-hoc scripts, or legacy apps.

MethodPathMaps to
POST/api/thinkborg_think
POST/api/learnborg_learn
POST/api/recallborg_recall
GET/api/episodes/{episode_id}borg_get_episode
POST/api/forgetborg_forget
POST/api/guardborg_guard
GET/api/admin/namespaces/{namespace}/summaryborg_project_summary
GET/healthLiveness · returns engine + worker status
GET/docsDeployment Swagger UI when BORG_ENABLE_DOCS=true
§ 03 — ADMIN

Inspect the pipeline,
drive the worker.

The admin surface exposes queue state, graph records, audit traces, project summaries, snapshots, and extraction cost.

Observability

// queue depth, running, errors, throughput
GET /api/admin/queue

// list recent entities / facts / procedures
GET /api/admin/entities
GET /api/admin/facts
GET /api/admin/procedures
GET /api/admin/episodes
GET /api/admin/audit

Control

// force-process or requeue
POST /api/admin/process-episode
POST /api/admin/requeue-failed

// snapshot + cost
POST /api/admin/snapshot
GET /api/admin/snapshot/latest
GET /api/admin/cost-summary
§ 04 — ERRORS

Predictable failures,
diagnostic bodies.

REST failures are JSON. Authentication, authorization, validation, missing resources, and rate limits have distinct status codes that clients can handle directly.

StatusConditionResponse behavior
401 / 403Missing credentials / insufficient accessEntra, API-key, role, and namespace checks stay distinct.
404Unknown namespaceResource is absent, deleted, or outside the visible scope.
422Request validation failedFastAPI returns the invalid field path and validation message.
429Rate-limited (default 60/min on learn)Retry after Retry-After seconds.
503Service or extraction dependency unavailableRetry after the dependency or worker recovers.