Overview
Persistent memory system using knowledge graphs for AI agents. Stores entities, relations, and observations as a graph, enabling semantic retrieval and reasoning over accumulated knowledge.
Capabilities
- Extract entities and relations from conversations and documents
- Store knowledge as a graph (nodes + edges + observations)
- Retrieve relevant knowledge via semantic search and graph traversal
- Consolidate and deduplicate knowledge over time
- Query knowledge with natural language
When to Use
Trigger phrases:
"memory knowledge graph"
"Knowledge graph-based persistent memory for AI agents — entities, relations, and"
Building AI agents with long-term memory
Need to remember user preferences, facts, and context across sessions
Knowledge base that grows and improves over time
Cross-referencing information across multiple sources
When NOT to Use
- Task is outside your authorization scope
- You need to implement controls (use implementing-* skills)
- Task is about analysis, not action (use analyzing-* skills)
- You don't have access to target systems
- Task requires compliance expertise (consult professionals)
- Task is about defense, not offense (use defensive skills)
Pseudo Code
# Example workflow for this skill
def execute(input_data):
# Step 1: Validate input
if not input_data:
raise ValueError("Input data is required")
# Step 2: Process core logic
result = process(input_data)
# Step 3: Validate output
validate_output(result)
return result
Entity Extraction
def extract_entities(text):
prompt = f"""Extract entities and relations from:
{text}
Return JSON: {{"entities": [{{"name": "...", "type": "...", "observations": [...]}}], "relations": [{{"from": "...", "to": "...", "type": "..."}}]}}"""
return llm.generate(prompt)
Knowledge Retrieval
def retrieve_relevant(query, graph, top_k=5):
# 1. Semantic search on entity names and observations
semantic_results = graph.semantic_search(query, top_k=top_k)
# 2. Graph traversal - get connected entities
related = []
for entity in semantic_results:
related.extend(graph.get_neighbors(entity.id, depth=2))
# 3. Deduplicate and rank
return rank_by_relevance(semantic_results + related, query)
Memory Consolidation
def consolidate(graph):
# Merge duplicate entities
duplicates = find_similar_entities(graph, threshold=0.9)
for dup_group in duplicates:
merge_entities(graph, dup_group)
# Remove stale observations
for entity in graph.entities:
entity.observations = [o for o in entity.observations if o.relevance > 0.3]
Common Patterns
- Extract on every interaction: Build knowledge from every conversation
- Semantic + graph traversal: Combine vector search with graph walks for better retrieval
- Consolidate periodically: Merge duplicates and prune stale knowledge
- Entity types: Person, Organization, Concept, Event, Preference
How to Use
- Invoke the skill when relevant domain keywords appear in the request
- Provide required inputs as specified in the skill definition
- Review the output for correctness before delivering to the user
- Combine with related skills for complex multi-step workflows
Verification
After completing this skill, confirm:
Process
- Analyze the task requirements
- Apply domain expertise
- Verify output quality
Anti-Rationalization Table
| Rationalization |
Reality |
| "I will just use curl" |
MCP handles auth, retries, streaming, and type safety. Use the SDK. |
| "One mega-server is simpler" |
Single-responsibility servers are easier to debug and maintain. |
| "MCP is just a wrapper" |
MCP enables cross-platform tool sharing. It is infrastructure, not overhead. |
Sub-Skills & Specialized Playbooks
| Sub-skill |
File |
Use when |
| codebase-memory-mcp |
SKILL.md |
Use when indexing codebases into a persistent knowledge graph for structural queries, call-chain tracing, and semantic search. |
| kb-memory |
SKILL.md |
Use when building agent knowledge bases, persistent memory, session recall, or brain architecture for context preservation. |
1---2name: memory-knowledge-graph3description: Use when knowledge graph-based persistent memory for AI agents — entities,4 relations, and semantic retrieval. Use when working with memory knowledge graph.5domain: mcp6author: oyi777license: Apache-2.08subdomain: mcp9tags:10- ai-agent11- graph12- knowledge13- mcp-server14- memory15- model-context-protocol16- tool-integration17version: 1.0.018category: mcp19metadata:20 source: https://skillmd.com/skills/oyi77/memory-knowledge-graph21---222324## Overview2526Persistent memory system using knowledge graphs for AI agents. Stores entities, relations, and observations as a graph, enabling semantic retrieval and reasoning over accumulated knowledge.2728## Capabilities2930- Extract entities and relations from conversations and documents31- Store knowledge as a graph (nodes + edges + observations)32- Retrieve relevant knowledge via semantic search and graph traversal33- Consolidate and deduplicate knowledge over time34- Query knowledge with natural language3536## When to Use37**Trigger phrases:**38- "memory knowledge graph"39- "Knowledge graph-based persistent memory for AI agents — entities, relations, and"404142- Building AI agents with long-term memory43- Need to remember user preferences, facts, and context across sessions44- Knowledge base that grows and improves over time45- Cross-referencing information across multiple sources4647## When NOT to Use4849- Task is outside your authorization scope50- You need to implement controls (use implementing-* skills)51- Task is about analysis, not action (use analyzing-* skills)52- You don't have access to target systems53- Task requires compliance expertise (consult professionals)54- Task is about defense, not offense (use defensive skills)555657## Pseudo Code58```python59# Example workflow for this skill60def execute(input_data):61 # Step 1: Validate input62 if not input_data:63 raise ValueError("Input data is required")6465 # Step 2: Process core logic66 result = process(input_data)6768 # Step 3: Validate output69 validate_output(result)7071 return result72```737475### Entity Extraction76```python77def extract_entities(text):78 prompt = f"""Extract entities and relations from:79{text}8081Return JSON: {{"entities": [{{"name": "...", "type": "...", "observations": [...]}}], "relations": [{{"from": "...", "to": "...", "type": "..."}}]}}"""82 return llm.generate(prompt)83```8485### Knowledge Retrieval86```python87def retrieve_relevant(query, graph, top_k=5):88 # 1. Semantic search on entity names and observations89 semantic_results = graph.semantic_search(query, top_k=top_k)90 91 # 2. Graph traversal - get connected entities92 related = []93 for entity in semantic_results:94 related.extend(graph.get_neighbors(entity.id, depth=2))95 96 # 3. Deduplicate and rank97 return rank_by_relevance(semantic_results + related, query)98```99100### Memory Consolidation101```python102def consolidate(graph):103 # Merge duplicate entities104 duplicates = find_similar_entities(graph, threshold=0.9)105 for dup_group in duplicates:106 merge_entities(graph, dup_group)107 108 # Remove stale observations109 for entity in graph.entities:110 entity.observations = [o for o in entity.observations if o.relevance > 0.3]111```112113## Common Patterns114115- **Extract on every interaction**: Build knowledge from every conversation116- **Semantic + graph traversal**: Combine vector search with graph walks for better retrieval117- **Consolidate periodically**: Merge duplicates and prune stale knowledge118- **Entity types**: Person, Organization, Concept, Event, Preference119120## How to Use1211221. Invoke the skill when relevant domain keywords appear in the request1232. Provide required inputs as specified in the skill definition1243. Review the output for correctness before delivering to the user1254. Combine with related skills for complex multi-step workflows126127## Verification128129After completing this skill, confirm:130131- [ ] Output meets the defined quality and completeness requirements132- [ ] All prerequisites are verified and documented133- [ ] Error handling covers edge cases134- [ ] Results are accurate and actionable135136## Process1371381. Analyze the task requirements1392. Apply domain expertise1403. Verify output quality141142## Anti-Rationalization Table143144| Rationalization | Reality |145|---|---|146| "I will just use curl" | MCP handles auth, retries, streaming, and type safety. Use the SDK. |147| "One mega-server is simpler" | Single-responsibility servers are easier to debug and maintain. |148| "MCP is just a wrapper" | MCP enables cross-platform tool sharing. It is infrastructure, not overhead. |149150## Sub-Skills & Specialized Playbooks151152| Sub-skill | File | Use when |153|---|---|---|154| codebase-memory-mcp | [SKILL.md](../servers/codebase-memory-mcp/SKILL.md) | Use when indexing codebases into a persistent knowledge graph for structural queries, call-chain tracing, and semantic search. |155| kb-memory | [SKILL.md](../../core/kb-memory/SKILL.md) | Use when building agent knowledge bases, persistent memory, session recall, or brain architecture for context preservation. |