Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ export class KnowledgeGraphManager {

async getNeighbors(
entityName: string,
depth: number = 1,
depth: number = 0,
sortBy?: EntitySortField,
sortDir?: SortDirection,
direction: 'forward' | 'backward' | 'any' = 'forward'
Expand Down Expand Up @@ -1690,7 +1690,7 @@ The file MUST be plaintext (.txt, .tex, .md, source code, etc.). For PDFs, use p
return { content: [{ type: "text", text: JSON.stringify(paginateGraph(graph, args.entityCursor as number ?? 0, args.relationCursor as number ?? 0)) }] };
}
case "get_neighbors": {
const neighbors = await knowledgeGraphManager.getNeighbors(args.entityName as string, args.depth as number ?? 1, args.sortBy as EntitySortField | undefined, args.sortDir as SortDirection | undefined, (args.direction as 'forward' | 'backward' | 'any') ?? 'forward');
const neighbors = await knowledgeGraphManager.getNeighbors(args.entityName as string, args.depth as number ?? 0, args.sortBy as EntitySortField | undefined, args.sortDir as SortDirection | undefined, (args.direction as 'forward' | 'backward' | 'any') ?? 'forward');
// Record walker visits for returned neighbors
knowledgeGraphManager.recordWalkerVisits(neighbors.map(n => n.name));
return { content: [{ type: "text", text: JSON.stringify(paginateItems(neighbors, args.cursor as number ?? 0)) }] };
Expand Down
16 changes: 16 additions & 0 deletions tests/memory-server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,22 @@ describe('MCP Memory Server E2E Tests', () => {
expect(names).toContain('Child2');
});

it('omitted depth must equal the schema default (0 = immediate only)', async () => {
// Bug_DepthDefaultMismatch_2026_08_23: the handler defaulted to 1 while
// the tool schema advertises 0, so omitted-depth calls silently returned
// TWO-hop neighborhoods. This pins the default path itself — the
// explicit-depth tests above cannot catch a default divergence.
const result = await callTool(client, 'get_neighbors', {
entityName: 'Root'
}) as PaginatedResult<Neighbor>;

expect(result.items).toHaveLength(2);
const names = result.items.map(n => n.name);
expect(names).toContain('Child1');
expect(names).toContain('Child2');
expect(names).not.toContain('Grandchild');
});

it('should get neighbors at depth 1 (includes neighbors of neighbors)', async () => {
const result = await callTool(client, 'get_neighbors', {
entityName: 'Root',
Expand Down
Loading