servers icon indicating copy to clipboard operation
servers copied to clipboard

"Cannot read properties of undefined (reading 'toLowerCase')" Error

Open egoes opened this issue 7 months ago • 0 comments

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

  1. Set up MCP memory server with the above configuration
  2. Create some entities in the knowledge graph (this works fine)
  3. Attempt to use the search_nodes function with any query string
  4. 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_graph function works correctly
  • open_nodes function 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).

egoes avatar Jun 08 '25 12:06 egoes