Skip to content

Conversation

@DukeDeSouth
Copy link

@DukeDeSouth DukeDeSouth commented Feb 7, 2026

Human View

Summary

Fixes #3137open_nodes returns empty relations array despite entity having relations in graph.

Root cause: Both openNodes() and searchNodes() filter relations using && (require BOTH endpoints to be in the result set). This means if you call open_nodes(["A"]) and there's a relation A → B, it gets silently dropped because B isn't in the filtered set.

Fix: Changed the relation filter from && to || — include any relation where at least one endpoint is in the result set. This matches standard graph-query semantics: opening a node should reveal all its edges, not just edges to other opened nodes.

Before (broken)

open_nodes(["2025-12-17"])
→ entities: [2025-12-17], relations: []  // relations silently dropped!

After (fixed)

open_nodes(["2025-12-17"])
→ entities: [2025-12-17], relations: [{from: "2025-12-17", to: "incident/example", ...}]

Changes

  • src/memory/index.ts: Changed &&|| in relation filtering for both openNodes() and searchNodes()
  • src/memory/__tests__/knowledge-graph.test.ts: Updated existing tests and added new cases:
    • Outgoing relations to nodes not in the open set
    • Incoming relations from nodes not in the open set
    • Relations connected to a single opened node (both directions)
    • searchNodes returning outgoing relations to unmatched entities

Test plan

  • All 45 existing tests pass (vitest run)
  • New tests verify outgoing/incoming relations are returned for single-node queries
  • read_graph behavior unchanged (returns all relations)
  • Empty node list still returns empty graph
  • Non-existent nodes still return empty result

AI View (DCCE Protocol v1.0)

Metadata

  • Generator: Claude (Anthropic) via Cursor IDE
  • Methodology: AI-assisted development with human oversight and review

AI Contribution Summary

  • Solution design and implementation

Verification Steps Performed

  1. Reproduced the reported issue
  2. Analyzed source code to identify root cause
  3. Implemented and tested the fix
  4. Verified lint/formatting compliance

Human Review Guidance

  • Core changes are in: src/memory/index.ts, src/memory/__tests__/knowledge-graph.test.ts

Made with M7 Cursor

…es/searchNodes

Previously, `openNodes` and `searchNodes` only returned relations where
BOTH endpoints were in the result set (using `&&`). This silently
dropped all relations to/from nodes outside the set — making it
impossible to discover a node's connections without calling `read_graph`
and filtering the entire dataset client-side.

Changed the filter from `&&` to `||` so that any relation with at least
one endpoint in the result set is included. This matches the expected
graph-query semantics: when you open a node, you should see all its
edges, not just edges to other opened nodes.

Fixes modelcontextprotocol#3137

Tests updated and new cases added covering:
- Outgoing relations to nodes not in the open set
- Incoming relations from nodes not in the open set
- Relations connected to a single opened node
- searchNodes returning outgoing relations to unmatched entities

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory MCP open_nodes returns empty relations array despite entity having relations in graph

1 participant