htm 0.0.14 → 0.0.15
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -0
- data/README.md +269 -79
- data/db/migrate/00003_create_file_sources.rb +5 -0
- data/db/migrate/00004_create_nodes.rb +17 -0
- data/db/migrate/00005_create_tags.rb +7 -0
- data/db/migrate/00006_create_node_tags.rb +2 -0
- data/db/migrate/00007_create_robot_nodes.rb +7 -0
- data/db/schema.sql +41 -29
- data/docs/api/yard/HTM/Configuration.md +54 -0
- data/docs/api/yard/HTM/Database.md +13 -10
- data/docs/api/yard/HTM/EmbeddingService.md +5 -1
- data/docs/api/yard/HTM/LongTermMemory.md +18 -277
- data/docs/api/yard/HTM/PropositionError.md +18 -0
- data/docs/api/yard/HTM/PropositionService.md +66 -0
- data/docs/api/yard/HTM/QueryCache.md +88 -0
- data/docs/api/yard/HTM/RobotGroup.md +481 -0
- data/docs/api/yard/HTM/SqlBuilder.md +108 -0
- data/docs/api/yard/HTM/TagService.md +4 -0
- data/docs/api/yard/HTM/Telemetry/NullInstrument.md +13 -0
- data/docs/api/yard/HTM/Telemetry/NullMeter.md +15 -0
- data/docs/api/yard/HTM/Telemetry.md +109 -0
- data/docs/api/yard/HTM/WorkingMemoryChannel.md +176 -0
- data/docs/api/yard/HTM.md +11 -23
- data/docs/api/yard/index.csv +102 -25
- data/docs/api/yard-reference.md +8 -0
- data/docs/assets/images/multi-provider-failover.svg +51 -0
- data/docs/assets/images/robot-group-architecture.svg +65 -0
- data/docs/database/README.md +3 -3
- data/docs/database/public.file_sources.svg +29 -21
- data/docs/database/public.node_tags.md +2 -0
- data/docs/database/public.node_tags.svg +53 -41
- data/docs/database/public.nodes.md +2 -0
- data/docs/database/public.nodes.svg +52 -40
- data/docs/database/public.robot_nodes.md +2 -0
- data/docs/database/public.robot_nodes.svg +30 -22
- data/docs/database/public.robots.svg +16 -12
- data/docs/database/public.tags.md +3 -0
- data/docs/database/public.tags.svg +41 -33
- data/docs/database/schema.json +66 -0
- data/docs/database/schema.svg +60 -48
- data/docs/development/index.md +13 -0
- data/docs/development/rake-tasks.md +1068 -0
- data/docs/getting-started/quick-start.md +144 -155
- data/docs/guides/adding-memories.md +2 -3
- data/docs/guides/context-assembly.md +185 -184
- data/docs/guides/getting-started.md +154 -148
- data/docs/guides/index.md +7 -0
- data/docs/guides/long-term-memory.md +60 -92
- data/docs/guides/mcp-server.md +617 -0
- data/docs/guides/multi-robot.md +249 -345
- data/docs/guides/recalling-memories.md +153 -163
- data/docs/guides/robot-groups.md +604 -0
- data/docs/guides/search-strategies.md +61 -58
- data/docs/guides/working-memory.md +103 -136
- data/docs/index.md +30 -26
- data/examples/robot_groups/robot_worker.rb +1 -2
- data/examples/robot_groups/same_process.rb +1 -4
- data/lib/htm/robot_group.rb +721 -0
- data/lib/htm/version.rb +1 -1
- data/lib/htm/working_memory_channel.rb +250 -0
- data/lib/htm.rb +2 -0
- data/mkdocs.yml +2 -0
- metadata +18 -9
- data/db/migrate/00009_add_working_memory_to_robot_nodes.rb +0 -12
- data/db/migrate/00010_add_soft_delete_to_associations.rb +0 -29
- data/db/migrate/00011_add_performance_indexes.rb +0 -21
- data/db/migrate/00012_add_tags_trigram_index.rb +0 -18
- data/db/migrate/00013_enable_lz4_compression.rb +0 -43
- data/examples/robot_groups/lib/robot_group.rb +0 -419
- data/examples/robot_groups/lib/working_memory_channel.rb +0 -140
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
# MCP Server Guide
|
|
2
|
+
|
|
3
|
+
HTM includes a Model Context Protocol (MCP) server that exposes memory capabilities to AI assistants. This enables tools like Claude Desktop, Claude Code, and AIA to store, recall, and manage memories through a standardized protocol.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The MCP server (`bin/htm_mcp.rb`) uses [FastMCP](https://github.com/yjacket/fast-mcp) to expose HTM's memory operations as MCP tools and resources. Any MCP-compatible client can connect to the server and use HTM's memory capabilities.
|
|
8
|
+
|
|
9
|
+
### Key Features
|
|
10
|
+
|
|
11
|
+
- **Session-based robot identity**: Each client session has its own robot identity
|
|
12
|
+
- **Full HTM API access**: Remember, recall, forget, restore, and manage tags
|
|
13
|
+
- **Session restore**: Restore previous session context from working memory
|
|
14
|
+
- **Fuzzy search**: Typo-tolerant tag and topic search
|
|
15
|
+
- **Resource access**: Query statistics, tag hierarchy, and recent memories
|
|
16
|
+
|
|
17
|
+
## Prerequisites
|
|
18
|
+
|
|
19
|
+
Before using the MCP server, ensure you have:
|
|
20
|
+
|
|
21
|
+
1. **HTM installed and configured**
|
|
22
|
+
```bash
|
|
23
|
+
gem install htm
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
2. **PostgreSQL database set up**
|
|
27
|
+
```bash
|
|
28
|
+
export HTM_DBURL="postgresql://user@localhost:5432/htm_development"
|
|
29
|
+
rake htm:db:setup
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
3. **Ollama running** (for embeddings and tag extraction)
|
|
33
|
+
```bash
|
|
34
|
+
ollama serve
|
|
35
|
+
ollama pull nomic-embed-text
|
|
36
|
+
ollama pull llama3
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Starting the Server
|
|
40
|
+
|
|
41
|
+
The MCP server uses STDIO transport which is compatible with most MCP clients. When you do a `gem install htm` the htm_mcp.rb executable is placed on your $PATH.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
htm_mcp.rb
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The server logs to STDERR to avoid corrupting the JSON-RPC protocol on STDOUT.
|
|
48
|
+
|
|
49
|
+
## Tools Reference
|
|
50
|
+
|
|
51
|
+
### SetRobotTool
|
|
52
|
+
|
|
53
|
+
Set the robot identity for this session. **Call this first** to establish your robot name.
|
|
54
|
+
|
|
55
|
+
**Parameters:**
|
|
56
|
+
- `name` (String, required): The robot name (will be created if it doesn't exist)
|
|
57
|
+
|
|
58
|
+
**Returns:**
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"success": true,
|
|
62
|
+
"robot_id": 5,
|
|
63
|
+
"robot_name": "my-assistant",
|
|
64
|
+
"node_count": 12,
|
|
65
|
+
"message": "Robot 'my-assistant' is now active for this session"
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Example usage:**
|
|
70
|
+
```
|
|
71
|
+
Set robot name to "research-bot"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### GetRobotTool
|
|
77
|
+
|
|
78
|
+
Get information about the current robot for this session.
|
|
79
|
+
|
|
80
|
+
**Parameters:** None
|
|
81
|
+
|
|
82
|
+
**Returns:**
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"success": true,
|
|
86
|
+
"robot_id": 5,
|
|
87
|
+
"robot_name": "my-assistant",
|
|
88
|
+
"initialized": true,
|
|
89
|
+
"memory_summary": {
|
|
90
|
+
"total_nodes": 150,
|
|
91
|
+
"working_memory_nodes": 25
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
### GetWorkingMemoryTool
|
|
99
|
+
|
|
100
|
+
Get all working memory contents for the current robot. Use this to restore a previous session.
|
|
101
|
+
|
|
102
|
+
**Parameters:** None
|
|
103
|
+
|
|
104
|
+
**Returns:**
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"success": true,
|
|
108
|
+
"robot_id": 5,
|
|
109
|
+
"robot_name": "my-assistant",
|
|
110
|
+
"count": 3,
|
|
111
|
+
"working_memory": [
|
|
112
|
+
{
|
|
113
|
+
"id": 123,
|
|
114
|
+
"content": "User prefers dark mode",
|
|
115
|
+
"tags": ["user:preference", "ui"],
|
|
116
|
+
"remember_count": 5,
|
|
117
|
+
"last_remembered_at": "2024-01-15T10:30:00Z",
|
|
118
|
+
"created_at": "2024-01-10T08:00:00Z"
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### RememberTool
|
|
127
|
+
|
|
128
|
+
Store information in HTM long-term memory with optional tags.
|
|
129
|
+
|
|
130
|
+
**Parameters:**
|
|
131
|
+
- `content` (String, required): The content to remember
|
|
132
|
+
- `tags` (Array<String>, optional): Tags for categorization (e.g., `["database:postgresql", "config"]`)
|
|
133
|
+
- `metadata` (Hash, optional): Key-value metadata pairs
|
|
134
|
+
|
|
135
|
+
**Returns:**
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"success": true,
|
|
139
|
+
"node_id": 456,
|
|
140
|
+
"robot_id": 5,
|
|
141
|
+
"robot_name": "my-assistant",
|
|
142
|
+
"content": "PostgreSQL uses pgvector for similarity search",
|
|
143
|
+
"tags": ["database:postgresql", "vector-search"],
|
|
144
|
+
"created_at": "2024-01-15T14:30:00Z"
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Example usage:**
|
|
149
|
+
```
|
|
150
|
+
Remember that the user prefers Ruby over Python for scripting tasks
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
### RecallTool
|
|
156
|
+
|
|
157
|
+
Search and retrieve memories from HTM using semantic, full-text, or hybrid search.
|
|
158
|
+
|
|
159
|
+
**Parameters:**
|
|
160
|
+
- `query` (String, required): Search query (natural language or keywords)
|
|
161
|
+
- `limit` (Integer, optional): Maximum results (default: 10)
|
|
162
|
+
- `strategy` (String, optional): Search strategy - `"vector"`, `"fulltext"`, or `"hybrid"` (default: `"hybrid"`)
|
|
163
|
+
- `timeframe` (String, optional): Time filter - `"today"`, `"this week"`, `"this month"`, or ISO8601 date range
|
|
164
|
+
|
|
165
|
+
**Returns:**
|
|
166
|
+
```json
|
|
167
|
+
{
|
|
168
|
+
"success": true,
|
|
169
|
+
"query": "database decisions",
|
|
170
|
+
"strategy": "hybrid",
|
|
171
|
+
"robot_name": "my-assistant",
|
|
172
|
+
"count": 3,
|
|
173
|
+
"results": [
|
|
174
|
+
{
|
|
175
|
+
"id": 123,
|
|
176
|
+
"content": "Decided to use PostgreSQL for vector search",
|
|
177
|
+
"tags": ["database:postgresql", "decision"],
|
|
178
|
+
"created_at": "2024-01-10T08:00:00Z",
|
|
179
|
+
"score": 0.89
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Example usage:**
|
|
186
|
+
```
|
|
187
|
+
Recall what we discussed about database architecture last week
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
### ForgetTool
|
|
193
|
+
|
|
194
|
+
Soft-delete a memory from HTM (can be restored later).
|
|
195
|
+
|
|
196
|
+
**Parameters:**
|
|
197
|
+
- `node_id` (Integer, required): The ID of the node to forget
|
|
198
|
+
|
|
199
|
+
**Returns:**
|
|
200
|
+
```json
|
|
201
|
+
{
|
|
202
|
+
"success": true,
|
|
203
|
+
"node_id": 123,
|
|
204
|
+
"robot_name": "my-assistant",
|
|
205
|
+
"message": "Memory soft-deleted. Use restore to recover."
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
### RestoreTool
|
|
212
|
+
|
|
213
|
+
Restore a soft-deleted memory.
|
|
214
|
+
|
|
215
|
+
**Parameters:**
|
|
216
|
+
- `node_id` (Integer, required): The ID of the node to restore
|
|
217
|
+
|
|
218
|
+
**Returns:**
|
|
219
|
+
```json
|
|
220
|
+
{
|
|
221
|
+
"success": true,
|
|
222
|
+
"node_id": 123,
|
|
223
|
+
"robot_name": "my-assistant",
|
|
224
|
+
"message": "Memory restored successfully"
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
### ListTagsTool
|
|
231
|
+
|
|
232
|
+
List all tags in HTM, optionally filtered by prefix.
|
|
233
|
+
|
|
234
|
+
**Parameters:**
|
|
235
|
+
- `prefix` (String, optional): Filter tags by prefix (e.g., `"database"` returns `"database:postgresql"`, etc.)
|
|
236
|
+
|
|
237
|
+
**Returns:**
|
|
238
|
+
```json
|
|
239
|
+
{
|
|
240
|
+
"success": true,
|
|
241
|
+
"prefix": "database",
|
|
242
|
+
"count": 5,
|
|
243
|
+
"tags": [
|
|
244
|
+
{ "name": "database", "node_count": 15 },
|
|
245
|
+
{ "name": "database:postgresql", "node_count": 10 },
|
|
246
|
+
{ "name": "database:postgresql:extensions", "node_count": 3 }
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
### SearchTagsTool
|
|
254
|
+
|
|
255
|
+
Search for tags using fuzzy matching (typo-tolerant). Use this when you're unsure of exact tag names.
|
|
256
|
+
|
|
257
|
+
**Parameters:**
|
|
258
|
+
- `query` (String, required): Search query (can contain typos, e.g., `"postgrsql"` finds `"database:postgresql"`)
|
|
259
|
+
- `limit` (Integer, optional): Maximum results (default: 20)
|
|
260
|
+
- `min_similarity` (Float, optional): Minimum similarity threshold 0.0-1.0 (default: 0.3, lower = more fuzzy)
|
|
261
|
+
|
|
262
|
+
**Returns:**
|
|
263
|
+
```json
|
|
264
|
+
{
|
|
265
|
+
"success": true,
|
|
266
|
+
"query": "postgrsql",
|
|
267
|
+
"min_similarity": 0.3,
|
|
268
|
+
"count": 2,
|
|
269
|
+
"tags": [
|
|
270
|
+
{ "name": "database:postgresql", "similarity": 0.857, "node_count": 10 },
|
|
271
|
+
{ "name": "database:postgresql:extensions", "similarity": 0.714, "node_count": 3 }
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
### FindByTopicTool
|
|
279
|
+
|
|
280
|
+
Find memory nodes by topic/tag with optional fuzzy matching for typo tolerance.
|
|
281
|
+
|
|
282
|
+
**Parameters:**
|
|
283
|
+
- `topic` (String, required): Topic or tag to search for
|
|
284
|
+
- `fuzzy` (Boolean, optional): Enable fuzzy matching for typo tolerance (default: false)
|
|
285
|
+
- `exact` (Boolean, optional): Require exact tag match (default: false, uses prefix matching)
|
|
286
|
+
- `limit` (Integer, optional): Maximum results (default: 20)
|
|
287
|
+
- `min_similarity` (Float, optional): Minimum similarity for fuzzy mode (default: 0.3)
|
|
288
|
+
|
|
289
|
+
**Returns:**
|
|
290
|
+
```json
|
|
291
|
+
{
|
|
292
|
+
"success": true,
|
|
293
|
+
"topic": "database:postgresql",
|
|
294
|
+
"fuzzy": false,
|
|
295
|
+
"exact": false,
|
|
296
|
+
"count": 5,
|
|
297
|
+
"results": [
|
|
298
|
+
{
|
|
299
|
+
"id": 123,
|
|
300
|
+
"content": "PostgreSQL uses pgvector for similarity search...",
|
|
301
|
+
"tags": ["database:postgresql", "vector-search"],
|
|
302
|
+
"created_at": "2024-01-10T08:00:00Z"
|
|
303
|
+
}
|
|
304
|
+
]
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
### StatsTool
|
|
311
|
+
|
|
312
|
+
Get statistics about HTM memory usage.
|
|
313
|
+
|
|
314
|
+
**Parameters:** None
|
|
315
|
+
|
|
316
|
+
**Returns:**
|
|
317
|
+
```json
|
|
318
|
+
{
|
|
319
|
+
"success": true,
|
|
320
|
+
"current_robot": {
|
|
321
|
+
"name": "my-assistant",
|
|
322
|
+
"id": 5,
|
|
323
|
+
"memory_summary": { "total_nodes": 150, "working_memory_nodes": 25 }
|
|
324
|
+
},
|
|
325
|
+
"statistics": {
|
|
326
|
+
"nodes": {
|
|
327
|
+
"active": 500,
|
|
328
|
+
"deleted": 20,
|
|
329
|
+
"with_embeddings": 495,
|
|
330
|
+
"with_tags": 480
|
|
331
|
+
},
|
|
332
|
+
"tags": { "total": 75 },
|
|
333
|
+
"robots": { "total": 3 }
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
## Resources Reference
|
|
339
|
+
|
|
340
|
+
### htm://statistics
|
|
341
|
+
|
|
342
|
+
Memory statistics as JSON.
|
|
343
|
+
|
|
344
|
+
```json
|
|
345
|
+
{
|
|
346
|
+
"total_nodes": 500,
|
|
347
|
+
"total_tags": 75,
|
|
348
|
+
"total_robots": 3,
|
|
349
|
+
"current_robot": "my-assistant",
|
|
350
|
+
"robot_id": 5,
|
|
351
|
+
"robot_initialized": true,
|
|
352
|
+
"embedding_provider": "ollama",
|
|
353
|
+
"embedding_model": "nomic-embed-text"
|
|
354
|
+
}
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### htm://tags/hierarchy
|
|
358
|
+
|
|
359
|
+
Tag hierarchy as a text tree:
|
|
360
|
+
|
|
361
|
+
```
|
|
362
|
+
database
|
|
363
|
+
├── postgresql
|
|
364
|
+
│ ├── extensions
|
|
365
|
+
│ └── performance
|
|
366
|
+
└── mysql
|
|
367
|
+
ai
|
|
368
|
+
├── llm
|
|
369
|
+
│ ├── embeddings
|
|
370
|
+
│ └── prompts
|
|
371
|
+
└── rag
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
### htm://memories/recent
|
|
375
|
+
|
|
376
|
+
Last 20 memories as JSON array.
|
|
377
|
+
|
|
378
|
+
## Client Configuration
|
|
379
|
+
|
|
380
|
+
### Claude Desktop
|
|
381
|
+
|
|
382
|
+
Add to `~/.config/claude/claude_desktop_config.json` (Linux/macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
|
|
383
|
+
|
|
384
|
+
```json
|
|
385
|
+
{
|
|
386
|
+
"mcpServers": {
|
|
387
|
+
"htm-memory": {
|
|
388
|
+
"command": "ruby",
|
|
389
|
+
"args": ["/absolute/path/to/htm/bin/htm_mcp.rb"],
|
|
390
|
+
"env": {
|
|
391
|
+
"HTM_DBURL": "postgresql://user@localhost:5432/htm_development"
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
After adding the configuration:
|
|
399
|
+
1. Restart Claude Desktop
|
|
400
|
+
2. Look for the HTM tools in the tools menu (hammer icon)
|
|
401
|
+
3. Start a conversation and ask Claude to remember something
|
|
402
|
+
|
|
403
|
+
### Claude Code
|
|
404
|
+
|
|
405
|
+
Add to `~/.claude/claude_code_config.json`:
|
|
406
|
+
|
|
407
|
+
```json
|
|
408
|
+
{
|
|
409
|
+
"mcpServers": {
|
|
410
|
+
"htm-memory": {
|
|
411
|
+
"command": "ruby",
|
|
412
|
+
"args": ["/absolute/path/to/htm/bin/htm_mcp.rb"],
|
|
413
|
+
"env": {
|
|
414
|
+
"HTM_DBURL": "postgresql://user@localhost:5432/htm_development"
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
After adding the configuration:
|
|
422
|
+
1. Restart Claude Code or run `/mcp` to refresh
|
|
423
|
+
2. The HTM tools will appear with the `mcp__htm-memory__` prefix
|
|
424
|
+
3. Claude Code will automatically use HTM tools when appropriate
|
|
425
|
+
|
|
426
|
+
**Example prompts for Claude Code:**
|
|
427
|
+
```
|
|
428
|
+
Remember that this project uses PostgreSQL with pgvector for similarity search
|
|
429
|
+
|
|
430
|
+
Recall what architecture decisions we made for this project
|
|
431
|
+
|
|
432
|
+
What tags do we have related to database configuration?
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### AIA (AI Assistant)
|
|
436
|
+
|
|
437
|
+
Add to `~/.config/aia/config.yml`:
|
|
438
|
+
|
|
439
|
+
```yaml
|
|
440
|
+
mcp_servers:
|
|
441
|
+
htm-memory:
|
|
442
|
+
command: ruby
|
|
443
|
+
args:
|
|
444
|
+
- /absolute/path/to/htm/bin/htm_mcp.rb
|
|
445
|
+
env:
|
|
446
|
+
HTM_DBURL: postgresql://user@localhost:5432/htm_development
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
For project-specific configuration, add to `.aia/config.yml` in your project root:
|
|
450
|
+
|
|
451
|
+
```yaml
|
|
452
|
+
mcp_servers:
|
|
453
|
+
htm-memory:
|
|
454
|
+
command: ruby
|
|
455
|
+
args:
|
|
456
|
+
- /absolute/path/to/htm/bin/htm_mcp.rb
|
|
457
|
+
env:
|
|
458
|
+
HTM_DBURL: postgresql://user@localhost:5432/my_project_htm
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
## Usage Examples
|
|
462
|
+
|
|
463
|
+
### Basic Workflow
|
|
464
|
+
|
|
465
|
+
1. **Set your robot identity** (do this first in each session):
|
|
466
|
+
```
|
|
467
|
+
Set my robot name to "project-assistant"
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
2. **Store information as you work**:
|
|
471
|
+
```
|
|
472
|
+
Remember that we decided to use Redis for caching with a 1-hour TTL
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
3. **Recall relevant context**:
|
|
476
|
+
```
|
|
477
|
+
What caching decisions have we made?
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
4. **Browse by topic**:
|
|
481
|
+
```
|
|
482
|
+
Show me all memories tagged with "architecture"
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### Session Restoration
|
|
486
|
+
|
|
487
|
+
When starting a new session, you can restore context from a previous session:
|
|
488
|
+
|
|
489
|
+
1. **Set robot identity** (same name as before):
|
|
490
|
+
```
|
|
491
|
+
Set robot name to "project-assistant"
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
2. **Get working memory**:
|
|
495
|
+
```
|
|
496
|
+
Get my working memory contents
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
3. **Review and continue**:
|
|
500
|
+
The AI assistant will have access to your previous session's context.
|
|
501
|
+
|
|
502
|
+
### Project-Specific Memory
|
|
503
|
+
|
|
504
|
+
Use different robot names for different projects:
|
|
505
|
+
|
|
506
|
+
```
|
|
507
|
+
# For project A
|
|
508
|
+
Set robot name to "project-a-assistant"
|
|
509
|
+
Remember that project A uses React with TypeScript
|
|
510
|
+
|
|
511
|
+
# For project B
|
|
512
|
+
Set robot name to "project-b-assistant"
|
|
513
|
+
Remember that project B uses Vue with JavaScript
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
Each robot has its own working memory but shares the global long-term memory (hive mind).
|
|
517
|
+
|
|
518
|
+
### Searching with Typo Tolerance
|
|
519
|
+
|
|
520
|
+
Use fuzzy search when you're not sure of exact tag names:
|
|
521
|
+
|
|
522
|
+
```
|
|
523
|
+
Search for tags similar to "postgrsql"
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
This will find `database:postgresql` even with the typo.
|
|
527
|
+
|
|
528
|
+
## Session Management
|
|
529
|
+
|
|
530
|
+
### How Sessions Work
|
|
531
|
+
|
|
532
|
+
1. **Per-client isolation**: Each MCP client spawns its own server process
|
|
533
|
+
2. **Robot identity**: The `SetRobotTool` establishes which robot you're using
|
|
534
|
+
3. **Working memory**: Each robot has its own working memory tracked in the database
|
|
535
|
+
4. **Hive mind**: All robots share the same long-term memory
|
|
536
|
+
|
|
537
|
+
### Best Practices
|
|
538
|
+
|
|
539
|
+
1. **Always set robot identity first**: Call `SetRobotTool` at the start of each session
|
|
540
|
+
2. **Use consistent robot names**: Use the same name to maintain continuity
|
|
541
|
+
3. **Restore previous sessions**: Use `GetWorkingMemoryTool` to restore context
|
|
542
|
+
4. **Use descriptive robot names**: e.g., `"code-review-assistant"`, `"project-x-helper"`
|
|
543
|
+
|
|
544
|
+
## Troubleshooting
|
|
545
|
+
|
|
546
|
+
### Server Won't Start
|
|
547
|
+
|
|
548
|
+
**Error: `fast-mcp gem not found`**
|
|
549
|
+
```bash
|
|
550
|
+
gem install fast-mcp
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
**Error: `HTM_DBURL not set`**
|
|
554
|
+
```bash
|
|
555
|
+
export HTM_DBURL="postgresql://user@localhost:5432/htm_development"
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
### Database Connection Issues
|
|
559
|
+
|
|
560
|
+
**Error: `could not connect to server`**
|
|
561
|
+
1. Verify PostgreSQL is running
|
|
562
|
+
2. Check your connection URL
|
|
563
|
+
3. Test with: `rake htm:db:test`
|
|
564
|
+
|
|
565
|
+
**Error: `extension "vector" does not exist`**
|
|
566
|
+
```bash
|
|
567
|
+
# Install pgvector extension
|
|
568
|
+
psql htm_development -c "CREATE EXTENSION IF NOT EXISTS vector;"
|
|
569
|
+
psql htm_development -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
### Client Can't Connect
|
|
573
|
+
|
|
574
|
+
**Claude Desktop doesn't show HTM tools:**
|
|
575
|
+
1. Verify the config file path is correct for your OS
|
|
576
|
+
2. Check that the path to `htm_mcp.rb` is absolute
|
|
577
|
+
3. Restart Claude Desktop completely
|
|
578
|
+
4. Check Claude Desktop logs for errors
|
|
579
|
+
|
|
580
|
+
**Claude Code doesn't recognize tools:**
|
|
581
|
+
1. Run `/mcp` to refresh MCP connections
|
|
582
|
+
2. Verify config is valid JSON
|
|
583
|
+
3. Check that HTM_DBURL is set in the env section
|
|
584
|
+
|
|
585
|
+
### Embedding/Tag Errors
|
|
586
|
+
|
|
587
|
+
**Error: `Connection refused` (Ollama)**
|
|
588
|
+
1. Start Ollama: `ollama serve`
|
|
589
|
+
2. Pull required models:
|
|
590
|
+
```bash
|
|
591
|
+
ollama pull nomic-embed-text
|
|
592
|
+
ollama pull llama3
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
### Debugging
|
|
596
|
+
|
|
597
|
+
Enable verbose logging by checking STDERR output:
|
|
598
|
+
```bash
|
|
599
|
+
ruby bin/htm_mcp.rb 2>&1 | tee mcp_debug.log
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
The server logs all tool calls and errors to STDERR.
|
|
603
|
+
|
|
604
|
+
## Environment Variables
|
|
605
|
+
|
|
606
|
+
| Variable | Description | Required |
|
|
607
|
+
|----------|-------------|----------|
|
|
608
|
+
| `HTM_DBURL` | PostgreSQL connection URL | Yes |
|
|
609
|
+
| `OLLAMA_URL` | Ollama server URL (default: `http://localhost:11434`) | No |
|
|
610
|
+
| `HTM_ROBOT_NAME` | Default robot name for clients | No |
|
|
611
|
+
|
|
612
|
+
## Next Steps
|
|
613
|
+
|
|
614
|
+
- [Getting Started](getting-started.md) - HTM basics
|
|
615
|
+
- [Adding Memories](adding-memories.md) - Learn about tags and metadata
|
|
616
|
+
- [Recalling Memories](recalling-memories.md) - Search strategies
|
|
617
|
+
- [Multi-Robot Systems](multi-robot.md) - Working with multiple robots
|