Skip to content

Bug: memory_store accepts missing/invalid content and memory_type without validation #211

Description

@guolvlin-cn

Summary

memory_store MCP tool silently accepts calls with:

  • Missing content field → returns 200 OK + "Stored memory : " (empty content persisted)
  • Invalid memory_type (e.g. "invalid_xyz") → returns 200 OK + persists with arbitrary type

This violates input validation contract and pollutes the memory pool with junk records.

Environment

  • Server: https://api.thememoria.ai (production)
  • MCP endpoint: POST /mcp (JSON-RPC 2.0)
  • Date observed: 2026-06-01
  • Tool version: 23 tools exposed via tools/list

Steps to Reproduce

Case 1: Missing content

curl -X POST https://api.thememoria.ai/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <token>" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory_store","arguments":{"memory_type":"working"}}}'

Expected: 422 / 400 with "content is required"
Actual: 200 OK + {"result":{"content":[{"text":"Stored memory 019e8285fcf07332af076c65cbdb7b91: ","type":"text"}]}} — empty record persisted

Case 2: Invalid memory_type

curl -X POST https://api.thememoria.ai/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <token>" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory_store","arguments":{"content":"x","memory_type":"invalid_xyz"}}}'

Expected: 422 / 400 with "memory_type must be one of: working|semantic|episodic|profile|procedural"
Actual: 200 OK + record persisted with memory_type: "invalid_xyz"

Impact

  • Data integrity: Empty / malformed records pollute the pool
  • No recovery at API level: The MCP memory_purge does work for these records, but they shouldn't exist in the first place
  • Hard to detect downstream: Search returns these records; downstream agents may consume them

Workaround

Clients must add their own pre-flight validation:

const VALID_TYPES = ['working', 'semantic', 'episodic', 'profile', 'procedural'];
if (!content || content.trim() === '') throw new Error('content required');
if (!VALID_TYPES.includes(memory_type)) throw new Error(`memory_type must be one of ${VALID_TYPES.join('|')}`);

Proposed Fix

  1. Schema-level validation: inputSchema.required should include content and memory_type; memory_type should be enum: ["working","semantic","episodic","profile","procedural"]
  2. Server-side validation: Return JSON-RPC error code -32602 (Invalid params) with descriptive message when validation fails
  3. Optional: Bulk-cleanup endpoint to remove records with empty content or invalid memory_type

Related

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions