Skip to content

Bug: MCP tool handlers called without await - returns empty objects #2

@lukegibson20

Description

@lukegibson20

Description

The MCP server's tool handlers are async functions but are called without await in src/mcp/server.ts. This causes all MCP tools (get_rules, get_pending_rules, etc.) to return {} instead of actual data.

Root Cause

In src/mcp/server.ts, lines ~200-250:

case 'get_rules': {
  const parsed = GetRulesInputSchema.parse(args);
  const result = handleGetRules(parsed);  // ← Missing await!
  return {
    content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
  };
}

Since handleGetRules is defined as async function, calling it without await returns a Promise. When JSON.stringify serializes a Promise, it outputs {}.

Impact

  • get_rules returns {} instead of { rules: [...] }
  • get_pending_rules returns {} instead of { rules: [...] }
  • All MCP tools return empty objects instead of actual data

Reproduction

  1. Install claude-learner v2.0.0
  2. Log a correction via log_correction tool
  3. Call get_rules or get_pending_rules
  4. Observe empty {} response

Fix

Add await to all handler calls in src/mcp/server.ts:

case 'get_rules': {
  const parsed = GetRulesInputSchema.parse(args);
  const result = await handleGetRules(parsed);  // ← Add await
  return {
    content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
  };
}

Same fix needed for: handleCheckRule, handleLogCorrection, handleGetPendingRules, handleApproveRule, handleRejectRule, handleRecordCompliance

Workaround

Use CLI commands (claude-learner rules) or query SQLite directly until fixed.

Environment

  • claude-learner v2.0.0
  • Node v22.21.1
  • Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions