"Cannot read properties of undefined (reading 'toLowerCase')" Error
Description
The search_nodes function in the MCP memory server fails with a JavaScript error when attempting to search the knowledge graph. The error indicates that the search function is trying to call .toLowerCase() on an undefined value without proper input validation.
Error Message
MCP error -32603: Cannot read properties of undefined (reading 'toLowerCase')
Environment
- OS: macOS (using Homebrew)
- Node.js version: v23.11.0
- MCP Memory Server version: Latest (installed via npx)
- Client: Claude Desktop and Claude Code
Configuration
{
"memory": {
"command": "/opt/homebrew/bin/npx",
"args": ["-y", "@modelcontextprotocol/server-memory"]
}
}
The MCP server was also added to Claude Code using:
claude mcp add-from-claude-desktop
Steps to Reproduce
- Set up MCP memory server with the above configuration
- Create some entities in the knowledge graph (this works fine)
- Attempt to use the
search_nodesfunction with any query string - Error occurs consistently in both Claude Desktop and Claude Code environments
Expected Behavior
The search_nodes function should successfully search through entity names, types, and observation content, returning relevant matches.
Actual Behavior
The function throws a JavaScript error and fails to return any results.
Workarounds
read_graphfunction works correctlyopen_nodesfunction works correctly when entity names are known- The issue is isolated to the search functionality
Additional Context
This appears to be related to insufficient input validation in the search function. The error suggests that the function attempts to call .toLowerCase() on a parameter that is undefined or null.
A similar error pattern has been reported with .includes() method: "Cannot read properties of undefined (reading 'includes')" indicating a broader input validation issue in the memory server's search implementation.
Impact
This bug prevents users from effectively searching their knowledge graphs, limiting the utility of the memory server for knowledge retrieval operations.
This issue was reported with assistance from Claude (Anthropic).