Skip to content

Commit 3d0fa94

Browse files
refactor: remove readGraph proxy function in memory example
1 parent 0c74f30 commit 3d0fa94

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

examples/memory/kb.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,6 @@ func (k knowledgeBase) deleteRelations(relations []Relation) error {
315315
return k.saveGraph(graph)
316316
}
317317

318-
// readGraph returns the complete knowledge graph.
319-
func (k knowledgeBase) readGraph() (KnowledgeGraph, error) {
320-
return k.loadGraph()
321-
}
322318

323319
// searchNodes filters entities and relations matching the query string.
324320
func (k knowledgeBase) searchNodes(query string) (KnowledgeGraph, error) {
@@ -537,7 +533,7 @@ func (k knowledgeBase) DeleteRelations(ctx context.Context, ss *mcp.ServerSessio
537533
func (k knowledgeBase) ReadGraph(ctx context.Context, ss *mcp.ServerSession, params *mcp.CallToolParamsFor[struct{}]) (*mcp.CallToolResultFor[KnowledgeGraph], error) {
538534
var res mcp.CallToolResultFor[KnowledgeGraph]
539535

540-
graph, err := k.readGraph()
536+
graph, err := k.loadGraph()
541537
if err != nil {
542538
res.IsError = true
543539
res.Content = []mcp.Content{

examples/memory/kb_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestKnowledgeBaseOperations(t *testing.T) {
7474
}
7575

7676
// Verify entities persist
77-
graph, err = kb.readGraph()
77+
graph, err = kb.loadGraph()
7878
if err != nil {
7979
t.Fatalf("failed to read graph: %v", err)
8080
}
@@ -146,7 +146,7 @@ func TestKnowledgeBaseOperations(t *testing.T) {
146146
}
147147

148148
// Confirm observation removal
149-
graph, _ = kb.readGraph()
149+
graph, _ = kb.loadGraph()
150150
aliceFound := false
151151
for _, e := range graph.Entities {
152152
if e.Name == "Alice" {
@@ -169,7 +169,7 @@ func TestKnowledgeBaseOperations(t *testing.T) {
169169
}
170170

171171
// Confirm relation removal
172-
graph, _ = kb.readGraph()
172+
graph, _ = kb.loadGraph()
173173
if len(graph.Relations) != 0 {
174174
t.Errorf("expected 0 relations after deletion, got %d", len(graph.Relations))
175175
}
@@ -181,7 +181,7 @@ func TestKnowledgeBaseOperations(t *testing.T) {
181181
}
182182

183183
// Confirm entity removal
184-
graph, _ = kb.readGraph()
184+
graph, _ = kb.loadGraph()
185185
if len(graph.Entities) != 1 || graph.Entities[0].Name != "Bob" {
186186
t.Errorf("expected only Bob to remain after deleting Alice, got %+v", graph.Entities)
187187
}

0 commit comments

Comments
 (0)