j5ed-knowledge-graph
A knowledge graph MCP server providing persistent, structured memory for AI assistants with multi-agent isolation, tiered search, and index navigation.
README
j5ed-knowledge-graph
A knowledge graph memory server for the Model Context Protocol (MCP). Gives AI assistants persistent, structured memory across sessions using a simple entity-relation-observation graph.
Forked from the official @modelcontextprotocol/server-memory and significantly enhanced with multi-agent isolation, tiered search, index navigation, backup rotation, and three transport modes.
What's different from upstream
| Feature | Upstream | j5ed |
|---|---|---|
read_graph() |
Returns full graph every time | Returns lightweight index stubs by default; force=true for full dump |
search_nodes() |
Flat substring match | Tokenized multi-word queries, tiered results by match count, field-priority ranking, per-tier caps |
open_nodes() |
Returns relations between opened nodes only | Also returns inbound relations to index entities (table-of-contents navigation) |
| Multi-agent | None | Tenant isolation via authored_by: provenance — agents only see their own entities |
| Multi-user | None | Two-dimensional isolation with user_id: tags — users share agent memory but not private entities |
| Auth | None | Bearer token authentication for HTTP/SSE transports |
| Read grants | None | Cross-agent read visibility via AGENT_READ_GRANTS |
| Write safety | None | Async mutex serializes all mutations — no lost writes under concurrency |
| Backups | None | Automatic backup rotation (last 5 copies) on every save |
| Transports | stdio only | stdio, SSE, and Streamable HTTP |
| Param handling | Strict | Gracefully handles double-serialized JSON from flaky clients |
Installation
npm install j5ed-knowledge-graph
Or run directly:
npx j5ed-knowledge-graph
MCP Configuration
stdio (local, default)
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "j5ed-knowledge-graph"],
"env": {
"MEMORY_FILE_PATH": "/path/to/memory.json"
}
}
}
}
Streamable HTTP (network)
npx j5ed-knowledge-graph --http --port 3100
{
"mcpServers": {
"memory": {
"url": "http://localhost:3100/mcp"
}
}
}
SSE (legacy network)
npx j5ed-knowledge-graph --sse --port 3100
Environment Variables
| Variable | Default | Description |
|---|---|---|
MEMORY_FILE_PATH |
./memory.json (relative to install) |
Path to the NDJSON graph file |
DEFAULT_AGENT_ID |
default |
Agent identity used for stdio connections and when no auth header is provided |
AGENT_CREDENTIALS |
(empty) | Comma-separated agentId:token pairs for bearer auth. When set, all HTTP/SSE connections require Authorization: Bearer <token> |
AGENT_READ_GRANTS |
(empty) | Comma-separated readerId:sourceId pairs. Grants readerId read access to entities authored by sourceId |
Multi-Agent Setup
When multiple agents share a graph, each agent's writes are tagged with authored_by:<agentId> and reads are filtered to show only entities owned by (or granted to) that agent.
Example: two agents with cross-read access
AGENT_CREDENTIALS="assistant:token-abc,researcher:token-xyz" \
AGENT_READ_GRANTS="assistant:researcher" \
npx j5ed-knowledge-graph --http --port 3100
assistantauthenticates withBearer token-abc, sees its own entities +researcher'sresearcherauthenticates withBearer token-xyz, sees only its own entities- Writes are always scoped — agents can only delete what they authored
Tools
| Tool | Description |
|---|---|
create_entities |
Create new entities with name, type, and observations |
create_relations |
Create directed relations between entities |
add_observations |
Append observations to existing entities |
delete_entities |
Delete entities and their relations (agent-scoped) |
delete_observations |
Remove specific observations from entities |
delete_relations |
Remove specific relations |
read_graph |
Returns index stubs by default; force: true for full graph |
search_nodes |
Tiered search across entity names, types, and observations |
open_nodes |
Retrieve full entities by name, with index navigation |
Index Navigation Pattern
The graph supports an index-first navigation pattern for large knowledge bases:
read_graph()— returns lightweight stubs for index entities (name, type, summary)- Pick relevant index —
open_nodes(["MY_INDEX"]) - See inbound relations — entities with
indexed_inrelations to the index are its table of contents - Drill into specifics —
open_nodes(["SPECIFIC_ENTITY"])
Index entities are detected by entityType containing "index" (case-insensitive) or entity name ending with _INDEX.
Search Behavior
Multi-word queries are tokenized. Results are grouped into tiers by how many tokens matched:
- Tier 1: entities matching any 1 token (broadest)
- Tier N: entities matching all N tokens (most specific)
Within each tier, entities are ranked by field priority: index entities first, then name matches (+30), type matches (+20), observation matches (+10). Per-tier caps prevent noise.
Results are returned as lightweight stubs (name, type, matchedIn fields, optional snippet). Use open_nodes() to get full observations.
Storage Format
NDJSON (newline-delimited JSON). Each line is either:
{"type":"entity","name":"MY_ENTITY","entityType":"service","observations":["fact 1","fact 2"]}
{"type":"relation","from":"MY_ENTITY","to":"MY_INDEX","relationType":"indexed_in"}
Docker
docker build -t j5ed-knowledge-graph .
docker run -i -v graph-data:/app/dist --rm j5ed-knowledge-graph
Development
git clone https://github.com/arktechnwa/j5ed-knowledge-graph.git
cd j5ed-knowledge-graph
npm install
npm run build
npm test # 7 suites, 80 tests
npm run dev # stdio mode with ts-node
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。