Skip to main content
Glama
README.md
# Agent Brain MCP

A scientific provenance layer for AI-assisted research programs. Tracks results,
equations, papers, datasets, and headline numerical outputs across multiple
repositories -- queryable by any AI agent via the
[Model Context Protocol (MCP)](https://modelcontextprotocol.io/).

## What It Does

Agent Brain gives your AI agents a persistent, structured memory:

- **Results**: Track every computation with lifecycle status
  (ACTIVE/DEAD/QUARANTINED), evidence grade (PROVEN/MEASURED/PARTIAL), and
  one-paragraph summaries
- **Outputs**: Store headline numbers from computations (not raw data -- just
  the 3-10 key values per computation that you'd actually query)
- **Papers**: Index papers by usage type (DATA/EQUATION/CONTEXT) with equations
  tracked to file+line
- **Artifacts**: List and fetch computation output files through the MCP without
  filesystem access
- **Events**: Append-only mutation log for full audit trail

## Quick Start

1. Install:

```bash
uv add agent-brain-mcp
```

2. Configure your repos:

```yaml
# ~/.agent-brain/config.yaml
domains:
  my-project:
    repo_root: /path/to/my/research
    active: true
```

3. Add to Claude Desktop config:

```json
{
  "mcpServers": {
    "brain": {
      "command": "uv",
      "args": ["run", "agent-brain"]
    }
  }
}
```

4. Start querying:
   - "What did comp42 find?" -> `query_results(computation_id="comp42")`
   - "All fitted values" -> `query_outputs(key_pattern="fit.%")`
   - "Papers about clusters" -> `query_papers(text="cluster")`

## Tools (17 total)

### Core provenance

| Tool | Purpose |
|------|---------|
| `record_result` | Create a new result |
| `update_result_status` | Change lifecycle/grade |
| `check_status` | Look up one result |
| `query_results` | Filter results |
| `record_assumption` | Track assumptions |
| `link_results` | Create inter-result links |
| `get_domain_summary` | Domain overview |
| `reconcile_disk_state` | DB-to-disk consistency check |

### Computation outputs

| Tool | Purpose |
|------|---------|
| `record_output` | Store a headline number |
| `query_outputs` | Search outputs by key pattern |

### Paper tracking

| Tool | Purpose |
|------|---------|
| `record_paper` | Add a paper |
| `query_papers` | Search papers |
| `link_paper_to_result` | Paper-to-result link |

### Artifact access

| Tool | Purpose |
|------|---------|
| `list_artifacts` | List files in a result's output dir |
| `fetch_artifact` | Read a specific artifact file |

## Configuration

All configuration is via environment variables with sensible defaults:

| Variable | Default | Purpose |
|----------|---------|---------|
| `AGENT_BRAIN_DB_PATH` | `~/.agent-brain/brain.db` | SQLite database location |
| `AGENT_BRAIN_CONFIG_PATH` | `~/.agent-brain/config.yaml` | Domain/repo config |
| `AGENT_BRAIN_HOST_KEY` | `localhost` | Host identifier for multi-machine setups |
| `AGENT_BRAIN_CONSTANTS_PATH` | *(empty)* | Optional project constants file for reconciliation |
| `AGENT_BRAIN_CUSTOM_MARKERS` | *(empty)* | JSON dict of extra marker files, e.g. `{"BUGGY.txt": "QUARANTINED"}` |
| `AGENT_BRAIN_ARTIFACT_MAX_BYTES` | `1048576` | Max artifact file size (1 MB) |
| `AGENT_BRAIN_ARTIFACT_MAX_LIST_ITEMS` | `200` | Max items from list_artifacts |
| `AGENT_BRAIN_ARTIFACT_ALLOW_SUPERSEDED` | `false` | Allow fetching dead/superseded artifacts |

## Design Principles

1. **Filesystem is ground truth** -- the DB mirrors on-disk state
2. **Metadata tier + fetch-on-demand artifact tier** -- summaries are always
   available, files on request
3. **No schema changes for new research** -- the same tables work for any domain
4. **Structured output keys** -- `category.target` pattern (`verdict.main`,
   `fit.slope`, `count.galaxies`)
5. **Path security** -- artifact fetching enforces allowlisted roots, blocks
   traversal

## Who This Is For

Research groups using AI agents (Claude, GPT, Codex) for computational science.
If your agents run computations, produce results, and need to remember what they
found -- this is the memory layer.

## Documentation

- [Architecture](docs/ARCHITECTURE.md) -- design rationale
- [Schema Reference](docs/SCHEMA.md) -- database tables and columns
- [Tool Reference](docs/TOOLS.md) -- every tool with examples
- [Conventions](docs/CONVENTIONS.md) -- output key vocabulary, verdict schema

## License

MIT

TDQS

B3/5.0

Scored across 15 tools

Disambiguation4/5

Most tools have clearly distinct resource+action targets (papers, results, outputs, artifacts), and the record_/query_ pairs are easy to tell apart. The main soft spots are check_status vs query_results (both read result classification) and record_result vs record_output, though the descriptions of 'headline quantitative value' vs 'scientific result' provide enough separation.

Naming Consistency4/5

All names are snake_case verb_noun (record_paper, query_results, link_results, fetch_artifact), which is a consistent and predictable pattern. The only minor deviation is the mix of read verbs (get_domain_summary, check_status, query_*, list_*, fetch_*), but each read verb maps to a genuinely different access mode.

Tool Count4/5

15 tools is at the upper edge of a well-scoped set but each maps to a distinct provenance operation (record/query/link for papers, results, outputs, plus disk reconciliation and artifact access). No tool appears redundant, though the set is close to feeling heavy for the domain.

Completeness3/5

Core write/read coverage exists for results, papers, and outputs, plus linking and artifact retrieval, but there is no delete/retire or update path for papers or outputs, and record_assumption has no corresponding query or update tool. Read-side traversal of links (e.g., list_links/query_links) is also missing, so an agent can create relationships but cannot inspect them except indirectly.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues