Agent layer

Agents & MCP

Give agents scoped, shareable memory. Spaces, capability tokens, sessions, and handoffs, exposed over REST and the Model Context Protocol.

Spaces

A space is a shared context database with its own encryption and its own set of grants. Agents and people work in the same space.

Capability tokens

Hand an agent a token scoped to one space with read, write, or admin rights. Fail-closed by default; revoke at any time.

Sessions

Working memory with a sliding TTL: messages in order, structured data, and summaries, swept when they expire.

Handoffs

Pass a task from one agent to another by reference, carrying a capability. The receiver accepts and the sender's grant is revoked.

MCP-native

barrel_server mounts a Model Context Protocol endpoint, so an agent runtime talks to the database directly, with the same capability scoping as the REST surface.

Tools

Documents, BQL queries, search, timeline, and the agent layer as MCP tools.

Live resources

Subscribe to a query and receive resource-updated notifications on every change.

Provenance

Every write records actor, session, and source, so agent actions stay auditable.

Quick Start

cURL
# Create a space (a shared context database)
curl -X POST https://your-host/spaces \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"label": "research-team"}'

# Issue a scoped capability token for an agent
curl -X POST https://your-host/spaces/$SPACE/grants \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"rights": ["read", "write"]}'

# The agent talks to the same database over MCP at /mcp
#   tools: db_create, doc_put, query, search, branch_create, ...
#   resources: live query subscriptions pushed as updates

When to Use

Use the agent layer when:

  • + Multiple agents share and hand off context
  • + You need per-agent, revocable access scoping
  • + You want an MCP-native memory store
  • + Agent actions must be auditable

Consider alternatives when:

  • + A single agent with no sharing is enough
  • + You do not need capability scoping or MCP
  • + You only need raw storage (then use just Barrel)