htm 0.0.15 → 0.0.18
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/.architecture/decisions/adrs/001-use-postgresql-timescaledb-storage.md +1 -1
- data/.architecture/decisions/adrs/011-database-side-embedding-generation-with-pgai.md +4 -4
- data/.architecture/decisions/adrs/012-llm-driven-ontology-topic-extraction.md +1 -1
- data/.envrc +12 -24
- data/.irbrc +7 -7
- data/.tbls.yml +2 -2
- data/CHANGELOG.md +138 -0
- data/README.md +97 -1592
- data/Rakefile +8 -3
- data/SETUP.md +12 -12
- data/bin/htm_mcp +27 -0
- data/db/seed_data/README.md +2 -2
- data/db/seeds.rb +2 -2
- data/docs/api/database.md +37 -37
- data/docs/api/htm.md +1 -1
- data/docs/api/yard/HTM/ActiveRecordConfig.md +2 -2
- data/docs/api/yard/HTM/Configuration.md +26 -15
- data/docs/api/yard/HTM/Database.md +7 -8
- data/docs/api/yard/HTM/JobAdapter.md +1 -1
- data/docs/api/yard/HTM/Railtie.md +2 -2
- data/docs/architecture/adrs/001-postgresql-timescaledb.md +1 -1
- data/docs/architecture/adrs/011-pgai-integration.md +4 -4
- data/docs/database_rake_tasks.md +5 -5
- data/docs/development/rake-tasks.md +11 -11
- data/docs/development/setup.md +21 -21
- data/docs/development/testing.md +1 -1
- data/docs/getting-started/installation.md +51 -31
- data/docs/getting-started/quick-start.md +12 -12
- data/docs/guides/getting-started.md +2 -2
- data/docs/guides/long-term-memory.md +1 -1
- data/docs/guides/mcp-server.md +464 -29
- data/docs/guides/robot-groups.md +8 -8
- data/docs/index.md +4 -4
- data/docs/multi_framework_support.md +10 -10
- data/docs/setup_local_database.md +19 -19
- data/docs/using_rake_tasks_in_your_app.md +14 -14
- data/examples/README.md +50 -6
- data/examples/basic_usage.rb +31 -21
- data/examples/cli_app/README.md +8 -8
- data/examples/cli_app/htm_cli.rb +5 -5
- data/examples/config_file_example/README.md +256 -0
- data/examples/config_file_example/config/htm.local.yml +34 -0
- data/examples/config_file_example/custom_config.yml +22 -0
- data/examples/config_file_example/show_config.rb +125 -0
- data/examples/custom_llm_configuration.rb +7 -7
- data/examples/example_app/Rakefile +2 -2
- data/examples/example_app/app.rb +8 -8
- data/examples/file_loader_usage.rb +9 -9
- data/examples/mcp_client.rb +7 -7
- data/examples/rails_app/.gitignore +2 -0
- data/examples/rails_app/Gemfile +22 -0
- data/examples/rails_app/Gemfile.lock +430 -0
- data/examples/rails_app/Procfile.dev +1 -0
- data/examples/rails_app/README.md +98 -0
- data/examples/rails_app/Rakefile +5 -0
- data/examples/rails_app/app/assets/stylesheets/application.css +83 -0
- data/examples/rails_app/app/assets/stylesheets/inter-font.css +6 -0
- data/examples/rails_app/app/controllers/application_controller.rb +19 -0
- data/examples/rails_app/app/controllers/dashboard_controller.rb +27 -0
- data/examples/rails_app/app/controllers/files_controller.rb +205 -0
- data/examples/rails_app/app/controllers/memories_controller.rb +102 -0
- data/examples/rails_app/app/controllers/robots_controller.rb +44 -0
- data/examples/rails_app/app/controllers/search_controller.rb +46 -0
- data/examples/rails_app/app/controllers/tags_controller.rb +30 -0
- data/examples/rails_app/app/javascript/application.js +4 -0
- data/examples/rails_app/app/javascript/controllers/application.js +9 -0
- data/examples/rails_app/app/javascript/controllers/index.js +6 -0
- data/examples/rails_app/app/views/dashboard/index.html.erb +123 -0
- data/examples/rails_app/app/views/files/index.html.erb +108 -0
- data/examples/rails_app/app/views/files/new.html.erb +321 -0
- data/examples/rails_app/app/views/files/show.html.erb +130 -0
- data/examples/rails_app/app/views/layouts/application.html.erb +124 -0
- data/examples/rails_app/app/views/memories/_memory_card.html.erb +51 -0
- data/examples/rails_app/app/views/memories/deleted.html.erb +62 -0
- data/examples/rails_app/app/views/memories/edit.html.erb +35 -0
- data/examples/rails_app/app/views/memories/index.html.erb +81 -0
- data/examples/rails_app/app/views/memories/new.html.erb +71 -0
- data/examples/rails_app/app/views/memories/show.html.erb +126 -0
- data/examples/rails_app/app/views/robots/index.html.erb +106 -0
- data/examples/rails_app/app/views/robots/new.html.erb +36 -0
- data/examples/rails_app/app/views/robots/show.html.erb +79 -0
- data/examples/rails_app/app/views/search/index.html.erb +184 -0
- data/examples/rails_app/app/views/shared/_navbar.html.erb +52 -0
- data/examples/rails_app/app/views/shared/_stat_card.html.erb +52 -0
- data/examples/rails_app/app/views/tags/index.html.erb +131 -0
- data/examples/rails_app/app/views/tags/show.html.erb +67 -0
- data/examples/rails_app/bin/dev +8 -0
- data/examples/rails_app/bin/rails +4 -0
- data/examples/rails_app/bin/rake +4 -0
- data/examples/rails_app/config/application.rb +33 -0
- data/examples/rails_app/config/boot.rb +5 -0
- data/examples/rails_app/config/database.yml +15 -0
- data/examples/rails_app/config/environment.rb +5 -0
- data/examples/rails_app/config/importmap.rb +7 -0
- data/examples/rails_app/config/routes.rb +38 -0
- data/examples/rails_app/config/tailwind.config.js +35 -0
- data/examples/rails_app/config.ru +5 -0
- data/examples/rails_app/log/.keep +0 -0
- data/examples/rails_app/tmp/local_secret.txt +1 -0
- data/examples/robot_groups/multi_process.rb +5 -5
- data/examples/robot_groups/robot_worker.rb +5 -5
- data/examples/robot_groups/same_process.rb +9 -9
- data/examples/sinatra_app/app.rb +1 -1
- data/examples/timeframe_demo.rb +1 -1
- data/lib/htm/active_record_config.rb +12 -28
- data/lib/htm/circuit_breaker.rb +0 -2
- data/lib/htm/config/defaults.yml +246 -0
- data/lib/htm/config.rb +888 -0
- data/lib/htm/database.rb +26 -33
- data/lib/htm/embedding_service.rb +0 -4
- data/lib/htm/integrations/sinatra.rb +3 -7
- data/lib/htm/job_adapter.rb +1 -15
- data/lib/htm/jobs/generate_embedding_job.rb +1 -7
- data/lib/htm/jobs/generate_propositions_job.rb +2 -12
- data/lib/htm/jobs/generate_tags_job.rb +1 -8
- data/lib/htm/loaders/defaults_loader.rb +143 -0
- data/lib/htm/loaders/xdg_config_loader.rb +116 -0
- data/lib/htm/mcp/cli.rb +475 -0
- data/lib/htm/mcp/group_tools.rb +476 -0
- data/lib/htm/mcp/resources.rb +89 -0
- data/lib/htm/mcp/server.rb +98 -0
- data/lib/htm/mcp/tools.rb +488 -0
- data/lib/htm/models/file_source.rb +5 -3
- data/lib/htm/proposition_service.rb +2 -12
- data/lib/htm/railtie.rb +3 -8
- data/lib/htm/tag_service.rb +1 -8
- data/lib/htm/tasks.rb +7 -4
- data/lib/htm/version.rb +1 -1
- data/lib/htm.rb +124 -5
- data/lib/tasks/htm.rake +6 -9
- metadata +81 -6
- data/bin/htm_mcp.rb +0 -621
- data/config/database.yml +0 -74
- data/lib/htm/configuration.rb +0 -766
data/docs/guides/mcp-server.md
CHANGED
|
@@ -4,7 +4,7 @@ HTM includes a Model Context Protocol (MCP) server that exposes memory capabilit
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
The MCP server (`bin/htm_mcp
|
|
7
|
+
The MCP server (`bin/htm_mcp`) 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
8
|
|
|
9
9
|
### Key Features
|
|
10
10
|
|
|
@@ -13,6 +13,7 @@ The MCP server (`bin/htm_mcp.rb`) uses [FastMCP](https://github.com/yjacket/fast
|
|
|
13
13
|
- **Session restore**: Restore previous session context from working memory
|
|
14
14
|
- **Fuzzy search**: Typo-tolerant tag and topic search
|
|
15
15
|
- **Resource access**: Query statistics, tag hierarchy, and recent memories
|
|
16
|
+
- **Robot Groups (High-Availability)**: Coordinate multiple robots with shared working memory, failover, and real-time sync
|
|
16
17
|
|
|
17
18
|
## Prerequisites
|
|
18
19
|
|
|
@@ -25,8 +26,8 @@ Before using the MCP server, ensure you have:
|
|
|
25
26
|
|
|
26
27
|
2. **PostgreSQL database set up**
|
|
27
28
|
```bash
|
|
28
|
-
export
|
|
29
|
-
|
|
29
|
+
export HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_development"
|
|
30
|
+
htm_mcp setup
|
|
30
31
|
```
|
|
31
32
|
|
|
32
33
|
3. **Ollama running** (for embeddings and tag extraction)
|
|
@@ -38,14 +39,60 @@ Before using the MCP server, ensure you have:
|
|
|
38
39
|
|
|
39
40
|
## Starting the Server
|
|
40
41
|
|
|
41
|
-
The MCP server uses STDIO transport which is compatible with most MCP clients.
|
|
42
|
+
The MCP server uses STDIO transport which is compatible with most MCP clients. When you do a `gem install htm`, the `htm_mcp` executable is placed on your $PATH.
|
|
42
43
|
|
|
43
44
|
```bash
|
|
44
|
-
htm_mcp
|
|
45
|
+
htm_mcp
|
|
45
46
|
```
|
|
46
47
|
|
|
47
48
|
The server logs to STDERR to avoid corrupting the JSON-RPC protocol on STDOUT.
|
|
48
49
|
|
|
50
|
+
## CLI Commands
|
|
51
|
+
|
|
52
|
+
The `htm_mcp` executable includes management commands for database setup and diagnostics:
|
|
53
|
+
|
|
54
|
+
| Command | Description |
|
|
55
|
+
|---------|-------------|
|
|
56
|
+
| `htm_mcp` | Start the MCP server (default) |
|
|
57
|
+
| `htm_mcp server` | Start the MCP server (explicit) |
|
|
58
|
+
| `htm_mcp setup` | Initialize database schema and run migrations |
|
|
59
|
+
| `htm_mcp init` | Alias for setup |
|
|
60
|
+
| `htm_mcp verify` | Verify database connection, extensions, and migration status |
|
|
61
|
+
| `htm_mcp stats` | Show memory statistics (nodes, tags, robots, database size) |
|
|
62
|
+
| `htm_mcp version` | Show HTM version |
|
|
63
|
+
| `htm_mcp help` | Show help with all environment variables |
|
|
64
|
+
|
|
65
|
+
### First-Time Setup
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Set your database URL
|
|
69
|
+
export HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_development"
|
|
70
|
+
|
|
71
|
+
# Initialize the database
|
|
72
|
+
htm_mcp setup
|
|
73
|
+
|
|
74
|
+
# Verify everything is working
|
|
75
|
+
htm_mcp verify
|
|
76
|
+
|
|
77
|
+
# Check memory statistics
|
|
78
|
+
htm_mcp stats
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Migration Status
|
|
82
|
+
|
|
83
|
+
The `verify` command shows migration status with `+` (applied) and `-` (pending) indicators:
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
Migration Status
|
|
87
|
+
--------------------------------------------------------------------------------
|
|
88
|
+
+ 20250101000001_create_schema_migrations
|
|
89
|
+
+ 20250101000002_create_robots
|
|
90
|
+
+ 20250101000003_create_nodes
|
|
91
|
+
- 20250612000001_add_new_feature
|
|
92
|
+
--------------------------------------------------------------------------------
|
|
93
|
+
3 applied, 1 pending
|
|
94
|
+
```
|
|
95
|
+
|
|
49
96
|
## Tools Reference
|
|
50
97
|
|
|
51
98
|
### SetRobotTool
|
|
@@ -335,6 +382,291 @@ Get statistics about HTM memory usage.
|
|
|
335
382
|
}
|
|
336
383
|
```
|
|
337
384
|
|
|
385
|
+
## Robot Group Tools
|
|
386
|
+
|
|
387
|
+
Robot Groups enable high-availability configurations with multiple robots sharing working memory. Groups support active/passive roles, automatic failover, and real-time synchronization via PostgreSQL LISTEN/NOTIFY.
|
|
388
|
+
|
|
389
|
+
### CreateGroupTool
|
|
390
|
+
|
|
391
|
+
Create a new robot group with shared working memory.
|
|
392
|
+
|
|
393
|
+
**Parameters:**
|
|
394
|
+
- `name` (String, required): Unique name for the group
|
|
395
|
+
- `sync_interval` (Integer, optional): Sync interval in seconds (default: 30)
|
|
396
|
+
- `max_members` (Integer, optional): Maximum group members (default: 10)
|
|
397
|
+
- `token_budget` (Integer, optional): Shared working memory token limit (default: 4000)
|
|
398
|
+
|
|
399
|
+
**Returns:**
|
|
400
|
+
```json
|
|
401
|
+
{
|
|
402
|
+
"success": true,
|
|
403
|
+
"group_name": "research-team",
|
|
404
|
+
"sync_interval": 30,
|
|
405
|
+
"max_members": 10,
|
|
406
|
+
"token_budget": 4000,
|
|
407
|
+
"message": "Robot group 'research-team' created successfully"
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
### ListGroupsTool
|
|
414
|
+
|
|
415
|
+
List all active robot groups in the current MCP session.
|
|
416
|
+
|
|
417
|
+
**Parameters:** None
|
|
418
|
+
|
|
419
|
+
**Returns:**
|
|
420
|
+
```json
|
|
421
|
+
{
|
|
422
|
+
"success": true,
|
|
423
|
+
"count": 2,
|
|
424
|
+
"groups": [
|
|
425
|
+
{
|
|
426
|
+
"name": "research-team",
|
|
427
|
+
"member_count": 3,
|
|
428
|
+
"active_robot": "researcher-1"
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
"name": "support-team",
|
|
432
|
+
"member_count": 2,
|
|
433
|
+
"active_robot": "support-bot"
|
|
434
|
+
}
|
|
435
|
+
]
|
|
436
|
+
}
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
### GetGroupStatusTool
|
|
442
|
+
|
|
443
|
+
Get detailed status of a robot group.
|
|
444
|
+
|
|
445
|
+
**Parameters:**
|
|
446
|
+
- `name` (String, required): The group name
|
|
447
|
+
|
|
448
|
+
**Returns:**
|
|
449
|
+
```json
|
|
450
|
+
{
|
|
451
|
+
"success": true,
|
|
452
|
+
"group_name": "research-team",
|
|
453
|
+
"status": {
|
|
454
|
+
"active_robot": "researcher-1",
|
|
455
|
+
"member_count": 3,
|
|
456
|
+
"members": [
|
|
457
|
+
{ "name": "researcher-1", "role": "active", "last_seen": "2024-01-15T10:30:00Z" },
|
|
458
|
+
{ "name": "researcher-2", "role": "passive", "last_seen": "2024-01-15T10:29:55Z" },
|
|
459
|
+
{ "name": "researcher-3", "role": "passive", "last_seen": "2024-01-15T10:29:50Z" }
|
|
460
|
+
],
|
|
461
|
+
"working_memory_tokens": 2500,
|
|
462
|
+
"token_budget": 4000,
|
|
463
|
+
"sync_interval": 30
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
---
|
|
469
|
+
|
|
470
|
+
### JoinGroupTool
|
|
471
|
+
|
|
472
|
+
Add a robot to an existing group.
|
|
473
|
+
|
|
474
|
+
**Parameters:**
|
|
475
|
+
- `group_name` (String, required): The group to join
|
|
476
|
+
- `robot_name` (String, required): The robot name to add
|
|
477
|
+
- `role` (String, optional): `"active"` or `"passive"` (default: `"passive"`)
|
|
478
|
+
|
|
479
|
+
**Returns:**
|
|
480
|
+
```json
|
|
481
|
+
{
|
|
482
|
+
"success": true,
|
|
483
|
+
"group_name": "research-team",
|
|
484
|
+
"robot_name": "researcher-4",
|
|
485
|
+
"role": "passive",
|
|
486
|
+
"message": "Robot 'researcher-4' joined group 'research-team' as passive"
|
|
487
|
+
}
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
---
|
|
491
|
+
|
|
492
|
+
### LeaveGroupTool
|
|
493
|
+
|
|
494
|
+
Remove a robot from a group.
|
|
495
|
+
|
|
496
|
+
**Parameters:**
|
|
497
|
+
- `group_name` (String, required): The group to leave
|
|
498
|
+
- `robot_name` (String, required): The robot to remove
|
|
499
|
+
|
|
500
|
+
**Returns:**
|
|
501
|
+
```json
|
|
502
|
+
{
|
|
503
|
+
"success": true,
|
|
504
|
+
"group_name": "research-team",
|
|
505
|
+
"robot_name": "researcher-4",
|
|
506
|
+
"message": "Robot 'researcher-4' left group 'research-team'"
|
|
507
|
+
}
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
### GroupRememberTool
|
|
513
|
+
|
|
514
|
+
Store memory shared across all group members. Only the active robot can write to group memory.
|
|
515
|
+
|
|
516
|
+
**Parameters:**
|
|
517
|
+
- `group_name` (String, required): The target group
|
|
518
|
+
- `content` (String, required): The content to remember
|
|
519
|
+
- `tags` (Array<String>, optional): Tags for categorization
|
|
520
|
+
- `metadata` (Hash, optional): Key-value metadata
|
|
521
|
+
|
|
522
|
+
**Returns:**
|
|
523
|
+
```json
|
|
524
|
+
{
|
|
525
|
+
"success": true,
|
|
526
|
+
"group_name": "research-team",
|
|
527
|
+
"node_id": 789,
|
|
528
|
+
"content": "Found relevant paper on embeddings",
|
|
529
|
+
"tags": ["research:papers", "ai:embeddings"],
|
|
530
|
+
"message": "Memory stored in group working memory"
|
|
531
|
+
}
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
---
|
|
535
|
+
|
|
536
|
+
### GroupRecallTool
|
|
537
|
+
|
|
538
|
+
Recall memories from a group's shared context.
|
|
539
|
+
|
|
540
|
+
**Parameters:**
|
|
541
|
+
- `group_name` (String, required): The target group
|
|
542
|
+
- `query` (String, required): Search query
|
|
543
|
+
- `limit` (Integer, optional): Maximum results (default: 10)
|
|
544
|
+
- `strategy` (String, optional): `"vector"`, `"fulltext"`, or `"hybrid"` (default: `"hybrid"`)
|
|
545
|
+
|
|
546
|
+
**Returns:**
|
|
547
|
+
```json
|
|
548
|
+
{
|
|
549
|
+
"success": true,
|
|
550
|
+
"group_name": "research-team",
|
|
551
|
+
"query": "embeddings",
|
|
552
|
+
"count": 3,
|
|
553
|
+
"results": [
|
|
554
|
+
{
|
|
555
|
+
"id": 789,
|
|
556
|
+
"content": "Found relevant paper on embeddings",
|
|
557
|
+
"tags": ["research:papers", "ai:embeddings"],
|
|
558
|
+
"score": 0.92
|
|
559
|
+
}
|
|
560
|
+
]
|
|
561
|
+
}
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
---
|
|
565
|
+
|
|
566
|
+
### GetGroupWorkingMemoryTool
|
|
567
|
+
|
|
568
|
+
Get a group's working memory contents.
|
|
569
|
+
|
|
570
|
+
**Parameters:**
|
|
571
|
+
- `group_name` (String, required): The target group
|
|
572
|
+
|
|
573
|
+
**Returns:**
|
|
574
|
+
```json
|
|
575
|
+
{
|
|
576
|
+
"success": true,
|
|
577
|
+
"group_name": "research-team",
|
|
578
|
+
"token_usage": 2500,
|
|
579
|
+
"token_budget": 4000,
|
|
580
|
+
"count": 15,
|
|
581
|
+
"working_memory": [
|
|
582
|
+
{
|
|
583
|
+
"id": 789,
|
|
584
|
+
"content": "Found relevant paper on embeddings",
|
|
585
|
+
"tags": ["research:papers"],
|
|
586
|
+
"added_at": "2024-01-15T10:30:00Z"
|
|
587
|
+
}
|
|
588
|
+
]
|
|
589
|
+
}
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
---
|
|
593
|
+
|
|
594
|
+
### PromoteRobotTool
|
|
595
|
+
|
|
596
|
+
Promote a passive robot to active role. The current active robot becomes passive.
|
|
597
|
+
|
|
598
|
+
**Parameters:**
|
|
599
|
+
- `group_name` (String, required): The target group
|
|
600
|
+
- `robot_name` (String, required): The robot to promote
|
|
601
|
+
|
|
602
|
+
**Returns:**
|
|
603
|
+
```json
|
|
604
|
+
{
|
|
605
|
+
"success": true,
|
|
606
|
+
"group_name": "research-team",
|
|
607
|
+
"promoted_robot": "researcher-2",
|
|
608
|
+
"previous_active": "researcher-1",
|
|
609
|
+
"message": "Robot 'researcher-2' is now active. 'researcher-1' is now passive."
|
|
610
|
+
}
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
---
|
|
614
|
+
|
|
615
|
+
### FailoverTool
|
|
616
|
+
|
|
617
|
+
Trigger failover to the next available robot in the group.
|
|
618
|
+
|
|
619
|
+
**Parameters:**
|
|
620
|
+
- `group_name` (String, required): The target group
|
|
621
|
+
|
|
622
|
+
**Returns:**
|
|
623
|
+
```json
|
|
624
|
+
{
|
|
625
|
+
"success": true,
|
|
626
|
+
"group_name": "research-team",
|
|
627
|
+
"new_active": "researcher-2",
|
|
628
|
+
"previous_active": "researcher-1",
|
|
629
|
+
"message": "Failover complete. 'researcher-2' is now active."
|
|
630
|
+
}
|
|
631
|
+
```
|
|
632
|
+
|
|
633
|
+
---
|
|
634
|
+
|
|
635
|
+
### SyncGroupTool
|
|
636
|
+
|
|
637
|
+
Manually synchronize group state across all members.
|
|
638
|
+
|
|
639
|
+
**Parameters:**
|
|
640
|
+
- `group_name` (String, required): The target group
|
|
641
|
+
|
|
642
|
+
**Returns:**
|
|
643
|
+
```json
|
|
644
|
+
{
|
|
645
|
+
"success": true,
|
|
646
|
+
"group_name": "research-team",
|
|
647
|
+
"synced_members": 3,
|
|
648
|
+
"message": "Group state synchronized across 3 members"
|
|
649
|
+
}
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
---
|
|
653
|
+
|
|
654
|
+
### ShutdownGroupTool
|
|
655
|
+
|
|
656
|
+
Gracefully shutdown a robot group, removing all members.
|
|
657
|
+
|
|
658
|
+
**Parameters:**
|
|
659
|
+
- `group_name` (String, required): The group to shutdown
|
|
660
|
+
|
|
661
|
+
**Returns:**
|
|
662
|
+
```json
|
|
663
|
+
{
|
|
664
|
+
"success": true,
|
|
665
|
+
"group_name": "research-team",
|
|
666
|
+
"message": "Robot group 'research-team' has been shut down"
|
|
667
|
+
}
|
|
668
|
+
```
|
|
669
|
+
|
|
338
670
|
## Resources Reference
|
|
339
671
|
|
|
340
672
|
### htm://statistics
|
|
@@ -375,6 +707,32 @@ ai
|
|
|
375
707
|
|
|
376
708
|
Last 20 memories as JSON array.
|
|
377
709
|
|
|
710
|
+
### htm://groups
|
|
711
|
+
|
|
712
|
+
Active robot groups and their status:
|
|
713
|
+
|
|
714
|
+
```json
|
|
715
|
+
{
|
|
716
|
+
"count": 2,
|
|
717
|
+
"groups": [
|
|
718
|
+
{
|
|
719
|
+
"name": "research-team",
|
|
720
|
+
"member_count": 3,
|
|
721
|
+
"active_robot": "researcher-1",
|
|
722
|
+
"token_usage": 2500,
|
|
723
|
+
"token_budget": 4000
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
"name": "support-team",
|
|
727
|
+
"member_count": 2,
|
|
728
|
+
"active_robot": "support-bot",
|
|
729
|
+
"token_usage": 1200,
|
|
730
|
+
"token_budget": 4000
|
|
731
|
+
}
|
|
732
|
+
]
|
|
733
|
+
}
|
|
734
|
+
```
|
|
735
|
+
|
|
378
736
|
## Client Configuration
|
|
379
737
|
|
|
380
738
|
### Claude Desktop
|
|
@@ -385,10 +743,24 @@ Add to `~/.config/claude/claude_desktop_config.json` (Linux/macOS) or `%APPDATA%
|
|
|
385
743
|
{
|
|
386
744
|
"mcpServers": {
|
|
387
745
|
"htm-memory": {
|
|
388
|
-
"command": "
|
|
389
|
-
"
|
|
746
|
+
"command": "htm_mcp",
|
|
747
|
+
"env": {
|
|
748
|
+
"HTM_DATABASE__URL": "postgresql://user@localhost:5432/htm_development"
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
If `htm_mcp` is not in your PATH, use the absolute path:
|
|
756
|
+
|
|
757
|
+
```json
|
|
758
|
+
{
|
|
759
|
+
"mcpServers": {
|
|
760
|
+
"htm-memory": {
|
|
761
|
+
"command": "/path/to/htm_mcp",
|
|
390
762
|
"env": {
|
|
391
|
-
"
|
|
763
|
+
"HTM_DATABASE__URL": "postgresql://user@localhost:5432/htm_development"
|
|
392
764
|
}
|
|
393
765
|
}
|
|
394
766
|
}
|
|
@@ -408,10 +780,9 @@ Add to `~/.claude/claude_code_config.json`:
|
|
|
408
780
|
{
|
|
409
781
|
"mcpServers": {
|
|
410
782
|
"htm-memory": {
|
|
411
|
-
"command": "
|
|
412
|
-
"args": ["/absolute/path/to/htm/bin/htm_mcp.rb"],
|
|
783
|
+
"command": "htm_mcp",
|
|
413
784
|
"env": {
|
|
414
|
-
"
|
|
785
|
+
"HTM_DATABASE__URL": "postgresql://user@localhost:5432/htm_development"
|
|
415
786
|
}
|
|
416
787
|
}
|
|
417
788
|
}
|
|
@@ -439,11 +810,9 @@ Add to `~/.config/aia/config.yml`:
|
|
|
439
810
|
```yaml
|
|
440
811
|
mcp_servers:
|
|
441
812
|
htm-memory:
|
|
442
|
-
command:
|
|
443
|
-
args:
|
|
444
|
-
- /absolute/path/to/htm/bin/htm_mcp.rb
|
|
813
|
+
command: htm_mcp
|
|
445
814
|
env:
|
|
446
|
-
|
|
815
|
+
HTM_DATABASE__URL: postgresql://user@localhost:5432/htm_development
|
|
447
816
|
```
|
|
448
817
|
|
|
449
818
|
For project-specific configuration, add to `.aia/config.yml` in your project root:
|
|
@@ -451,11 +820,9 @@ For project-specific configuration, add to `.aia/config.yml` in your project roo
|
|
|
451
820
|
```yaml
|
|
452
821
|
mcp_servers:
|
|
453
822
|
htm-memory:
|
|
454
|
-
command:
|
|
455
|
-
args:
|
|
456
|
-
- /absolute/path/to/htm/bin/htm_mcp.rb
|
|
823
|
+
command: htm_mcp
|
|
457
824
|
env:
|
|
458
|
-
|
|
825
|
+
HTM_DATABASE__URL: postgresql://user@localhost:5432/my_project_htm
|
|
459
826
|
```
|
|
460
827
|
|
|
461
828
|
## Usage Examples
|
|
@@ -515,6 +882,41 @@ Remember that project B uses Vue with JavaScript
|
|
|
515
882
|
|
|
516
883
|
Each robot has its own working memory but shares the global long-term memory (hive mind).
|
|
517
884
|
|
|
885
|
+
### Using Robot Groups
|
|
886
|
+
|
|
887
|
+
Robot Groups enable high-availability configurations where multiple robots share working memory:
|
|
888
|
+
|
|
889
|
+
1. **Create a group**:
|
|
890
|
+
```
|
|
891
|
+
Create a robot group called "research-team" with 3 max members
|
|
892
|
+
```
|
|
893
|
+
|
|
894
|
+
2. **Join robots to the group**:
|
|
895
|
+
```
|
|
896
|
+
Join robot "researcher-1" to group "research-team" as active
|
|
897
|
+
Join robot "researcher-2" to group "research-team" as passive
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
3. **Store shared memories**:
|
|
901
|
+
```
|
|
902
|
+
Remember in group "research-team" that we found a relevant paper on embeddings
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
4. **Recall from group context**:
|
|
906
|
+
```
|
|
907
|
+
Recall from group "research-team" what we know about embeddings
|
|
908
|
+
```
|
|
909
|
+
|
|
910
|
+
5. **Handle failover**:
|
|
911
|
+
```
|
|
912
|
+
Trigger failover for group "research-team"
|
|
913
|
+
```
|
|
914
|
+
|
|
915
|
+
6. **Check group status**:
|
|
916
|
+
```
|
|
917
|
+
Show status of group "research-team"
|
|
918
|
+
```
|
|
919
|
+
|
|
518
920
|
### Searching with Typo Tolerance
|
|
519
921
|
|
|
520
922
|
Use fuzzy search when you're not sure of exact tag names:
|
|
@@ -550,9 +952,9 @@ This will find `database:postgresql` even with the typo.
|
|
|
550
952
|
gem install fast-mcp
|
|
551
953
|
```
|
|
552
954
|
|
|
553
|
-
**Error: `
|
|
955
|
+
**Error: `HTM_DATABASE__URL not set`**
|
|
554
956
|
```bash
|
|
555
|
-
export
|
|
957
|
+
export HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_development"
|
|
556
958
|
```
|
|
557
959
|
|
|
558
960
|
### Database Connection Issues
|
|
@@ -573,14 +975,14 @@ psql htm_development -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
|
|
573
975
|
|
|
574
976
|
**Claude Desktop doesn't show HTM tools:**
|
|
575
977
|
1. Verify the config file path is correct for your OS
|
|
576
|
-
2. Check that
|
|
978
|
+
2. Check that `htm_mcp` is in your PATH or use an absolute path
|
|
577
979
|
3. Restart Claude Desktop completely
|
|
578
980
|
4. Check Claude Desktop logs for errors
|
|
579
981
|
|
|
580
982
|
**Claude Code doesn't recognize tools:**
|
|
581
983
|
1. Run `/mcp` to refresh MCP connections
|
|
582
984
|
2. Verify config is valid JSON
|
|
583
|
-
3. Check that
|
|
985
|
+
3. Check that HTM_DATABASE__URL is set in the env section
|
|
584
986
|
|
|
585
987
|
### Embedding/Tag Errors
|
|
586
988
|
|
|
@@ -596,18 +998,51 @@ psql htm_development -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
|
|
596
998
|
|
|
597
999
|
Enable verbose logging by checking STDERR output:
|
|
598
1000
|
```bash
|
|
599
|
-
|
|
1001
|
+
htm_mcp 2>&1 | tee mcp_debug.log
|
|
600
1002
|
```
|
|
601
1003
|
|
|
602
1004
|
The server logs all tool calls and errors to STDERR.
|
|
603
1005
|
|
|
604
1006
|
## Environment Variables
|
|
605
1007
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
|
1008
|
+
Run `htm_mcp help` for a complete list. Key variables:
|
|
1009
|
+
|
|
1010
|
+
### Database (required)
|
|
1011
|
+
|
|
1012
|
+
| Variable | Description |
|
|
1013
|
+
|----------|-------------|
|
|
1014
|
+
| `HTM_DATABASE__URL` | PostgreSQL connection URL (e.g., `postgresql://user:pass@localhost:5432/htm_development`) |
|
|
1015
|
+
|
|
1016
|
+
### Database (alternative to HTM_DATABASE__URL)
|
|
1017
|
+
|
|
1018
|
+
| Variable | Description | Default |
|
|
1019
|
+
|----------|-------------|---------|
|
|
1020
|
+
| `HTM_DATABASE__NAME` | Database name | - |
|
|
1021
|
+
| `HTM_DATABASE__HOST` | Database host | `localhost` |
|
|
1022
|
+
| `HTM_DATABASE__PORT` | Database port | `5432` |
|
|
1023
|
+
| `HTM_DATABASE__USER` | Database username | - |
|
|
1024
|
+
| `HTM_DATABASE__PASSWORD` | Database password | - |
|
|
1025
|
+
| `HTM_DBSSLMODE` | SSL mode | `prefer` |
|
|
1026
|
+
|
|
1027
|
+
### LLM Providers
|
|
1028
|
+
|
|
1029
|
+
| Variable | Description | Default |
|
|
1030
|
+
|----------|-------------|---------|
|
|
1031
|
+
| `HTM_EMBEDDING_PROVIDER` | Embedding provider | `ollama` |
|
|
1032
|
+
| `HTM_EMBEDDING_MODEL` | Embedding model | `nomic-embed-text:latest` |
|
|
1033
|
+
| `HTM_TAG_PROVIDER` | Tag extraction provider | `ollama` |
|
|
1034
|
+
| `HTM_TAG_MODEL` | Tag model | `gemma3:latest` |
|
|
1035
|
+
| `HTM_OLLAMA_URL` | Ollama server URL | `http://localhost:11434` |
|
|
1036
|
+
|
|
1037
|
+
### Other Providers (set API keys as needed)
|
|
1038
|
+
|
|
1039
|
+
| Variable | Description |
|
|
1040
|
+
|----------|-------------|
|
|
1041
|
+
| `HTM_OPENAI_API_KEY` | OpenAI API key |
|
|
1042
|
+
| `HTM_ANTHROPIC_API_KEY` | Anthropic API key |
|
|
1043
|
+
| `HTM_GEMINI_API_KEY` | Google Gemini API key |
|
|
1044
|
+
| `HTM_AZURE_API_KEY` | Azure OpenAI API key |
|
|
1045
|
+
| `HTM_AZURE_ENDPOINT` | Azure OpenAI endpoint |
|
|
611
1046
|
|
|
612
1047
|
## Next Steps
|
|
613
1048
|
|
data/docs/guides/robot-groups.md
CHANGED
|
@@ -89,10 +89,10 @@ require 'htm'
|
|
|
89
89
|
|
|
90
90
|
# Configure HTM
|
|
91
91
|
HTM.configure do |config|
|
|
92
|
-
config.
|
|
93
|
-
config.
|
|
94
|
-
config.
|
|
95
|
-
config.
|
|
92
|
+
config.embedding.provider = :ollama
|
|
93
|
+
config.embedding.model = 'nomic-embed-text'
|
|
94
|
+
config.tag.provider = :ollama
|
|
95
|
+
config.tag.model = 'llama3'
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
# Create a robot group with active and passive members
|
|
@@ -386,8 +386,8 @@ group_name = 'distributed-service'
|
|
|
386
386
|
|
|
387
387
|
# Configure HTM
|
|
388
388
|
HTM.configure do |config|
|
|
389
|
-
config.
|
|
390
|
-
config.
|
|
389
|
+
config.embedding.provider = :ollama
|
|
390
|
+
config.embedding.model = 'nomic-embed-text'
|
|
391
391
|
end
|
|
392
392
|
|
|
393
393
|
# Create HTM instance for this worker
|
|
@@ -573,7 +573,7 @@ Single-process demo showing:
|
|
|
573
573
|
- Real-time sync via LISTEN/NOTIFY
|
|
574
574
|
|
|
575
575
|
```bash
|
|
576
|
-
|
|
576
|
+
HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_dev" ruby examples/robot_groups/same_process.rb
|
|
577
577
|
```
|
|
578
578
|
|
|
579
579
|
### multi_process.rb
|
|
@@ -585,7 +585,7 @@ Multi-process demo showing:
|
|
|
585
585
|
- Dynamic scaling by spawning new processes
|
|
586
586
|
|
|
587
587
|
```bash
|
|
588
|
-
|
|
588
|
+
HTM_DATABASE__URL="postgresql://user@localhost:5432/htm_dev" ruby examples/robot_groups/multi_process.rb
|
|
589
589
|
```
|
|
590
590
|
|
|
591
591
|
### robot_worker.rb
|
data/docs/index.md
CHANGED
|
@@ -81,10 +81,10 @@ require 'htm'
|
|
|
81
81
|
|
|
82
82
|
# Configure HTM globally (optional - uses Ollama by default)
|
|
83
83
|
HTM.configure do |config|
|
|
84
|
-
config.
|
|
85
|
-
config.
|
|
86
|
-
config.
|
|
87
|
-
config.
|
|
84
|
+
config.embedding.provider = :ollama
|
|
85
|
+
config.embedding.model = 'nomic-embed-text:latest'
|
|
86
|
+
config.tag.provider = :ollama
|
|
87
|
+
config.tag.model = 'gemma3:latest'
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
# Initialize HTM for your robot
|