The add_memory tool fails with a 422 Unprocessable Entity error when the sessionId parameter is omitted. This violates the documented behavior (and typical MCP expectations) where a missing sessionId should either be auto-generated or handled gracefully.
Steps to Reproduce:
- Ensure the Memory Core MCP server is running.
- Call
add_memory with valid prompt, thought, and response, but omit the sessionId.
- Observe the tool error:
Error executing add_memory: 422: Unprocessable Entity.
Root Cause Analysis:
The MemoryService.addMemory method likely attempts to insert undefined or null as the sessionId into the ChromaDB metadata. ChromaDB (or the validation layer) requires metadata values to be strings, numbers, or booleans, and strictly rejects undefined/null.
Proposed Fix:
Modify ai/mcp/server/memory-core/services/SessionService.mjs to manage a currentSessionId (UUID generated at startup). Update MemoryService to use this ID as a default when sessionId is missing. Expose this ID via HealthService for visibility.
Implemented Solution:
SessionService.mjs: Added currentSessionId (UUID) initialized at startup.
MemoryService.mjs: Updated addMemory to default to SessionService.currentSessionId if no sessionId is provided.
HealthService.mjs: Updated healthcheck to include the session.currentId in its response payload.
openapi.yaml: Updated documentation to reflect the optional sessionId parameter and the new session field in the healthcheck response.
Verification:
Verified that healthcheck returns the current session ID and that add_memory succeeds without a sessionId parameter, correctly using the default ID.
The
add_memorytool fails with a422 Unprocessable Entityerror when thesessionIdparameter is omitted. This violates the documented behavior (and typical MCP expectations) where a missingsessionIdshould either be auto-generated or handled gracefully.Steps to Reproduce:
add_memorywith validprompt,thought, andresponse, but omit thesessionId.Error executing add_memory: 422: Unprocessable Entity.Root Cause Analysis: The
MemoryService.addMemorymethod likely attempts to insertundefinedornullas thesessionIdinto the ChromaDB metadata. ChromaDB (or the validation layer) requires metadata values to be strings, numbers, or booleans, and strictly rejectsundefined/null.Proposed Fix: Modify
ai/mcp/server/memory-core/services/SessionService.mjsto manage acurrentSessionId(UUID generated at startup). UpdateMemoryServiceto use this ID as a default whensessionIdis missing. Expose this ID viaHealthServicefor visibility.Implemented Solution:
SessionService.mjs: AddedcurrentSessionId(UUID) initialized at startup.MemoryService.mjs: UpdatedaddMemoryto default toSessionService.currentSessionIdif nosessionIdis provided.HealthService.mjs: Updatedhealthcheckto include thesession.currentIdin its response payload.openapi.yaml: Updated documentation to reflect the optionalsessionIdparameter and the newsessionfield in the healthcheck response.Verification: Verified that
healthcheckreturns the current session ID and thatadd_memorysucceeds without asessionIdparameter, correctly using the default ID.