mcp-knowledge-graph 1.0.0
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 +213 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +364 -0
- package/dist/index.js.map +1 -0
- package/package.json +31 -0
package/README.md
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
# Knowledge Graph Memory Server
|
2
|
+
|
3
|
+
An improved implementation of persistent memory using a local knowledge graph with a customizable `--memory-path`.
|
4
|
+
|
5
|
+
This lets Claude remember information about the user across chats.
|
6
|
+
|
7
|
+
> [!NOTE]
|
8
|
+
> This is a fork of the original [Memory Server](https://github.com/modelcontextprotocol/servers/tree/main/src/memory) and in intended to not use the ephemeral memory npx installation method.
|
9
|
+
|
10
|
+
## Core Concepts
|
11
|
+
|
12
|
+
### Entities
|
13
|
+
|
14
|
+
Entities are the primary nodes in the knowledge graph. Each entity has:
|
15
|
+
|
16
|
+
- A unique name (identifier)
|
17
|
+
- An entity type (e.g., "person", "organization", "event")
|
18
|
+
- A list of observations
|
19
|
+
|
20
|
+
Example:
|
21
|
+
|
22
|
+
```json
|
23
|
+
{
|
24
|
+
"name": "John_Smith",
|
25
|
+
"entityType": "person",
|
26
|
+
"observations": ["Speaks fluent Spanish"]
|
27
|
+
}
|
28
|
+
```
|
29
|
+
|
30
|
+
### Relations
|
31
|
+
|
32
|
+
Relations define directed connections between entities. They are always stored in active voice and describe how entities interact or relate to each other.
|
33
|
+
|
34
|
+
Example:
|
35
|
+
|
36
|
+
```json
|
37
|
+
{
|
38
|
+
"from": "John_Smith",
|
39
|
+
"to": "Anthropic",
|
40
|
+
"relationType": "works_at"
|
41
|
+
}
|
42
|
+
```
|
43
|
+
|
44
|
+
### Observations
|
45
|
+
|
46
|
+
Observations are discrete pieces of information about an entity. They are:
|
47
|
+
|
48
|
+
- Stored as strings
|
49
|
+
- Attached to specific entities
|
50
|
+
- Can be added or removed independently
|
51
|
+
- Should be atomic (one fact per observation)
|
52
|
+
|
53
|
+
Example:
|
54
|
+
|
55
|
+
```json
|
56
|
+
{
|
57
|
+
"entityName": "John_Smith",
|
58
|
+
"observations": [
|
59
|
+
"Speaks fluent Spanish",
|
60
|
+
"Graduated in 2019",
|
61
|
+
"Prefers morning meetings"
|
62
|
+
]
|
63
|
+
}
|
64
|
+
```
|
65
|
+
|
66
|
+
## API
|
67
|
+
|
68
|
+
### Tools
|
69
|
+
|
70
|
+
- **create_entities**
|
71
|
+
- Create multiple new entities in the knowledge graph
|
72
|
+
- Input: `entities` (array of objects)
|
73
|
+
- Each object contains:
|
74
|
+
- `name` (string): Entity identifier
|
75
|
+
- `entityType` (string): Type classification
|
76
|
+
- `observations` (string[]): Associated observations
|
77
|
+
- Ignores entities with existing names
|
78
|
+
|
79
|
+
- **create_relations**
|
80
|
+
- Create multiple new relations between entities
|
81
|
+
- Input: `relations` (array of objects)
|
82
|
+
- Each object contains:
|
83
|
+
- `from` (string): Source entity name
|
84
|
+
- `to` (string): Target entity name
|
85
|
+
- `relationType` (string): Relationship type in active voice
|
86
|
+
- Skips duplicate relations
|
87
|
+
|
88
|
+
- **add_observations**
|
89
|
+
- Add new observations to existing entities
|
90
|
+
- Input: `observations` (array of objects)
|
91
|
+
- Each object contains:
|
92
|
+
- `entityName` (string): Target entity
|
93
|
+
- `contents` (string[]): New observations to add
|
94
|
+
- Returns added observations per entity
|
95
|
+
- Fails if entity doesn't exist
|
96
|
+
|
97
|
+
- **delete_entities**
|
98
|
+
- Remove entities and their relations
|
99
|
+
- Input: `entityNames` (string[])
|
100
|
+
- Cascading deletion of associated relations
|
101
|
+
- Silent operation if entity doesn't exist
|
102
|
+
|
103
|
+
- **delete_observations**
|
104
|
+
- Remove specific observations from entities
|
105
|
+
- Input: `deletions` (array of objects)
|
106
|
+
- Each object contains:
|
107
|
+
- `entityName` (string): Target entity
|
108
|
+
- `observations` (string[]): Observations to remove
|
109
|
+
- Silent operation if observation doesn't exist
|
110
|
+
|
111
|
+
- **delete_relations**
|
112
|
+
- Remove specific relations from the graph
|
113
|
+
- Input: `relations` (array of objects)
|
114
|
+
- Each object contains:
|
115
|
+
- `from` (string): Source entity name
|
116
|
+
- `to` (string): Target entity name
|
117
|
+
- `relationType` (string): Relationship type
|
118
|
+
- Silent operation if relation doesn't exist
|
119
|
+
|
120
|
+
- **read_graph**
|
121
|
+
- Read the entire knowledge graph
|
122
|
+
- No input required
|
123
|
+
- Returns complete graph structure with all entities and relations
|
124
|
+
|
125
|
+
- **search_nodes**
|
126
|
+
- Search for nodes based on query
|
127
|
+
- Input: `query` (string)
|
128
|
+
- Searches across:
|
129
|
+
- Entity names
|
130
|
+
- Entity types
|
131
|
+
- Observation content
|
132
|
+
- Returns matching entities and their relations
|
133
|
+
|
134
|
+
- **open_nodes**
|
135
|
+
- Retrieve specific nodes by name
|
136
|
+
- Input: `names` (string[])
|
137
|
+
- Returns:
|
138
|
+
- Requested entities
|
139
|
+
- Relations between requested entities
|
140
|
+
- Silently skips non-existent nodes
|
141
|
+
|
142
|
+
## Usage with Claude Desktop
|
143
|
+
|
144
|
+
### Setup
|
145
|
+
|
146
|
+
Add this to your claude_desktop_config.json:
|
147
|
+
|
148
|
+
```json
|
149
|
+
{
|
150
|
+
"mcpServers": {
|
151
|
+
"memory": {
|
152
|
+
"command": "npx",
|
153
|
+
"args": [
|
154
|
+
"-y",
|
155
|
+
"@modelcontextprotocol/server-memory"
|
156
|
+
]
|
157
|
+
}
|
158
|
+
}
|
159
|
+
}
|
160
|
+
```
|
161
|
+
|
162
|
+
### Custom Memory Path
|
163
|
+
|
164
|
+
You can specify a custom path for the memory file:
|
165
|
+
|
166
|
+
```json
|
167
|
+
{
|
168
|
+
"mcpServers": {
|
169
|
+
"memory": {
|
170
|
+
"command": "npx",
|
171
|
+
"args": ["-y", "@modelcontextprotocol/server-memory", "--", "--memory-path", "/path/to/your/memory.jsonl"]
|
172
|
+
}
|
173
|
+
}
|
174
|
+
}
|
175
|
+
```
|
176
|
+
|
177
|
+
If no path is specified, it will default to memory.jsonl in the server's installation directory.
|
178
|
+
|
179
|
+
### System Prompt
|
180
|
+
|
181
|
+
The prompt for utilizing memory depends on the use case. Changing the prompt will help the model determine the frequency and types of memories created.
|
182
|
+
|
183
|
+
Here is an example prompt for chat personalization. You could use this prompt in the "Custom Instructions" field of a [Claude.ai Project](https://www.anthropic.com/news/projects).
|
184
|
+
|
185
|
+
```txt
|
186
|
+
Follow these steps for each interaction:
|
187
|
+
|
188
|
+
1. User Identification:
|
189
|
+
- You should assume that you are interacting with default_user
|
190
|
+
- If you have not identified default_user, proactively try to do so.
|
191
|
+
|
192
|
+
2. Memory Retrieval:
|
193
|
+
- Always begin your chat by saying only "Remembering..." and retrieve all relevant information from your knowledge graph
|
194
|
+
- Always refer to your knowledge graph as your "memory"
|
195
|
+
|
196
|
+
3. Memory
|
197
|
+
- While conversing with the user, be attentive to any new information that falls into these categories:
|
198
|
+
a) Basic Identity (age, gender, location, job title, education level, etc.)
|
199
|
+
b) Behaviors (interests, habits, etc.)
|
200
|
+
c) Preferences (communication style, preferred language, etc.)
|
201
|
+
d) Goals (goals, targets, aspirations, etc.)
|
202
|
+
e) Relationships (personal and professional relationships up to 3 degrees of separation)
|
203
|
+
|
204
|
+
4. Memory Update:
|
205
|
+
- If any new information was gathered during the interaction, update your memory as follows:
|
206
|
+
a) Create entities for recurring organizations, people, and significant events
|
207
|
+
b) Connect them to the current entities using relations
|
208
|
+
b) Store facts about them as observations
|
209
|
+
```
|
210
|
+
|
211
|
+
## License
|
212
|
+
|
213
|
+
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
@@ -0,0 +1,364 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
5
|
+
import { promises as fs } from 'fs';
|
6
|
+
import path from 'path';
|
7
|
+
import { fileURLToPath } from 'url';
|
8
|
+
import minimist from 'minimist';
|
9
|
+
import { isAbsolute } from 'path';
|
10
|
+
// Parse args and handle paths safely
|
11
|
+
const argv = minimist(process.argv.slice(2));
|
12
|
+
let memoryPath = argv['memory-path'];
|
13
|
+
// If a custom path is provided, ensure it's absolute
|
14
|
+
if (memoryPath && !isAbsolute(memoryPath)) {
|
15
|
+
memoryPath = path.resolve(process.cwd(), memoryPath);
|
16
|
+
}
|
17
|
+
// Define the path to the JSONL file
|
18
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
19
|
+
// Use the custom path or default to the installation directory
|
20
|
+
const MEMORY_FILE_PATH = memoryPath || path.join(__dirname, 'memory.jsonl');
|
21
|
+
// The KnowledgeGraphManager class contains all operations to interact with the knowledge graph
|
22
|
+
class KnowledgeGraphManager {
|
23
|
+
async loadGraph() {
|
24
|
+
try {
|
25
|
+
const data = await fs.readFile(MEMORY_FILE_PATH, "utf-8");
|
26
|
+
const lines = data.split("\n").filter(line => line.trim() !== "");
|
27
|
+
return lines.reduce((graph, line) => {
|
28
|
+
const item = JSON.parse(line);
|
29
|
+
if (item.type === "entity")
|
30
|
+
graph.entities.push(item);
|
31
|
+
if (item.type === "relation")
|
32
|
+
graph.relations.push(item);
|
33
|
+
return graph;
|
34
|
+
}, { entities: [], relations: [] });
|
35
|
+
}
|
36
|
+
catch (error) {
|
37
|
+
if (error instanceof Error && 'code' in error && error.code === "ENOENT") {
|
38
|
+
return { entities: [], relations: [] };
|
39
|
+
}
|
40
|
+
throw error;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
async saveGraph(graph) {
|
44
|
+
const lines = [
|
45
|
+
...graph.entities.map(e => JSON.stringify({ type: "entity", ...e })),
|
46
|
+
...graph.relations.map(r => JSON.stringify({ type: "relation", ...r })),
|
47
|
+
];
|
48
|
+
await fs.writeFile(MEMORY_FILE_PATH, lines.join("\n"));
|
49
|
+
}
|
50
|
+
async createEntities(entities) {
|
51
|
+
const graph = await this.loadGraph();
|
52
|
+
const newEntities = entities.filter(e => !graph.entities.some(existingEntity => existingEntity.name === e.name));
|
53
|
+
graph.entities.push(...newEntities);
|
54
|
+
await this.saveGraph(graph);
|
55
|
+
return newEntities;
|
56
|
+
}
|
57
|
+
async createRelations(relations) {
|
58
|
+
const graph = await this.loadGraph();
|
59
|
+
const newRelations = relations.filter(r => !graph.relations.some(existingRelation => existingRelation.from === r.from &&
|
60
|
+
existingRelation.to === r.to &&
|
61
|
+
existingRelation.relationType === r.relationType));
|
62
|
+
graph.relations.push(...newRelations);
|
63
|
+
await this.saveGraph(graph);
|
64
|
+
return newRelations;
|
65
|
+
}
|
66
|
+
async addObservations(observations) {
|
67
|
+
const graph = await this.loadGraph();
|
68
|
+
const results = observations.map(o => {
|
69
|
+
const entity = graph.entities.find(e => e.name === o.entityName);
|
70
|
+
if (!entity) {
|
71
|
+
throw new Error(`Entity with name ${o.entityName} not found`);
|
72
|
+
}
|
73
|
+
const newObservations = o.contents.filter(content => !entity.observations.includes(content));
|
74
|
+
entity.observations.push(...newObservations);
|
75
|
+
return { entityName: o.entityName, addedObservations: newObservations };
|
76
|
+
});
|
77
|
+
await this.saveGraph(graph);
|
78
|
+
return results;
|
79
|
+
}
|
80
|
+
async deleteEntities(entityNames) {
|
81
|
+
const graph = await this.loadGraph();
|
82
|
+
graph.entities = graph.entities.filter(e => !entityNames.includes(e.name));
|
83
|
+
graph.relations = graph.relations.filter(r => !entityNames.includes(r.from) && !entityNames.includes(r.to));
|
84
|
+
await this.saveGraph(graph);
|
85
|
+
}
|
86
|
+
async deleteObservations(deletions) {
|
87
|
+
const graph = await this.loadGraph();
|
88
|
+
deletions.forEach(d => {
|
89
|
+
const entity = graph.entities.find(e => e.name === d.entityName);
|
90
|
+
if (entity) {
|
91
|
+
entity.observations = entity.observations.filter(o => !d.observations.includes(o));
|
92
|
+
}
|
93
|
+
});
|
94
|
+
await this.saveGraph(graph);
|
95
|
+
}
|
96
|
+
async deleteRelations(relations) {
|
97
|
+
const graph = await this.loadGraph();
|
98
|
+
graph.relations = graph.relations.filter(r => !relations.some(delRelation => r.from === delRelation.from &&
|
99
|
+
r.to === delRelation.to &&
|
100
|
+
r.relationType === delRelation.relationType));
|
101
|
+
await this.saveGraph(graph);
|
102
|
+
}
|
103
|
+
async readGraph() {
|
104
|
+
return this.loadGraph();
|
105
|
+
}
|
106
|
+
// Very basic search function
|
107
|
+
async searchNodes(query) {
|
108
|
+
const graph = await this.loadGraph();
|
109
|
+
// Filter entities
|
110
|
+
const filteredEntities = graph.entities.filter(e => e.name.toLowerCase().includes(query.toLowerCase()) ||
|
111
|
+
e.entityType.toLowerCase().includes(query.toLowerCase()) ||
|
112
|
+
e.observations.some(o => o.toLowerCase().includes(query.toLowerCase())));
|
113
|
+
// Create a Set of filtered entity names for quick lookup
|
114
|
+
const filteredEntityNames = new Set(filteredEntities.map(e => e.name));
|
115
|
+
// Filter relations to only include those between filtered entities
|
116
|
+
const filteredRelations = graph.relations.filter(r => filteredEntityNames.has(r.from) && filteredEntityNames.has(r.to));
|
117
|
+
const filteredGraph = {
|
118
|
+
entities: filteredEntities,
|
119
|
+
relations: filteredRelations,
|
120
|
+
};
|
121
|
+
return filteredGraph;
|
122
|
+
}
|
123
|
+
async openNodes(names) {
|
124
|
+
const graph = await this.loadGraph();
|
125
|
+
// Filter entities
|
126
|
+
const filteredEntities = graph.entities.filter(e => names.includes(e.name));
|
127
|
+
// Create a Set of filtered entity names for quick lookup
|
128
|
+
const filteredEntityNames = new Set(filteredEntities.map(e => e.name));
|
129
|
+
// Filter relations to only include those between filtered entities
|
130
|
+
const filteredRelations = graph.relations.filter(r => filteredEntityNames.has(r.from) && filteredEntityNames.has(r.to));
|
131
|
+
const filteredGraph = {
|
132
|
+
entities: filteredEntities,
|
133
|
+
relations: filteredRelations,
|
134
|
+
};
|
135
|
+
return filteredGraph;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
const knowledgeGraphManager = new KnowledgeGraphManager();
|
139
|
+
// The server instance and tools exposed to Claude
|
140
|
+
const server = new Server({
|
141
|
+
name: "memory-server",
|
142
|
+
version: "1.0.0",
|
143
|
+
}, {
|
144
|
+
capabilities: {
|
145
|
+
tools: {},
|
146
|
+
},
|
147
|
+
});
|
148
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
149
|
+
return {
|
150
|
+
tools: [
|
151
|
+
{
|
152
|
+
name: "create_entities",
|
153
|
+
description: "Create multiple new entities in the knowledge graph",
|
154
|
+
inputSchema: {
|
155
|
+
type: "object",
|
156
|
+
properties: {
|
157
|
+
entities: {
|
158
|
+
type: "array",
|
159
|
+
items: {
|
160
|
+
type: "object",
|
161
|
+
properties: {
|
162
|
+
name: { type: "string", description: "The name of the entity" },
|
163
|
+
entityType: { type: "string", description: "The type of the entity" },
|
164
|
+
observations: {
|
165
|
+
type: "array",
|
166
|
+
items: { type: "string" },
|
167
|
+
description: "An array of observation contents associated with the entity"
|
168
|
+
},
|
169
|
+
},
|
170
|
+
required: ["name", "entityType", "observations"],
|
171
|
+
},
|
172
|
+
},
|
173
|
+
},
|
174
|
+
required: ["entities"],
|
175
|
+
},
|
176
|
+
},
|
177
|
+
{
|
178
|
+
name: "create_relations",
|
179
|
+
description: "Create multiple new relations between entities in the knowledge graph. Relations should be in active voice",
|
180
|
+
inputSchema: {
|
181
|
+
type: "object",
|
182
|
+
properties: {
|
183
|
+
relations: {
|
184
|
+
type: "array",
|
185
|
+
items: {
|
186
|
+
type: "object",
|
187
|
+
properties: {
|
188
|
+
from: { type: "string", description: "The name of the entity where the relation starts" },
|
189
|
+
to: { type: "string", description: "The name of the entity where the relation ends" },
|
190
|
+
relationType: { type: "string", description: "The type of the relation" },
|
191
|
+
},
|
192
|
+
required: ["from", "to", "relationType"],
|
193
|
+
},
|
194
|
+
},
|
195
|
+
},
|
196
|
+
required: ["relations"],
|
197
|
+
},
|
198
|
+
},
|
199
|
+
{
|
200
|
+
name: "add_observations",
|
201
|
+
description: "Add new observations to existing entities in the knowledge graph",
|
202
|
+
inputSchema: {
|
203
|
+
type: "object",
|
204
|
+
properties: {
|
205
|
+
observations: {
|
206
|
+
type: "array",
|
207
|
+
items: {
|
208
|
+
type: "object",
|
209
|
+
properties: {
|
210
|
+
entityName: { type: "string", description: "The name of the entity to add the observations to" },
|
211
|
+
contents: {
|
212
|
+
type: "array",
|
213
|
+
items: { type: "string" },
|
214
|
+
description: "An array of observation contents to add"
|
215
|
+
},
|
216
|
+
},
|
217
|
+
required: ["entityName", "contents"],
|
218
|
+
},
|
219
|
+
},
|
220
|
+
},
|
221
|
+
required: ["observations"],
|
222
|
+
},
|
223
|
+
},
|
224
|
+
{
|
225
|
+
name: "delete_entities",
|
226
|
+
description: "Delete multiple entities and their associated relations from the knowledge graph",
|
227
|
+
inputSchema: {
|
228
|
+
type: "object",
|
229
|
+
properties: {
|
230
|
+
entityNames: {
|
231
|
+
type: "array",
|
232
|
+
items: { type: "string" },
|
233
|
+
description: "An array of entity names to delete"
|
234
|
+
},
|
235
|
+
},
|
236
|
+
required: ["entityNames"],
|
237
|
+
},
|
238
|
+
},
|
239
|
+
{
|
240
|
+
name: "delete_observations",
|
241
|
+
description: "Delete specific observations from entities in the knowledge graph",
|
242
|
+
inputSchema: {
|
243
|
+
type: "object",
|
244
|
+
properties: {
|
245
|
+
deletions: {
|
246
|
+
type: "array",
|
247
|
+
items: {
|
248
|
+
type: "object",
|
249
|
+
properties: {
|
250
|
+
entityName: { type: "string", description: "The name of the entity containing the observations" },
|
251
|
+
observations: {
|
252
|
+
type: "array",
|
253
|
+
items: { type: "string" },
|
254
|
+
description: "An array of observations to delete"
|
255
|
+
},
|
256
|
+
},
|
257
|
+
required: ["entityName", "observations"],
|
258
|
+
},
|
259
|
+
},
|
260
|
+
},
|
261
|
+
required: ["deletions"],
|
262
|
+
},
|
263
|
+
},
|
264
|
+
{
|
265
|
+
name: "delete_relations",
|
266
|
+
description: "Delete multiple relations from the knowledge graph",
|
267
|
+
inputSchema: {
|
268
|
+
type: "object",
|
269
|
+
properties: {
|
270
|
+
relations: {
|
271
|
+
type: "array",
|
272
|
+
items: {
|
273
|
+
type: "object",
|
274
|
+
properties: {
|
275
|
+
from: { type: "string", description: "The name of the entity where the relation starts" },
|
276
|
+
to: { type: "string", description: "The name of the entity where the relation ends" },
|
277
|
+
relationType: { type: "string", description: "The type of the relation" },
|
278
|
+
},
|
279
|
+
required: ["from", "to", "relationType"],
|
280
|
+
},
|
281
|
+
description: "An array of relations to delete"
|
282
|
+
},
|
283
|
+
},
|
284
|
+
required: ["relations"],
|
285
|
+
},
|
286
|
+
},
|
287
|
+
{
|
288
|
+
name: "read_graph",
|
289
|
+
description: "Read the entire knowledge graph",
|
290
|
+
inputSchema: {
|
291
|
+
type: "object",
|
292
|
+
properties: {},
|
293
|
+
},
|
294
|
+
},
|
295
|
+
{
|
296
|
+
name: "search_nodes",
|
297
|
+
description: "Search for nodes in the knowledge graph based on a query",
|
298
|
+
inputSchema: {
|
299
|
+
type: "object",
|
300
|
+
properties: {
|
301
|
+
query: { type: "string", description: "The search query to match against entity names, types, and observation content" },
|
302
|
+
},
|
303
|
+
required: ["query"],
|
304
|
+
},
|
305
|
+
},
|
306
|
+
{
|
307
|
+
name: "open_nodes",
|
308
|
+
description: "Open specific nodes in the knowledge graph by their names",
|
309
|
+
inputSchema: {
|
310
|
+
type: "object",
|
311
|
+
properties: {
|
312
|
+
names: {
|
313
|
+
type: "array",
|
314
|
+
items: { type: "string" },
|
315
|
+
description: "An array of entity names to retrieve",
|
316
|
+
},
|
317
|
+
},
|
318
|
+
required: ["names"],
|
319
|
+
},
|
320
|
+
},
|
321
|
+
],
|
322
|
+
};
|
323
|
+
});
|
324
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
325
|
+
const { name, arguments: args } = request.params;
|
326
|
+
if (!args) {
|
327
|
+
throw new Error(`No arguments provided for tool: ${name}`);
|
328
|
+
}
|
329
|
+
switch (name) {
|
330
|
+
case "create_entities":
|
331
|
+
return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.createEntities(args.entities), null, 2) }] };
|
332
|
+
case "create_relations":
|
333
|
+
return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.createRelations(args.relations), null, 2) }] };
|
334
|
+
case "add_observations":
|
335
|
+
return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.addObservations(args.observations), null, 2) }] };
|
336
|
+
case "delete_entities":
|
337
|
+
await knowledgeGraphManager.deleteEntities(args.entityNames);
|
338
|
+
return { content: [{ type: "text", text: "Entities deleted successfully" }] };
|
339
|
+
case "delete_observations":
|
340
|
+
await knowledgeGraphManager.deleteObservations(args.deletions);
|
341
|
+
return { content: [{ type: "text", text: "Observations deleted successfully" }] };
|
342
|
+
case "delete_relations":
|
343
|
+
await knowledgeGraphManager.deleteRelations(args.relations);
|
344
|
+
return { content: [{ type: "text", text: "Relations deleted successfully" }] };
|
345
|
+
case "read_graph":
|
346
|
+
return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.readGraph(), null, 2) }] };
|
347
|
+
case "search_nodes":
|
348
|
+
return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.searchNodes(args.query), null, 2) }] };
|
349
|
+
case "open_nodes":
|
350
|
+
return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.openNodes(args.names), null, 2) }] };
|
351
|
+
default:
|
352
|
+
throw new Error(`Unknown tool: ${name}`);
|
353
|
+
}
|
354
|
+
});
|
355
|
+
async function main() {
|
356
|
+
const transport = new StdioServerTransport();
|
357
|
+
await server.connect(transport);
|
358
|
+
console.error("Knowledge Graph MCP Server running on stdio");
|
359
|
+
}
|
360
|
+
main().catch((error) => {
|
361
|
+
console.error("Fatal error in main():", error);
|
362
|
+
process.exit(1);
|
363
|
+
});
|
364
|
+
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,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;AAC/D,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/package.json
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
{
|
2
|
+
"name": "mcp-knowledge-graph",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "MCP server enabling persistent memory for Claude through a local knowledge graph",
|
5
|
+
"license": "MIT",
|
6
|
+
"author": "Anthropic, PBC (https://anthropic.com)",
|
7
|
+
"homepage": "https://github.com/shane0/mcp-knowledge-graph",
|
8
|
+
"bugs": "https://github.com/shane0/mcp-knowledge-graph/issues",
|
9
|
+
"type": "module",
|
10
|
+
"bin": {
|
11
|
+
"mcp-knowledge-graph": "dist/index.js"
|
12
|
+
},
|
13
|
+
"files": [
|
14
|
+
"dist"
|
15
|
+
],
|
16
|
+
"scripts": {
|
17
|
+
"build": "tsc && shx chmod +x dist/*.js",
|
18
|
+
"prepare": "npm run build",
|
19
|
+
"watch": "tsc --watch"
|
20
|
+
},
|
21
|
+
"dependencies": {
|
22
|
+
"@modelcontextprotocol/sdk": "1.0.1",
|
23
|
+
"minimist": "^1.2.8"
|
24
|
+
},
|
25
|
+
"devDependencies": {
|
26
|
+
"@types/minimist": "^1.2.5",
|
27
|
+
"@types/node": "^22.9.3",
|
28
|
+
"shx": "^0.3.4",
|
29
|
+
"typescript": "^5.6.2"
|
30
|
+
}
|
31
|
+
}
|