@abraca/mcp 2.90.0 → 2.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,557 +0,0 @@
1
- /**
2
- * Static resource: AI agent guide for working with Abracadabra documents.
3
- */
4
- import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
-
6
- const AGENT_GUIDE = `# Abracadabra AI Agent Guide
7
-
8
- ## Core Principle: "Everything is a Document"
9
-
10
- Every piece of visible data in Abracadabra — a calendar event, a kanban card, a table cell, a map marker — is a **document** in the tree. The document's **label** (name) IS the displayed value. Always.
11
-
12
- - A column's name IS the column header
13
- - A card's name IS the card title
14
- - A cell's name IS the cell content
15
- - An event's name IS the event title
16
-
17
- **Page types are views over the same document hierarchy**, not isolated data stores. Switching a page from Kanban to Table to Outline works without migration — the tree doesn't change, only the rendering.
18
-
19
- The same tree viewed as different page types:
20
- \`\`\`
21
- My Doc
22
- ├── "To Do" → Kanban: column / Table: column / Outline: item
23
- │ ├── "Fix bug" → Kanban: card / Table: cell / Outline: sub-item
24
- │ └── "Add tests"
25
- ├── "In Progress"
26
- │ └── "Refactor"
27
- └── "Done"
28
- └── "Deploy"
29
- \`\`\`
30
-
31
- ---
32
-
33
- ## Getting Oriented in a Space
34
-
35
- Before creating any documents, always call \`list_spaces\` to understand the current workspace. Each space has a \`doc_id\` — this is the **hub document** (the space root). All user-created documents must be direct or indirect children of this hub doc.
36
-
37
- \`\`\`
38
- list_spaces → pick the active space → note its doc_id (= hub doc ID)
39
- create_document(parentId: hubDocId, ...) ← top-level pages go here
40
- \`\`\`
41
-
42
- The hub doc itself is a system document — do not rename, move, or write content to it. It is just a container.
43
-
44
- If you are adding content to an existing space, call \`get_document_tree(rootId: hubDocId)\` first to understand what already exists before creating anything.
45
-
46
- ---
47
-
48
- ## Page Types Reference
49
-
50
- ### Core Types (always available)
51
-
52
- | Type | Children Are | Grandchildren Are | Depth | Key Meta on Children |
53
- |------|-------------|-------------------|-------|---------------------|
54
- | **doc** | Sub-documents | Sub-sub-documents | ∞ | — |
55
- | **kanban** | Columns | Cards | 2 | color, icon on cards |
56
- | **table** | Columns | Cells (positional rows) | 2 | — |
57
- | **calendar** | Events | — | 1 | datetimeStart, datetimeEnd, allDay, color, icon |
58
- | **timeline** | Epics | Tasks | 2 | dateStart, dateEnd, taskProgress, color |
59
- | **checklist** | Tasks | Sub-tasks | ∞ | checked, priority, dateEnd |
60
- | **outline** | Items | Sub-items | ∞ | — |
61
- | **graph** | Nodes | — | 1 | graphX, graphY, graphPinned, color |
62
- | **gallery** | Items | — | 1 | geoLat, geoLng, datetimeStart, tags, rating, icon, color |
63
- | **map** | Markers/Lines | Points (for lines) | 2 | geoType, geoLat, geoLng, icon, color |
64
- | **slides** | Slides | Sub-slides | 2 | slidesTransition, color |
65
- | **dashboard** | Items | — | 1 | deskX, deskY, deskZ, deskMode |
66
- | **chart** | Data points | Data points | 2 | number (value), color, tags |
67
- | **sheets** | Columns | Cells | 2 | formula, bold, italic, textColor, bgColor, align |
68
- | **overview** | Pages | — | 1 | — |
69
- | **call** | — (no children) | — | 0 | — |
70
-
71
- Alias: \`desktop\` → \`dashboard\`.
72
-
73
- ### Plugin Types (require plugin enabled on the server)
74
-
75
- | Type | Plugin | Children Are | Grandchildren Are | Depth | Key Meta on Children |
76
- |------|--------|-------------|-------------------|-------|---------------------|
77
- | **spatial** | spatial | Objects | Sub-parts | ∞ | spShape, spX/Y/Z, spRX/RY/RZ, spSX/SY/SZ, color, spOpacity |
78
- | **media** | media | Tracks | — | ∞ | tags |
79
- | **coder** | coder | Files/Folders | — | ∞ | fileType, entry |
80
-
81
- > Spatial uses the universal \`color\` key for object color — there is no \`spColor\`.
82
-
83
- ---
84
-
85
- ## Document Tree Operations
86
-
87
- ### Creating Well-Structured Hierarchies
88
-
89
- **Kanban board:**
90
- 1. \`create_document(parentId, "Project Board", "kanban")\`
91
- 2. Create columns: \`create_document(boardId, "To Do")\`, \`create_document(boardId, "In Progress")\`, \`create_document(boardId, "Done")\`
92
- 3. Create cards under columns: \`create_document(toDoColumnId, "Fix bug #123")\`
93
- 4. Optionally set card metadata: \`update_metadata(cardId, { color: "#ef4444", priority: 3, tags: ["urgent"] })\`
94
- 5. Optionally configure column width: \`update_metadata(boardId, { kanbanColumnWidth: "wide" })\`
95
-
96
- **Table with data:**
97
- 1. \`create_document(parentId, "Contacts", "table")\`
98
- 2. Create columns: \`create_document(tableId, "Name")\`, \`create_document(tableId, "Email")\`, \`create_document(tableId, "Phone")\`
99
- 3. Create cells (children of columns): \`create_document(nameColId, "Alice")\`, \`create_document(emailColId, "alice@example.com")\`
100
- 4. **Rows are positional** — the Nth child of each column forms row N
101
- 5. Row count = max children across all columns. Missing cells render as empty.
102
- 6. To add a row: create a child under each column at the same index position
103
- 7. To delete row N: delete the Nth child from every column
104
-
105
- **Calendar with events:**
106
- 1. \`create_document(parentId, "Team Calendar", "calendar")\`
107
- 2. Create events: \`create_document(calendarId, "Sprint Planning")\`
108
- 3. Set event times: \`update_metadata(eventId, { datetimeStart: "2026-03-20T10:00:00Z", datetimeEnd: "2026-03-20T11:00:00Z" })\`
109
- 4. All-day events: \`update_metadata(eventId, { datetimeStart: "2026-03-20", allDay: true })\`
110
- 5. Multi-day events: \`update_metadata(eventId, { datetimeStart: "2026-03-20", datetimeEnd: "2026-03-22", allDay: true })\`
111
- 6. Configure view: \`update_metadata(calendarId, { calendarView: "week" })\`
112
-
113
- **Timeline (Gantt chart):**
114
- 1. \`create_document(parentId, "Q1 Roadmap", "timeline")\`
115
- 2. Create epics: \`create_document(timelineId, "Auth Rewrite")\`
116
- 3. Create tasks under epics: \`create_document(epicId, "Implement JWT refresh")\`
117
- 4. Set dates and progress: \`update_metadata(taskId, { dateStart: "2026-03-01", dateEnd: "2026-03-15", taskProgress: 50, color: "#6366f1" })\`
118
-
119
- **Checklist (nested task list):**
120
- 1. \`create_document(parentId, "Sprint Tasks", "checklist")\`
121
- 2. Create tasks: \`create_document(checklistId, "Write tests")\`
122
- 3. Set task properties: \`update_metadata(taskId, { checked: false, priority: 3, dateEnd: "2026-04-01" })\`
123
- 4. Create sub-tasks (unlimited nesting): \`create_document(taskId, "Unit tests")\`
124
-
125
- **Map with markers and lines:**
126
- 1. \`create_document(parentId, "Travel Map", "map")\`
127
- 2. Create markers: \`create_document(mapId, "Coffee Shop")\`
128
- 3. Set marker position: \`update_metadata(markerId, { geoType: "marker", geoLat: 37.7749, geoLng: -122.4194, icon: "coffee", color: "#f97316" })\`
129
- 4. Create a line/route: \`create_document(mapId, "Walking Route")\`
130
- 5. Set line properties: \`update_metadata(routeId, { geoType: "line", color: "#3b82f6" })\`
131
- 6. Create line points as children: \`create_document(routeId, "Start")\` then \`update_metadata(pointId, { geoLat: 37.7749, geoLng: -122.4194 })\`
132
- 7. Create measuring tool: set \`geoType: "measure"\` instead of "line"
133
-
134
- **Gallery:**
135
- 1. \`create_document(parentId, "Photo Album", "gallery")\`
136
- 2. Create items: \`create_document(galleryId, "Sunset at Beach")\`
137
- 3. Set metadata: \`update_metadata(itemId, { geoLat: 37.7749, geoLng: -122.4194, tags: ["travel", "sunset"] })\`
138
- 4. Configure layout: \`update_metadata(galleryId, { galleryColumns: 4, galleryAspect: "16:9" })\`
139
-
140
- **Graph (knowledge graph):**
141
- 1. \`create_document(parentId, "Tech Stack", "graph")\`
142
- 2. Create nodes: \`create_document(graphId, "React")\`, \`create_document(graphId, "Vue")\`
143
- 3. Set node properties: \`update_metadata(nodeId, { color: "#6366f1", icon: "file-code" })\`
144
- 4. Edges are created by parent-child relationships AND document references (doc embeds/links in content)
145
- 5. Enable reference edges: \`update_metadata(graphId, { showRefEdges: true })\`
146
-
147
- **Dashboard:**
148
- 1. \`create_document(parentId, "Overview", "dashboard")\`
149
- 2. Create items: \`create_document(dashboardId, "Revenue Chart")\`
150
- 3. Position items on grid: \`update_metadata(itemId, { deskX: 0, deskY: 0, deskMode: "widget-lg" })\`
151
- 4. Modes: \`"icon"\` (small), \`"widget-sm"\` (240×180), \`"widget-lg"\` (400×320)
152
- 5. Grid uses 80px cells
153
-
154
- **Spatial (3D scene)** *(requires spatial plugin):*
155
- 1. \`create_document(parentId, "3D Scene", "spatial")\`
156
- 2. Create objects: \`create_document(sceneId, "Red Cube")\`
157
- 3. Set 3D properties: \`update_metadata(objId, { spShape: "box", color: "#ef4444", spX: 0, spY: 1, spZ: 0, spSX: 2, spSY: 2, spSZ: 2 })\`
158
- 4. Shapes: \`"box"\`, \`"sphere"\`, \`"cylinder"\`, \`"cone"\`, \`"plane"\`, \`"torus"\`, \`"glb"\` (uploaded 3D model — set \`spModelUploadId\` and \`spModelDocId\`)
159
- 5. Rotation (degrees): \`spRX\`, \`spRY\`, \`spRZ\`. Scale: \`spSX\`, \`spSY\`, \`spSZ\` (default 1). Opacity: \`spOpacity\` (0–100)
160
- 6. Use the universal \`color\` key — **never \`spColor\`**
161
-
162
- **Outline (nested items):**
163
- 1. \`create_document(parentId, "Meeting Notes", "outline")\`
164
- 2. Create items: \`create_document(outlineId, "Agenda Item 1")\`
165
- 3. Create sub-items (unlimited depth): \`create_document(itemId, "Sub-point")\`
166
-
167
- **Slides (presentation with two-axis nav):**
168
- 1. \`create_document(parentId, "Q1 Review", "slides")\`
169
- 2. Create slides as direct children: \`create_document(deckId, "Intro")\`
170
- 3. Create sub-slides (vertical navigation) as grandchildren: \`create_document(slideId, "Deep dive")\`
171
- 4. Per-slide transition: \`update_metadata(slideId, { slidesTransition: "fade", color: "#6366f1" })\`
172
- 5. Deck-level theme: \`update_metadata(deckId, { slidesTheme: "dark" })\`
173
-
174
- **Chart (data viz — manual or aggregation):**
175
- 1. \`create_document(parentId, "Sales", "chart")\`
176
- 2. Configure: \`update_metadata(chartId, { chartType: "bar", chartMetric: "value", chartShowLegend: true, chartLimit: 10 })\`
177
- 3. Modes:
178
- - **Manual data points**: create children with \`number\` (value) and optional \`tags\`/\`color\`
179
- \`create_document(chartId, "Q1")\` then \`update_metadata(dpId, { number: 42500, color: "#6366f1" })\`
180
- - **Aggregation**: set \`chartMetric\` to \`"type"\`/\`"tag"\`/\`"status"\`/\`"priority"\`/\`"activity"\`/\`"completion"\` and point the chart at a subtree — it aggregates the descendants' meta automatically
181
- 4. Chart types: \`"bar"\`, \`"stacked bar"\`, \`"line"\`, \`"donut"\`, \`"treemap"\`
182
- 5. Color schemes: \`"default"\`, \`"warm"\`, \`"cool"\`, \`"mono"\`
183
-
184
- **Sheets (spreadsheet with formulas):**
185
- 1. \`create_document(parentId, "Budget", "sheets")\`
186
- 2. Create columns: \`create_document(sheetId, "A")\`, \`create_document(sheetId, "B")\`
187
- 3. Create cells under columns (positional rows, like \`table\`)
188
- 4. Formulas on cells: \`update_metadata(cellId, { formula: "=A1+B1" })\`
189
- 5. Cell formatting: \`update_metadata(cellId, { bold: true, bgColor: "#fef3c7", align: "right" })\`
190
- 6. Deck config: \`update_metadata(sheetId, { sheetsDefaultColWidth: 120, sheetsDefaultRowHeight: 28, sheetsShowGridlines: true, sheetsFreezeRows: 1, sheetsFreezeCols: 1 })\`
191
-
192
- **Overview (space home):**
193
- 1. \`create_document(parentId, "Home", "overview")\`
194
- 2. No children required — renders activity, people, stats from the surrounding space
195
- 3. Children (if any) show as linked pages
196
-
197
- **Call (video room):**
198
- 1. \`create_document(parentId, "Daily Standup", "call")\`
199
- 2. Video rooms have **no children** — do not add documents underneath
200
-
201
- **Coder (multi-file collaborative editor)** *(requires coder plugin):*
202
- 1. \`create_document(parentId, "My App", "coder")\`
203
- 2. Create files/folders: \`create_document(projectId, "App.vue")\`, \`create_document(projectId, "src")\`
204
- 3. Set file type: \`update_metadata(fileId, { fileType: "vue", entry: true })\`
205
- 4. \`fileType\` options: \`"vue"\`, \`"ts"\`, \`"js"\`, \`"css"\`, \`"json"\`, \`"folder"\`
206
- 5. Mark the entry file with \`entry: true\` — the renderer uses it as the preview root
207
-
208
- **Media (audio/video playlist)** *(requires media plugin):*
209
- 1. \`create_document(parentId, "Focus Mix", "media")\`
210
- 2. Create tracks: \`create_document(playlistId, "Track 1")\` — attach audio/video file via upload tool
211
- 3. Playlist config: \`update_metadata(playlistId, { mediaRepeat: "all", mediaShuffle: false })\`
212
-
213
- ---
214
-
215
- ## Document References
216
-
217
- You can link and embed documents within rich-text content:
218
-
219
- **Block-level doc embed** — renders an embedded document preview:
220
- \`\`\`
221
- ![[docId]]
222
- \`\`\`
223
-
224
- **Inline link to another document:**
225
- \`\`\`
226
- [Link text](/doc/docId)
227
- \`\`\`
228
-
229
- **Inline wikilink** (shorthand — converted to doc link):
230
- \`\`\`
231
- [[docId]]
232
- [[docId|Display Text]]
233
- \`\`\`
234
-
235
- Example — write content with references:
236
- \`\`\`
237
- write_document(docId, "# Project Overview\\n\\nSee the detailed spec:\\n\\n![[specDocId]]\\n\\nCheck the [timeline](/doc/timelineDocId) for dates.")
238
- \`\`\`
239
-
240
- In the **graph** page type, document references (embeds and links) create visible edges between nodes when \`showRefEdges\` is enabled.
241
-
242
- ---
243
-
244
- ## Metadata Reference
245
-
246
- ### Universal Keys (use these — never invent prefixed variants)
247
-
248
- | Key | Type | Meaning |
249
- |-----|------|---------|
250
- | \`color\` | string | Hex/CSS color (e.g. "#6366f1") |
251
- | \`icon\` | string | Lucide icon name in kebab-case (e.g. "star", "code-2", "users"). **Never emoji.** Omit for default. |
252
- | \`datetimeStart\` / \`datetimeEnd\` | string | ISO datetime with time |
253
- | \`allDay\` | boolean | Whether datetime is all-day |
254
- | \`dateStart\` / \`dateEnd\` | string | ISO date-only (e.g. "2026-03-20") |
255
- | \`timeStart\` / \`timeEnd\` | string | HH:MM time |
256
- | \`tags\` | string[] | Tag labels |
257
- | \`checked\` | boolean | Done/checked state |
258
- | \`priority\` | number | 0=none, 1=low, 2=medium, 3=high, 4=urgent |
259
- | \`status\` | string | Status string |
260
- | \`rating\` | number | 0–5 stars |
261
- | \`url\` | string | URL |
262
- | \`email\` | string | Email address |
263
- | \`phone\` | string | Phone number |
264
- | \`number\` | number | Generic numeric value |
265
- | \`unit\` | string | Unit label for \`number\` |
266
- | \`subtitle\` | string | Secondary text |
267
- | \`note\` | string | Free-text note |
268
- | \`taskProgress\` | number | 0–100 progress (timeline tasks) |
269
- | \`members\` | { id, label }[] | Assigned users |
270
- | \`coverUploadId\` | string | Cover image (upload ID from upload_file) |
271
-
272
- ### Geo/Map Keys (for map children)
273
-
274
- | Key | Type | Meaning |
275
- |-----|------|---------|
276
- | \`geoType\` | string | "marker", "line", or "measure" |
277
- | \`geoLat\` | number | Latitude |
278
- | \`geoLng\` | number | Longitude |
279
- | \`geoDescription\` | string | Location description text |
280
-
281
- ### Renderer Config Keys (set on the page doc itself, not its children)
282
-
283
- | Key | Type | Applies to | Values |
284
- |-----|------|-----------|--------|
285
- | \`kanbanColumnWidth\` | string | kanban | "narrow", "default", "wide" |
286
- | \`galleryColumns\` | number | gallery | 1–6 |
287
- | \`galleryAspect\` | string | gallery | "square", "4:3", "3:2", "16:9", "free" |
288
- | \`galleryCardStyle\` | string | gallery | "default", "compact", "detailed" |
289
- | \`galleryShowLabels\` | boolean | gallery | show item labels |
290
- | \`gallerySortBy\` | string | gallery | "manual", "date", "name", "rating" |
291
- | \`calendarView\` | string | calendar | "month", "week", "day" |
292
- | \`calendarWeekStart\` | string | calendar | "sun", "mon" |
293
- | \`calendarShowWeekNumbers\` | boolean | calendar | — |
294
- | \`tableMode\` | string | table | "hierarchy", "flat" |
295
- | \`tableSortKey\` | string | table | meta key to sort by |
296
- | \`tableSortDir\` | string | table | "asc", "desc" |
297
- | \`timelineZoom\` | string | timeline | "week", "month", "quarter" |
298
- | \`timelinePixelsPerDay\` | number | timeline | zoom granularity |
299
- | \`timelineCenterDate\` | string | timeline | ISO date to center view |
300
- | \`checklistFilter\` | string | checklist | "all", "active", "completed" |
301
- | \`checklistSort\` | string | checklist | "manual", "priority", "due" |
302
- | \`mapShowLabels\` | boolean | map | — |
303
- | \`graphSpacing\` | string | graph | "compact", "default", "spacious" |
304
- | \`graphShowLabels\` | boolean | graph | — |
305
- | \`graphEdgeThickness\` | string | graph | "thin", "normal", "thick" |
306
- | \`showRefEdges\` | boolean | graph | show doc-reference edges |
307
- | \`mmSpacing\` | string | mindmap-layout | spacing between branches |
308
- | \`spatialGridVisible\` | boolean | spatial | show ground grid |
309
- | \`slidesTheme\` | string | slides | "dark", "light" |
310
- | \`chartType\` | string | chart | "bar", "stacked bar", "line", "donut", "treemap" |
311
- | \`chartMetric\` | string | chart | "value", "type", "tag", "status", "priority", "activity", "completion" |
312
- | \`chartColorScheme\` | string | chart | "default", "warm", "cool", "mono" |
313
- | \`chartLimit\` | number | chart | 3–30 (max items) |
314
- | \`chartShowLegend\` | boolean | chart | — |
315
- | \`chartShowValues\` | boolean | chart | — |
316
- | \`sheetsDefaultColWidth\` | number | sheets | 40–500 |
317
- | \`sheetsDefaultRowHeight\` | number | sheets | 20–100 |
318
- | \`sheetsShowGridlines\` | boolean | sheets | — |
319
- | \`sheetsFreezeRows\` | number | sheets | frozen rows count |
320
- | \`sheetsFreezeCols\` | number | sheets | frozen cols count |
321
- | \`mediaRepeat\` | string | media | "off", "all", "one" (plugin) |
322
- | \`mediaShuffle\` | boolean | media | plugin |
323
-
324
- ### Spatial 3D Keys (for spatial children — requires spatial plugin)
325
-
326
- | Key | Type | Default | Meaning |
327
- |-----|------|---------|---------|
328
- | \`spShape\` | string | — | "box", "sphere", "cylinder", "cone", "plane", "torus", "glb" |
329
- | \`color\` | string | — | CSS color — universal key, **not** \`spColor\` |
330
- | \`spOpacity\` | number | 100 | 0–100 |
331
- | \`spX\`, \`spY\`, \`spZ\` | number | 0 | Position |
332
- | \`spRX\`, \`spRY\`, \`spRZ\` | number | 0 | Rotation (degrees) |
333
- | \`spSX\`, \`spSY\`, \`spSZ\` | number | 1 | Scale |
334
- | \`spModelUploadId\` | string | — | GLB upload ID (when \`spShape: "glb"\`) |
335
- | \`spModelDocId\` | string | — | Doc ID that owns the GLB upload |
336
-
337
- ### Dashboard Keys (for dashboard children)
338
-
339
- | Key | Type | Meaning |
340
- |-----|------|---------|
341
- | \`deskX\`, \`deskY\` | number | Grid position (80px cells) |
342
- | \`deskZ\` | number | Z-index (layering) |
343
- | \`deskMode\` | string | "icon", "widget-sm" (240×180), "widget-lg" (400×320) |
344
-
345
- ### Sheets Cell Formatting (per-cell meta)
346
-
347
- | Key | Type | Meaning |
348
- |-----|------|---------|
349
- | \`formula\` | string | Cell formula (e.g. "=A1+B1") |
350
- | \`bold\` | boolean | — |
351
- | \`italic\` | boolean | — |
352
- | \`textColor\` | string | CSS color |
353
- | \`bgColor\` | string | CSS color |
354
- | \`align\` | string | "left", "center", "right" |
355
-
356
- ### Coder Keys (for coder children — plugin)
357
-
358
- | Key | Type | Meaning |
359
- |-----|------|---------|
360
- | \`fileType\` | string | "vue", "ts", "js", "css", "json", "folder" |
361
- | \`entry\` | boolean | Mark this file as the preview entry point |
362
-
363
- ### Discovering What Metadata Applies
364
-
365
- Use the \`list_page_types\` tool to enumerate all known page types and their declared \`metaSchema\` (fields that apply to children/descendants) and \`defaultMetaFields\` (renderer config fields on the page itself). It's the authoritative list of what meta keys make sense for any given page type.
366
-
367
- ---
368
-
369
- ## Content Structure
370
-
371
- Documents use a TipTap editor schema. The body supports:
372
- - Headings (# through ######)
373
- - Paragraphs with **bold**, *italic*, ~~strikethrough~~, \\\`code\\\`, [links](url)
374
- - Bullet lists, ordered lists, task lists (- [x] / - [ ])
375
- - Code blocks with language
376
- - Blockquotes
377
- - Tables (pipe syntax)
378
- - Horizontal rules
379
- - Images: \`![alt](src){width="..." height="..."}\`
380
- - Document embeds: \`![[docId]]\`
381
- - Inline doc links: \`[[docId|label]]\` or \`[label](/doc/docId)\`
382
- - MDC components: \`::tip\`, \`::note\`, \`::warning\`, \`::collapsible\`, \`::steps\`, \`::card\`, \`::accordion\`, \`::tabs\`, \`::code-group\`, etc.
383
- - Badges: \`:badge[Label]{color="..."}\`
384
- - Icons: \`:icon{name="star"}\`
385
-
386
- ### Writing Content with Frontmatter
387
-
388
- Set document title and metadata via YAML frontmatter:
389
-
390
- \`\`\`markdown
391
- ---
392
- title: My Document
393
- tags: [important, review]
394
- color: "#6366f1"
395
- icon: star
396
- priority: high
397
- checked: false
398
- datetimeStart: "2026-03-20T10:00:00Z"
399
- datetimeEnd: "2026-03-20T11:00:00Z"
400
- allDay: false
401
- geoLat: 37.7749
402
- geoLng: -122.4194
403
- geoType: marker
404
- ---
405
-
406
- Content goes here...
407
- \`\`\`
408
-
409
- ---
410
-
411
- ## Awareness / Presence
412
-
413
- When you connect, you appear in the awareness system alongside human users. Presence runs at two levels:
414
- - **Root awareness**: your name, color, and which document you're currently viewing (\`docId\`)
415
- - **Child doc awareness**: per-document presence including TipTap cursor position and renderer-specific state
416
-
417
- ### What happens automatically
418
-
419
- You do **not** need to call \`set_presence\` after reading or writing content — it's done for you:
420
-
421
- | Action | Automatic effect |
422
- |---|---|
423
- | \`read_document\` | Root \`docId\` updated; TipTap cursor placed at start of document |
424
- | \`write_document\` | Root \`docId\` updated; TipTap cursor placed at end of written content |
425
- | \`create_document\` | Root \`docId\` updated to the new document |
426
-
427
- ### set_presence — manual overrides only
428
-
429
- Use \`set_presence\` when you want to:
430
- - Override \`status\` to communicate intent ("thinking", "reviewing", "writing")
431
- - Explicitly update \`docId\` when browsing the document tree without reading content
432
-
433
- ### set_doc_awareness — renderer-specific item presence
434
-
435
- For structured renderers (kanban, table, calendar, etc.), use \`set_doc_awareness(docId, fields)\` to broadcast which item you are interacting with. This is visible as highlighted cards, cells, events, etc. in the dashboard.
436
-
437
- Always clear fields when done by setting them to \`null\`.
438
-
439
- | Renderer | Key | Value | When to set |
440
- |---|---|---|---|
441
- | **Kanban** | \`kanban:hovering\` | cardId | Inspecting or about to edit a card |
442
- | **Kanban** | \`kanban:dragging\` | \`{ cardId, toColumnId }\` | Moving a card between columns |
443
- | **Table** | \`table:editing\` | \`{ rowIdx, fieldId }\` | Editing a cell |
444
- | **Calendar** | \`calendar:focused\` | eventId | Interacting with an event |
445
- | **Calendar** | \`calendar:viewing\` | "YYYY-MM" | The month/week you're looking at |
446
- | **Outline** | \`outline:editing\` | nodeId | Editing an outline node |
447
- | **Gallery** | \`gallery:focused\` | itemId | Item hovered/selected |
448
- | **Timeline** | \`timeline:focused\` | taskId | Task selected |
449
- | **Graph** | \`graph:focused\` | nodeId | Node hovered/selected |
450
- | **Slides** | \`slides:current\` | slideId | Slide being presented |
451
- | **Spatial** | \`spatial:selected\`, \`spatial:camera\` | objectId / camera state | plugin |
452
- | **Media** | \`media:playing\`, \`media:position\` | trackId / 0–1 | plugin |
453
- | **Coder** | \`coder:activeFile\` | fileId | plugin |
454
- | **Map** | \`map:focused\` | markerId | Marker hovered/selected |
455
- | **Doc** | \`doc:scroll\` | 0–1 number | Scroll position in document |
456
-
457
- Example — mark a kanban card as being inspected, then clear:
458
- \`\`\`
459
- set_doc_awareness(boardDocId, { "kanban:hovering": cardId })
460
- // ... do work ...
461
- set_doc_awareness(boardDocId, { "kanban:hovering": null })
462
- \`\`\`
463
-
464
- ---
465
-
466
- ## Receiving Instructions from Humans
467
-
468
- **Channel events (preferred):** When running in channel mode, \`ai:task\` events from
469
- human users arrive as \`<channel source="abracadabra" ...>\` notifications directly in
470
- your session. Use the \`reply\` tool to send your response — it creates a reply document
471
- and signals task completion.
472
-
473
- **Chat messages:** Chat messages from the platform arrive as channel notifications. Use
474
- \`send_chat_message\` to respond in the same channel.
475
-
476
- **Polling (fallback):** Call \`poll_inbox\` to read the "AI Inbox" document.
477
-
478
- ---
479
-
480
- ## Common Patterns
481
-
482
- ### Explore a document fully (the correct way)
483
- \`\`\`
484
- 1. read_document(docId)
485
- → returns { markdown, children: [...] }
486
- 2. The body may be empty — that does NOT mean the doc is empty.
487
- Children ARE the content. Read every child:
488
- read_document(childId1), read_document(childId2), ...
489
- 3. Continue recursively until no children remain.
490
- \`\`\`
491
-
492
- **Never conclude a document is "empty" just because its markdown body is empty.
493
- Always check and traverse the \`children\` array returned by \`read_document\`.**
494
-
495
- ### Populate a kanban board from a list
496
- \`\`\`
497
- 1. create_document → kanban parent
498
- 2. For each column: create_document under kanban
499
- 3. For each card: create_document under the appropriate column
500
- 4. Optionally set metadata (color, tags, priority) on cards
501
- \`\`\`
502
-
503
- ### Write rich content with references
504
- \`\`\`
505
- 1. read_document to see current content (and children)
506
- 2. write_document with markdown (mode: "replace" or "append")
507
- 3. Use ![[docId]] to embed other documents
508
- 4. Use [[docId|label]] for inline doc links
509
- 5. Include frontmatter for title/metadata if needed
510
- \`\`\`
511
-
512
- ---
513
-
514
- ## Rules
515
-
516
- ### MUST:
517
- - Call \`list_spaces\` first to find the hub doc ID before creating any documents
518
- - Use document \`label\` as the display value — renaming a document renames it everywhere
519
- - Create child documents for every visible item (columns, cards, events, etc.)
520
- - Use universal meta keys (color, icon, dateStart) — never prefix with page type
521
- - Set meaningful labels on every document you create
522
- - Use \`get_document_tree\` to understand existing structure before adding to a space
523
- - Traverse the full \`children\` tree when asked to "check out", "explore", or "summarize" a document
524
-
525
- ### MUST NOT:
526
- - Conclude a document is empty because its markdown body is empty — check children first
527
- - Stop at the top-level doc when exploring — children and grandchildren are part of the content
528
- - Store display values in metadata — the label IS the display value
529
- - Use special metadata to distinguish document roles — the hierarchy does that
530
- - Create documents just for metadata — metadata lives ON documents
531
- - Break interchangeability — switching page types must not lose data
532
- - Use emoji as \`icon\` values — only lowercase kebab-case Lucide icon names are valid
533
- - Create top-level documents without first confirming the correct hub doc ID
534
- - Rename or write content to the space hub document itself
535
- - Set \`type\` on child items (cards, cells, events) — only set type on the parent page
536
- `;
537
-
538
- export function registerAgentGuide(mcp: McpServer) {
539
- mcp.resource(
540
- "agent-guide",
541
- "abracadabra://agent-guide",
542
- {
543
- description:
544
- "Comprehensive guide for AI agents working with Abracadabra documents. Covers page types, tree operations, metadata, content structure, and best practices.",
545
- mimeType: "text/markdown",
546
- },
547
- async () => ({
548
- contents: [
549
- {
550
- uri: "abracadabra://agent-guide",
551
- text: AGENT_GUIDE,
552
- mimeType: "text/markdown",
553
- },
554
- ],
555
- }),
556
- );
557
- }
@@ -1,47 +0,0 @@
1
- /**
2
- * Dynamic resource: server health + info.
3
- */
4
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
5
- import type { AbracadabraMCPServer } from '../server.ts'
6
-
7
- export function registerServerInfoResource(mcp: McpServer, server: AbracadabraMCPServer) {
8
- mcp.resource(
9
- 'server-info',
10
- 'abracadabra://server-info',
11
- {
12
- description: 'Abracadabra server info: name, version, root document ID, and health status.',
13
- mimeType: 'application/json',
14
- },
15
- async () => {
16
- let health = null
17
- try {
18
- health = await server.client.health()
19
- } catch {
20
- // health endpoint unavailable
21
- }
22
-
23
- const spaces = server.spaces
24
- const activeSpace = spaces.find(s => s.id === server.rootDocId) ?? null
25
-
26
- const info = {
27
- serverInfo: server.serverInfo,
28
- activeSpaceDocId: server.rootDocId,
29
- activeSpace,
30
- spaces: spaces.length > 0 ? spaces : undefined,
31
- health,
32
- agent: {
33
- name: server.agentName,
34
- color: server.agentColor,
35
- },
36
- }
37
-
38
- return {
39
- contents: [{
40
- uri: 'abracadabra://server-info',
41
- text: JSON.stringify(info, null, 2),
42
- mimeType: 'application/json',
43
- }],
44
- }
45
- }
46
- )
47
- }
@@ -1,57 +0,0 @@
1
- /**
2
- * Dynamic resource: document tree as navigable JSON.
3
- */
4
- import { readEntries } from '@abraca/dabra'
5
- import type { TreeEntry } from '@abraca/dabra'
6
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
7
- import type { AbracadabraMCPServer } from '../server.ts'
8
-
9
- function childrenOf(entries: TreeEntry[], parentId: string | null): TreeEntry[] {
10
- return entries
11
- .filter(e => e.parentId === parentId)
12
- .sort((a, b) => (a.order ?? 0) - (b.order ?? 0))
13
- }
14
-
15
- function buildTree(entries: TreeEntry[], rootId: string | null, maxDepth: number, depth = 0): any[] {
16
- if (maxDepth >= 0 && depth >= maxDepth) return []
17
- return childrenOf(entries, rootId).map(e => ({
18
- id: e.id,
19
- label: e.label,
20
- type: e.type,
21
- children: buildTree(entries, e.id, maxDepth, depth + 1),
22
- }))
23
- }
24
-
25
- export function registerTreeResource(mcp: McpServer, server: AbracadabraMCPServer) {
26
- mcp.resource(
27
- 'tree',
28
- 'abracadabra://tree',
29
- {
30
- description: 'Full document tree as nested JSON. Shows the complete hierarchy of all documents.',
31
- mimeType: 'application/json',
32
- },
33
- async () => {
34
- const treeMap = server.getTreeMap()
35
- if (!treeMap) {
36
- return {
37
- contents: [{
38
- uri: 'abracadabra://tree',
39
- text: '{"error": "Not connected"}',
40
- mimeType: 'application/json',
41
- }],
42
- }
43
- }
44
-
45
- const entries = readEntries(treeMap)
46
- const tree = buildTree(entries, null, 10)
47
-
48
- return {
49
- contents: [{
50
- uri: 'abracadabra://tree',
51
- text: JSON.stringify(tree, null, 2),
52
- mimeType: 'application/json',
53
- }],
54
- }
55
- }
56
- )
57
- }