Skip to content

fix: send messages in chat format in MCP add_memory tool#1275

Merged
CaralHsi merged 2 commits intoMemTensor:dev-20260323-v2.0.11from
brentkearney:fix/mcp-add-memory-message-format
Mar 26, 2026
Merged

fix: send messages in chat format in MCP add_memory tool#1275
CaralHsi merged 2 commits intoMemTensor:dev-20260323-v2.0.11from
brentkearney:fix/mcp-add-memory-message-format

Conversation

@brentkearney
Copy link
Copy Markdown
Contributor

@brentkearney brentkearney commented Mar 18, 2026

Description

The MCP add_memory tool in examples/mem_mcp/simple_fastmcp_serve.py passes memory_content as a plain string to the messages field in the /product/add API payload. The endpoint expects messages to be a list of chat message objects. When a plain string is passed, the SimpleStruct MemReader silently skips it — no error is raised, the API returns success, but no memory is actually stored.

The fix wraps the content as [{"role": "user", "content": memory_content}].

Related Issue (Required): Fixes #1274

Type of change

  • 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 not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

Test steps:

  1. Start MCP server with simple_fastmcp_serve.py
  2. Call add_memory tool with test content
  3. Call search_memories — verify memory is returned
  4. Before fix: search returns empty. After fix: memory is stored and retrievable.

Checklist

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have created related documentation issue/PR in MemOS-Docs (if applicable) | 我已在 MemOS-Docs 中创建了相关的文档 issue/PR(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

🤖 Generated with Claude Code

The /product/add endpoint expects messages as a list of chat message
objects, not a plain string. When passed a string, the SimpleStruct
MemReader silently skips it and no memory is stored.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@CaralHsi CaralHsi self-requested a review March 23, 2026 06:52
@CaralHsi CaralHsi changed the base branch from main to dev-20260323-v2.0.11 March 25, 2026 13:51
@CaralHsi CaralHsi merged commit f354acf into MemTensor:dev-20260323-v2.0.11 Mar 26, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: MCP add_memory tool silently fails to store memories

2 participants