Skip to content

Commit 82de64a

Browse files
committed
docs: replace cavemem MCP summary with full MCP documentation
1 parent b6187a9 commit 82de64a

1 file changed

Lines changed: 82 additions & 10 deletions

File tree

docs/cavemem/reference/mcp.md

Lines changed: 82 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,89 @@ title: MCP
44
sidebar_position: 2
55
---
66

7+
cavemem exposes four tools over an MCP stdio server, plus an opt-in `enrich` tool. The design goal is **progressive disclosure**: hits are compact until the agent asks for more.
78

8-
Progressive disclosure: `search` and `timeline` return compact results; `get_observations` fetches full bodies.
9+
The recommended workflow is a three-layer pattern:
910

10-
| Tool | Returns |
11-
|------|---------|
12-
| `search(query, limit?)` | `[{id, score, snippet, session_id, ts}]` — BM25 + optional cosine re-rank |
13-
| `timeline(session_id, around_id?, limit?)` | `[{id, kind, ts}]` |
14-
| `get_observations(ids[], expand?)` | Full bodies, expanded by default |
15-
| `list_sessions(limit?)` | `[{id, ide, cwd, started_at, ended_at}]` |
16-
| `enrich(query, note?)` | `{results: [{title, url, extract, observation_id}]}`**opt-in** web enrichment |
11+
1. `search` (or `list_sessions``timeline`) to get a compact index.
12+
2. Review IDs.
13+
3. `get_observations` with the filtered set.
1714

18-
`enrich` is off by default. When `enrich.enabled` is `false` the tool is not registered and cavemem makes no network call, ever. When enabled, it searches DuckDuckGo, stores compressed plain-text extracts as observations (tagged `source: web` + URL for provenance), and returns them.
15+
Following this pattern saves ~10× tokens versus fetching full bodies upfront.
1916

20-
---
17+
## `search`
18+
19+
Find observations matching a natural-language query.
20+
21+
```json
22+
{
23+
"name": "search",
24+
"input": { "query": "auth middleware", "limit": 10 }
25+
}
26+
```
27+
28+
Returns: `[ { id, session_id, snippet, score, ts } ]`
29+
30+
Scoring is hybrid: keyword (FTS5 BM25) blended with vector similarity via `settings.search.alpha`. Missing fields fall back gracefully.
31+
32+
## `timeline`
33+
34+
Chronological observation identifiers for a given session.
35+
36+
```json
37+
{
38+
"name": "timeline",
39+
"input": { "session_id": "sess_abc", "around_id": 42, "limit": 50 }
40+
}
41+
```
42+
43+
Returns: `[ { id, kind, ts } ]` — no body content. Use the IDs in `get_observations`.
44+
45+
## `get_observations`
46+
47+
Fetch full observation bodies by ID.
48+
49+
```json
50+
{
51+
"name": "get_observations",
52+
"input": { "ids": [12, 34], "expand": true }
53+
}
54+
```
55+
56+
Returns: `[ { id, session_id, kind, ts, content, metadata } ]`.
57+
58+
Content is expanded to human-readable form by default. Pass `expand: false` to request the compressed form (useful for audit or for agents that understand the caveman dialect directly).
59+
60+
## `list_sessions`
61+
62+
List recent sessions in reverse chronological order.
63+
64+
```json
65+
{
66+
"name": "list_sessions",
67+
"input": { "limit": 20 }
68+
}
69+
```
70+
71+
Returns: `[ { id, ide, cwd, started_at, ended_at } ]`. Use `id` with `timeline` to navigate within a session.
72+
73+
## `enrich` (opt-in)
74+
75+
Search the web via DuckDuckGo's HTML endpoint, store plain-text extracts of the top results as observations, and return them. **Off by default**: the tool is only registered when `enrich.enabled` is `true` in settings. When it is off, the tool does not exist and cavemem makes no network call, ever. Queries leave the machine only when the user has enabled the setting **and** the agent explicitly calls the tool.
76+
77+
```json
78+
{
79+
"name": "enrich",
80+
"input": { "query": "sqlite fts5 bm25 ranking", "note": "researching search ranking" }
81+
}
82+
```
83+
84+
Returns: `{ query, results: [ { title, url, extract, observation_id } ], stored_ids }`
85+
86+
Each result page is fetched with a 500 KB byte cap and the `enrich.timeoutMs` timeout, stripped to plain text, and truncated to 2000 characters. Extracts are stored through the normal write path (compressed, privacy-redacted) under a dedicated `enrich` session, with `metadata: { source: "web", url, query, note? }` for provenance. `query` and `note` are scrubbed (private tags + secret patterns) before they reach metadata, and source URLs are preserved byte-for-byte. `enrich.maxResults` (default 3, max 5) bounds how many results are fetched and stored. If the search fails or nothing can be fetched, the call returns an error and nothing is stored.
87+
88+
Only public hosts are fetched: every URL and every redirect hop (followed manually, capped at 3) must be http(s) to a non-private address. Loopback, RFC1918, link-local (`169.254.0.0/16`, e.g. cloud metadata endpoints), and unique-local targets — including obfuscated numeric forms — are rejected without a request, protecting against SSRF via malicious result links or redirects.
89+
90+
## Contract stability
91+
92+
Fields may be added. Existing fields will not be removed or renamed within a minor version.

0 commit comments

Comments
 (0)