thedotmack/claude-mem · warning

observation_add: "content" is required

Error message

observation_add: "content" is required

What it means

handleObservationAdd validates its arguments before forwarding to the server: the 'content' field must be a non-empty, non-whitespace string. If it's missing, not a string, or blank after trimming, the handler throws `observation_add: "content" is required`, which wrapHandler converts into an MCP error result. It's a plain argument-validation error on the tool's input schema.

Solutions

  1. Pass a non-empty string in the `content` field of the observation_add arguments.
  2. Trim-check the value client-side before calling the tool; skip the call when empty.
  3. Verify the payload key is exactly `content` (not `text`/`observation`) and that it's a string, not a number or object.
  4. If content comes from an upstream step, guard that step's output so empty results don't produce the tool call.

Example fix

// before
await observation_add({ projectId: 'p1' });
// after
const content = extractedNote.trim();
if (content) await observation_add({ projectId: 'p1', content });
Defensive patterns

Strategy: validation

Validate before calling

function canCallObservationAdd(args: { content?: unknown } | undefined): args is { content: string } {
  return typeof args?.content === 'string' && args.content.trim().length > 0;
}

Type guard

function hasNonEmptyContent(args: unknown): args is { content: string } {
  return typeof args === 'object' && args !== null
    && 'content' in args
    && typeof (args as { content: unknown }).content === 'string'
    && (args as { content: string }).content.trim().length > 0;
}

Try / catch

try {
  await observation_add(args);
} catch (err) {
  if ((err as Error).message === 'observation_add: "content" is required') {
    // skip or queue the observation; do not retry with the same payload
  }
}

Prevention

When it happens

Trigger: Calling the observation_add MCP tool with args omitted, args.content undefined/null/non-string, or args.content set to "" or whitespace-only (e.g. " ").

Common situations: An agent constructing the tool call with an empty variable because upstream extraction found nothing; JSON payloads where content sits under a different key (e.g. 'text' or 'observation'); programmatic callers passing a number/object instead of a string; template rendering leaving the field blank.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17). Data as JSON: /api/errors/769e7fa0701ea08d. Report an issue: GitHub.

Appendix: source

Thrown at src/servers/mcp-server.ts:246

      return formatToolError(error);
    }
  };
}

interface ObservationAddArgs {
  projectId?: string;
  serverSessionId?: string | null;
  contentSessionId?: string | null;
  platformSource?: string | null;
  kind?: string;
  content: string;
  metadata?: Record<string, unknown>;
}

const handleObservationAdd = wrapHandler('observation_add', async (args: ObservationAddArgs) => {
  const ctx = requireServerForObservationTool('observation_add');
  if (typeof args?.content !== 'string' || args.content.trim().length === 0) {
    throw new Error('observation_add: "content" is required');
  }
  const projectId = args.projectId && args.projectId.trim().length > 0 ? args.projectId : ctx.projectId;
  const request: ServerAddObservationRequest = {
    projectId,
    content: args.content,
    ...(args.serverSessionId !== undefined ? { serverSessionId: args.serverSessionId } : {}),
    ...(args.contentSessionId !== undefined ? { contentSessionId: args.contentSessionId } : {}),
    ...(args.platformSource !== undefined ? { platformSource: args.platformSource } : {}),
    ...(args.kind !== undefined ? { kind: args.kind } : {}),
    ...(args.metadata !== undefined ? { metadata: args.metadata } : {}),
  };
  const response = await ctx.client.addObservation(request);
  return formatJsonResult(response);
});

interface ObservationRecordEventArgs {
  projectId?: string;
  serverSessionId?: string | null;

View on GitHub (pinned to d8bc9755e7)