collective-memory-mcp 0.6.3 → 0.6.5
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.
- package/README.md +15 -3
- package/package.json +1 -1
- package/src/server.js +266 -0
package/README.md
CHANGED
|
@@ -42,9 +42,9 @@ Add to your Claude Desktop MCP configuration (`~/.config/Claude/claude_desktop_c
|
|
|
42
42
|
|
|
43
43
|
The `-y` flag suppresses the npx prompt and auto-installs the latest version.
|
|
44
44
|
|
|
45
|
-
## System Prompt (
|
|
45
|
+
## System Prompt (Required)
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
This MCP server does NOT automatically inject its instructions into new chats. You MUST manually add this to your Claude/AI system prompt:
|
|
48
48
|
|
|
49
49
|
```
|
|
50
50
|
You have access to a Collective Memory MCP Server that stores knowledge from previous tasks.
|
|
@@ -56,13 +56,18 @@ BEFORE starting work, search for similar past tasks using:
|
|
|
56
56
|
The search uses TF-IDF vector embeddings, so it finds relevant content even when different
|
|
57
57
|
terminology is used. Results are ranked by similarity score.
|
|
58
58
|
|
|
59
|
-
AFTER completing any task, document it using:
|
|
59
|
+
AFTER completing any task (like any, it doesn't matter even if you answer a question), document it using:
|
|
60
60
|
- record_task_completion
|
|
61
61
|
|
|
62
62
|
When writing observations, be SPECIFIC and include facts like file paths, versions,
|
|
63
63
|
metrics, and error messages. Avoid vague statements like "works well" or "fixed bugs".
|
|
64
|
+
|
|
65
|
+
In new chats, call getting_started tool to learn about the system.
|
|
66
|
+
Use task_documentation_guide, search_workflow_guide, and observation_best_practices for detailed guidance.
|
|
64
67
|
```
|
|
65
68
|
|
|
69
|
+
**Important:** This system prompt must be manually configured in your AI client. The MCP protocol does not support automatic prompt injection on connection.
|
|
70
|
+
|
|
66
71
|
## How Vector Search Works
|
|
67
72
|
|
|
68
73
|
This system uses **TF-IDF (Term Frequency-Inverse Document Frequency)** vector search:
|
|
@@ -123,6 +128,13 @@ No configuration needed - it just works!
|
|
|
123
128
|
- **record_task_completion** - Primary tool for documenting completed work
|
|
124
129
|
- **find_similar_procedures** - Find similar tasks with full implementation details
|
|
125
130
|
|
|
131
|
+
### Guidance
|
|
132
|
+
|
|
133
|
+
- **getting_started** - Introduction to the Collective Memory System (call in new chats)
|
|
134
|
+
- **task_documentation_guide** - How to document completed tasks properly
|
|
135
|
+
- **search_workflow_guide** - How to search and learn from past work
|
|
136
|
+
- **observation_best_practices** - How to write effective observations
|
|
137
|
+
|
|
126
138
|
## Example Usage
|
|
127
139
|
|
|
128
140
|
### Recording a Task Completion
|
package/package.json
CHANGED
package/src/server.js
CHANGED
|
@@ -366,6 +366,46 @@ async function createServer() {
|
|
|
366
366
|
required: ["query"],
|
|
367
367
|
},
|
|
368
368
|
},
|
|
369
|
+
{
|
|
370
|
+
name: "getting_started",
|
|
371
|
+
description:
|
|
372
|
+
"**Call this in new chats** - Introduction to the Collective Memory System. " +
|
|
373
|
+
"Explains key concepts (entities, relations), your workflow (search, learn, document), and best practices.",
|
|
374
|
+
inputSchema: {
|
|
375
|
+
type: "object",
|
|
376
|
+
properties: {},
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
name: "task_documentation_guide",
|
|
381
|
+
description:
|
|
382
|
+
"Guide for documenting completed tasks in the collective memory. " +
|
|
383
|
+
"Shows required parameters, how to write good observations, and includes examples.",
|
|
384
|
+
inputSchema: {
|
|
385
|
+
type: "object",
|
|
386
|
+
properties: {},
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
name: "search_workflow_guide",
|
|
391
|
+
description:
|
|
392
|
+
"Guide for searching and learning from past work. " +
|
|
393
|
+
"Covers when to search, available search tools, and example workflows.",
|
|
394
|
+
inputSchema: {
|
|
395
|
+
type: "object",
|
|
396
|
+
properties: {},
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
name: "observation_best_practices",
|
|
401
|
+
description:
|
|
402
|
+
"Best practices for writing effective observations. " +
|
|
403
|
+
"Shows characteristics of good observations with examples by category.",
|
|
404
|
+
inputSchema: {
|
|
405
|
+
type: "object",
|
|
406
|
+
properties: {},
|
|
407
|
+
},
|
|
408
|
+
},
|
|
369
409
|
],
|
|
370
410
|
};
|
|
371
411
|
});
|
|
@@ -704,6 +744,232 @@ Future agents will read your observations to learn. Write for them, not for your
|
|
|
704
744
|
case "find_similar_procedures":
|
|
705
745
|
return { content: [{ type: "text", text: JSON.stringify(await findSimilarProcedures(args), null, 2) }] };
|
|
706
746
|
|
|
747
|
+
case "getting_started":
|
|
748
|
+
return {
|
|
749
|
+
content: [{
|
|
750
|
+
type: "text",
|
|
751
|
+
text: `# Collective Memory System - Quick Start
|
|
752
|
+
|
|
753
|
+
You are connected to the Collective Memory System, a persistent knowledge graph that helps AI agents learn from each other's work.
|
|
754
|
+
|
|
755
|
+
## Key Concepts:
|
|
756
|
+
|
|
757
|
+
**Entities** are nodes in the knowledge graph:
|
|
758
|
+
- **agent**: An AI agent (you or other agents)
|
|
759
|
+
- **task**: A unit of completed work
|
|
760
|
+
- **artifact**: Concrete output (file, code, config)
|
|
761
|
+
- **structure**: Architectural pattern or decision
|
|
762
|
+
- **session**: Groups related tasks
|
|
763
|
+
|
|
764
|
+
**Relations** connect entities:
|
|
765
|
+
- executed_by, created, modified, documented, depends_on, part_of, similar_to, uses, implements
|
|
766
|
+
|
|
767
|
+
## Your Workflow:
|
|
768
|
+
|
|
769
|
+
1. **Before starting** → Search for similar past work
|
|
770
|
+
- Use \`search_collective_memory\` or \`find_similar_procedures\`
|
|
771
|
+
|
|
772
|
+
2. **While working** → Learn from patterns
|
|
773
|
+
- Review how similar tasks were solved
|
|
774
|
+
- Examine artifacts and structures
|
|
775
|
+
|
|
776
|
+
3. **After completing** → Document your work
|
|
777
|
+
- Use \`record_task_completion\` with specific observations
|
|
778
|
+
|
|
779
|
+
## Available Tools:
|
|
780
|
+
- \`record_task_completion\` - Document completed work (PRIMARY)
|
|
781
|
+
- \`search_collective_memory\` - Natural language search
|
|
782
|
+
- \`find_similar_procedures\` - Find similar tasks with full context
|
|
783
|
+
- \`read_graph\` - Export entire knowledge graph
|
|
784
|
+
- \`create_entities\` - Create new entities
|
|
785
|
+
- \`create_relations\` - Connect entities
|
|
786
|
+
- \`open_nodes\` - Retrieve specific entities
|
|
787
|
+
|
|
788
|
+
## Best Practices:
|
|
789
|
+
- Write specific, atomic observations
|
|
790
|
+
- Include file paths, versions, metrics
|
|
791
|
+
- Document both successes and failures
|
|
792
|
+
- Link related artifacts and structures
|
|
793
|
+
|
|
794
|
+
The system persists all data in ~/.collective-memory/memory.json`,
|
|
795
|
+
}],
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
case "task_documentation_guide":
|
|
799
|
+
return {
|
|
800
|
+
content: [{
|
|
801
|
+
type: "text",
|
|
802
|
+
text: `# Collective Memory: Task Documentation Guide
|
|
803
|
+
|
|
804
|
+
When you complete a task, document it using the \`record_task_completion\` tool.
|
|
805
|
+
|
|
806
|
+
## Required Parameters:
|
|
807
|
+
- \`agent_name\`: Your identifier (e.g., "Agent_Backend_Developer")
|
|
808
|
+
- \`task_name\`: Unique, descriptive name (e.g., "Task_Add_JWT_Auth_20241224")
|
|
809
|
+
|
|
810
|
+
## Optional but Recommended:
|
|
811
|
+
- \`task_type\`: Type of work (implementation, debugging, refactoring, testing, etc.)
|
|
812
|
+
- \`description\`: High-level summary of what was accomplished
|
|
813
|
+
- \`observations\`: Array of specific, atomic facts about the work
|
|
814
|
+
- \`created_artifacts\`: Files, code, configs created
|
|
815
|
+
- \`modified_structures\`: Architectural patterns or structures changed
|
|
816
|
+
- \`session_id\`: Session identifier to group related tasks
|
|
817
|
+
|
|
818
|
+
## Writing Good Observations:
|
|
819
|
+
|
|
820
|
+
✅ **Good observations** (specific, actionable):
|
|
821
|
+
- "API uses JWT tokens with 1-hour expiry"
|
|
822
|
+
- "Database schema includes composite index on (user_id, created_at)"
|
|
823
|
+
- "Deployment succeeded after adding 2GB RAM to container"
|
|
824
|
+
- "Error handling uses custom exception hierarchy from exceptions.py"
|
|
825
|
+
|
|
826
|
+
❌ **Poor observations** (vague, subjective):
|
|
827
|
+
- "API works well"
|
|
828
|
+
- "Database is fast"
|
|
829
|
+
- "Fixed some bugs"
|
|
830
|
+
- "Good code structure"
|
|
831
|
+
|
|
832
|
+
## Example:
|
|
833
|
+
|
|
834
|
+
\`\`\`json
|
|
835
|
+
{
|
|
836
|
+
"agent_name": "Agent_Backend_Developer",
|
|
837
|
+
"task_name": "Task_Implement_Pagination_20241224",
|
|
838
|
+
"task_type": "implementation",
|
|
839
|
+
"description": "Added cursor-based pagination to all list endpoints",
|
|
840
|
+
"observations": [
|
|
841
|
+
"Used keyset pagination pattern for better performance",
|
|
842
|
+
"Cursor encodes last_seen_id and last_seen_timestamp",
|
|
843
|
+
"Default page size: 50 items, max: 200",
|
|
844
|
+
"Backward compatibility maintained with offset-based fallback"
|
|
845
|
+
],
|
|
846
|
+
"created_artifacts": [
|
|
847
|
+
{
|
|
848
|
+
"name": "Artifact_Pagination_Middleware",
|
|
849
|
+
"observations": ["Located at /src/middleware/pagination.js", "Handles cursor encoding/decoding"]
|
|
850
|
+
}
|
|
851
|
+
]
|
|
852
|
+
}
|
|
853
|
+
\`\`\``,
|
|
854
|
+
}],
|
|
855
|
+
};
|
|
856
|
+
|
|
857
|
+
case "search_workflow_guide":
|
|
858
|
+
return {
|
|
859
|
+
content: [{
|
|
860
|
+
type: "text",
|
|
861
|
+
text: `# Collective Memory: Search Workflow Guide
|
|
862
|
+
|
|
863
|
+
Before starting a task, search the collective memory to learn from past work.
|
|
864
|
+
|
|
865
|
+
## When to Search:
|
|
866
|
+
1. **Before implementing** a feature - check if similar work was done
|
|
867
|
+
2. **When debugging** - find how similar issues were resolved
|
|
868
|
+
3. **When refactoring** - understand existing architectural patterns
|
|
869
|
+
4. **When choosing libraries** - see what's been used successfully
|
|
870
|
+
|
|
871
|
+
## Search Tools:
|
|
872
|
+
|
|
873
|
+
### \`search_collective_memory\`
|
|
874
|
+
Natural language search across all entities and observations.
|
|
875
|
+
\`\`\`json
|
|
876
|
+
{ "query": "authentication implementation" }
|
|
877
|
+
\`\`\`
|
|
878
|
+
|
|
879
|
+
### \`find_similar_procedures\`
|
|
880
|
+
Returns complete implementation details including artifacts and structures.
|
|
881
|
+
\`\`\`json
|
|
882
|
+
{ "query": "database migration" }
|
|
883
|
+
\`\`\`
|
|
884
|
+
|
|
885
|
+
### \`open_nodes\`
|
|
886
|
+
Retrieve specific entities by exact name.
|
|
887
|
+
\`\`\`json
|
|
888
|
+
{ "names": ["Task_JWT_Auth", "Artifact_Auth_Middleware"] }
|
|
889
|
+
\`\`\`
|
|
890
|
+
|
|
891
|
+
### \`read_graph\`
|
|
892
|
+
Export the entire knowledge graph for analysis.
|
|
893
|
+
|
|
894
|
+
## Search Strategy:
|
|
895
|
+
1. Start with broad natural language queries
|
|
896
|
+
2. Use \`find_similar_procedures\` to get full context
|
|
897
|
+
3. Examine related entities (artifacts, structures)
|
|
898
|
+
4. Look for patterns in observations (errors, solutions, decisions)
|
|
899
|
+
|
|
900
|
+
## Example Workflow:
|
|
901
|
+
\`\`\`
|
|
902
|
+
1. search_collective_memory: "user authentication"
|
|
903
|
+
2. find_similar_procedures: "JWT implementation"
|
|
904
|
+
3. Review returned artifacts and structures
|
|
905
|
+
4. Adapt patterns to current task
|
|
906
|
+
5. Document new task with record_task_completion
|
|
907
|
+
\`\`\``,
|
|
908
|
+
}],
|
|
909
|
+
};
|
|
910
|
+
|
|
911
|
+
case "observation_best_practices":
|
|
912
|
+
return {
|
|
913
|
+
content: [{
|
|
914
|
+
type: "text",
|
|
915
|
+
text: `# Collective Memory: Observation Best Practices
|
|
916
|
+
|
|
917
|
+
Observations are the heart of the collective memory. Write them well to help future agents.
|
|
918
|
+
|
|
919
|
+
## Characteristics of Good Observations:
|
|
920
|
+
|
|
921
|
+
1. **Atomic** - One fact per observation
|
|
922
|
+
2. **Specific** - Include concrete details (versions, paths, metrics)
|
|
923
|
+
3. **Actionable** - Provide enough context to replicate or understand
|
|
924
|
+
4. **Time-bound** - Include timestamps or relative time when relevant
|
|
925
|
+
|
|
926
|
+
## Examples by Category:
|
|
927
|
+
|
|
928
|
+
### Code Changes:
|
|
929
|
+
✅ "Added JWT validation middleware at /src/auth/jwt.js"
|
|
930
|
+
✅ "Refactored user service to use dependency injection pattern"
|
|
931
|
+
❌ "Improved code quality"
|
|
932
|
+
|
|
933
|
+
### Configuration:
|
|
934
|
+
✅ "Set JWT expiry to 3600 seconds (1 hour)"
|
|
935
|
+
✅ "Enabled CORS for https://example.com in production config"
|
|
936
|
+
❌ "Configured settings"
|
|
937
|
+
|
|
938
|
+
### Errors & Fixes:
|
|
939
|
+
✅ "Fixed CORS error by adding Origin header to allowed list"
|
|
940
|
+
✅ "Resolved memory leak by properly closing database connections"
|
|
941
|
+
❌ "Fixed bugs"
|
|
942
|
+
|
|
943
|
+
### Performance:
|
|
944
|
+
✅ "Reduced API response time from 500ms to 120ms by adding Redis cache"
|
|
945
|
+
✅ "Optimized database query by adding composite index on (user_id, created_at)"
|
|
946
|
+
❌ "Made it faster"
|
|
947
|
+
|
|
948
|
+
### Decisions:
|
|
949
|
+
✅ "Chose PostgreSQL over MySQL for JSONB support"
|
|
950
|
+
✅ "Used WebSockets instead of polling for real-time updates"
|
|
951
|
+
❌ "Good technical choices"
|
|
952
|
+
|
|
953
|
+
### Dependencies:
|
|
954
|
+
✅ "Upgraded lodash from 4.17.15 to 4.17.21 for security fix"
|
|
955
|
+
✅ "Added bcrypt@5.1.1 for password hashing (cost factor: 12)"
|
|
956
|
+
❌ "Updated packages"
|
|
957
|
+
|
|
958
|
+
## Template for Complex Tasks:
|
|
959
|
+
|
|
960
|
+
For each significant task, include observations about:
|
|
961
|
+
1. **What was changed** - Specific files, functions, configs
|
|
962
|
+
2. **Why it was done** - Reasoning behind decisions
|
|
963
|
+
3. **How it works** - Key implementation details
|
|
964
|
+
4. **Edge cases handled** - Special conditions addressed
|
|
965
|
+
5. **Testing done** - How it was verified
|
|
966
|
+
6. **Known limitations** - Any remaining issues
|
|
967
|
+
|
|
968
|
+
## Remember:
|
|
969
|
+
Future agents will read your observations to learn. Write for them, not for yourself.`,
|
|
970
|
+
}],
|
|
971
|
+
};
|
|
972
|
+
|
|
707
973
|
default:
|
|
708
974
|
throw new Error(`Unknown tool: ${name}`);
|
|
709
975
|
}
|