Skip to content

Conversation

@caizhiqiangzeyuan
Copy link

@caizhiqiangzeyuan caizhiqiangzeyuan commented Jun 9, 2025

fix the bug 2044

Description

1.Safer Query Handling:
Since query is typed as string, we skip unnecessary safety checks and directly process it with lowerQuery = query.trim().toLowerCase()

2.Extracted Matching Logic:
Created reusable checkMatch helper that encapsulates:
Type checking (typeof text === 'string')
Normalization (trim()+toLowerCase())
Search logic (includes())

3.Performance Optimizations:
Pre-computes lowerQuery once instead of per-filter iteration
Eliminates repeated arrow function creation in array operations

4.Improved Readability:
Flattened nested conditions
Clear separation of concerns between filtering steps
More descriptive variable names

Server Details

  • Server: 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.
  • Changes to: Map to safe lower case

Motivation and Context

bug address

How Has This Been Tested?

Yes, Cursor and Claude.

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • I have updated the server's README accordingly
  • I have tested this with an LLM client
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options

Additional context

@olaservo olaservo added server-memory Reference implementation for the Memory MCP server - src/memory bug Something isn't working labels Jun 13, 2025
Copy link
Member

@domdomegg domdomegg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this fix, I'd prefer we figure out the root cause of non-strings ending up here. E.g. insufficient input validation to the tools, or knowledge graphs being corrupted for some reason - and fix that.

@domdomegg
Copy link
Member

Hey, thanks for the contribution! This hasn't been updated for a while, so I'm closing it to help us more easily track active contributions. If you're still interested in working on this, please feel free to reopen it. Thanks again for your contribution!

@domdomegg domdomegg closed this Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working server-memory Reference implementation for the Memory MCP server - src/memory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants