Skip to content

Silent except Exception: pass in MCP tools hides errors from callers #339

@wuxiwei

Description

@wuxiwei

Labels: bug, developer-experience

Description

Multiple MCP tool functions in mcp_server.py use except Exception: pass to catch and silently discard errors. This makes debugging extremely difficult — tools return seemingly valid but empty results with no indication that an error occurred.

Affected Functions

Function Lines (v3.0.0) Impact
tool_status wings/rooms aggregation wings: {}, rooms: {} returned silently
tool_list_wings full function body {"wings": {}} returned silently
tool_list_rooms full function body {"rooms": {}} returned silently
tool_get_taxonomy full function body {"taxonomy": {}} returned silently

Impact

When ChromaDB encounters an internal error (e.g., HNSW segment corruption on large collections), these functions return empty results ({}) instead of reporting the error. The AI caller has no way to distinguish between:

  • "The palace is genuinely empty" (valid state)
  • "An error occurred while reading the palace" (bug / corruption)

This is especially problematic because mempalace_status is typically the first tool called on session start. If it returns wings: {}, the AI assumes the palace is empty and skips querying it — even though mempalace_search would return valid results.

Suggested Fix

At minimum, return an error field when an exception occurs:

try:
    all_meta = col.get(include=["metadatas"])["metadatas"]
    for m in all_meta:
        w = m.get("wing", "unknown")
        wings[w] = wings.get(w, 0) + 1
except Exception as e:
    return {"wings": wings, "error": str(e), "partial": True}

Or use Python's logging module:

import logging
logger = logging.getLogger("mempalace")

except Exception as e:
    logger.warning(f"Failed to aggregate wings: {e}")

Why This Matters

MemPalace is designed to be used by AI agents via MCP. AI agents rely on tool return values to make decisions. Silent failures that return valid-looking but incorrect data cause the AI to make wrong assumptions about the palace state, which defeats the purpose of the memory system.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions