Skip to content

Conversation

@enthali
Copy link

@enthali enthali commented Jul 8, 2025

Summary

This PR adds a new get_node_relations function to the MCP memory server that enables efficient graph traversal by retrieving all incoming and outgoing relations for a specific node without loading the entire graph.

Changes

  • New function: getNodeRelations in KnowledgeGraphManager class
  • New MCP tool: get_node_relations exposed via the server API
  • Documentation: Updated README.md with API documentation for the new function
  • Tool registration: Added to .github/mcp.json for discoverability

Implementation Details

Input

  • nodeName (string): The name of the entity to get relations for

Output

  • outgoing (array): Relations where this node is the source
  • incoming (array): Relations where this node is the target
  • connected_entities (string[]): Names of all connected entities

Use Cases

  • Graph traversal without loading entire graph
  • Finding connected entities efficiently
  • Building relationship maps for specific nodes
  • Performance optimization for large knowledge graphs

Testing

The implementation has been tested locally with:

  • Existing nodes with multiple relations
  • Nodes with no relations (returns empty arrays)
  • Non-existent nodes (returns empty structure)

Files Changed

  • src/memory/index.ts: Core implementation
  • src/memory/README.md: API documentation

This enhancement maintains backward compatibility and follows existing code patterns in the memory server.

- Implements new get_node_relations tool that returns incoming/outgoing relations for a specific node
- Enables efficient graph traversal without loading entire knowledge graph
- Returns connected entity names for further exploration
- Solves limitation where search_nodes and open_nodes only show relations between filtered results
- Updated README with comprehensive API documentation
@olaservo olaservo added server-memory Reference implementation for the Memory MCP server - src/memory enhancement New feature or request labels Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request server-memory Reference implementation for the Memory MCP server - src/memory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants