Repository navigation
Closed
Labels
Milestone
Description
Summary
Core raises the legacy MCP SDK ToolError from mcp.server.fastmcp.exceptions, even though the server runtime is FastMCP 3.x and hosted middleware handles fastmcp.exceptions.ToolError.
Those are different Python classes. As a result, a structured hosted API error can escape the Cloud middleware as a bare tool failure instead of being converted into the intended friendly MCP result.
Evidence
Core currently imports the legacy class in the shared HTTP helper:
src/basic_memory/mcp/tools/utils.py:33- several individual tools and project-context paths use the same import
Under the currently locked dependencies:
from fastmcp.exceptions import ToolError as FastMCPToolError
from mcp.server.fastmcp.exceptions import ToolError as LegacyToolError
assert LegacyToolError is not FastMCPToolError
assert not issubclass(LegacyToolError, FastMCPToolError)The concrete hosted failure is:
- Cloud's tenant API returns a structured
403 subscription_requiredresponse with a subscribe URL. - Core's HTTP helper catches
httpx.HTTPStatusErrorand wraps it in the legacy SDKToolError. - Cloud middleware catches the FastMCP runtime
ToolError. - The class mismatch bypasses conversion, so tools such as
recent_activitysurface onlyActive subscription requiredinstead of the actionable subscription result.
Cloud can temporarily recognize both classes, but Core should emit the exception type owned by its active FastMCP runtime.
Proposed fix
- While Core remains on FastMCP 3.x, replace legacy
mcp.server.fastmcp.exceptions.ToolErrorimports withfastmcp.exceptions.ToolErroracross the MCP tool/runtime surface. - Keep the original
httpx.HTTPStatusErroras the explicit cause so hosted middleware can inspect structured response details. - Add a focused regression test proving the shared HTTP helper raises the FastMCP runtime class and preserves the HTTP cause.
- Audit tests and deferred imports that still name the legacy SDK class.
Acceptance criteria
- Core MCP tools consistently raise the
ToolErrorclass expected by the active FastMCP runtime. - Shared HTTP helpers preserve
httpx.HTTPStatusErroras__cause__. - Hosted middleware can catch a Core tool error without a compatibility import for the legacy MCP SDK class.
- Unrelated tool errors continue to fail loudly.
- Focused MCP tests and repository checks pass.
Related
- feat(mcp): adopt FastMCP 4 beta and validate hosted MCP Apps #1181 tracks the FastMCP 4 beta port. That port may use a different supported exception path; this issue is the narrower current-runtime bug and should not wait on the full upgrade.
- basicmachines-co/basic-memory-cloud#1666 exposed the inconsistent agent-facing subscription error while testing hosted MCP tools.
Activity
claude commentedon Aug 5, 2026
Claude finished @phernandez's task in 1m 55s —— View job
Triage complete
Classification
bug)recent_activitysubscription check) is currently surfacing as a bare tool error instead of the intended actionable/friendly result, because Core raisesmcp.server.fastmcp.exceptions.ToolErrorwhile Cloud's middleware catchesfastmcp.exceptions.ToolError. No repopriority:*labels exist to apply, so this is reflected here in the comment.mcp/tools/*.py,mcp/project_context.py, severalcli/commands/*.py) and ~15 test files that import the legacy class, so it needs a careful audit pass rather than a single-line patch. No repocomplexity:*labels exist to apply.Verification
I confirmed the evidence in the issue against the current
mainbranch — the legacy importfrom mcp.server.fastmcp.exceptions import ToolErroris indeed still present atsrc/basic_memory/mcp/tools/utils.py:33, plus inedit_note.py,move_note.py,build_context.py,read_content.py,delete_note.py,project_context.py(x2), and severalcli/commands/*.pyfiles, along with ~15 test files. The issue's root-cause analysis is accurate and reproducible from the code as described.Duplicate check
No existing open/closed issue duplicates this. #1181 (FastMCP 4 beta port) is related but distinct in scope, as the issue itself already notes — this bug is about the current FastMCP 3.x runtime and shouldn't wait on that upgrade.
Labels applied
production— this is an observed production bug (hostedrecent_activitysubscription error surfacing incorrectly), not just a theoretical mismatchcloud— the failure mode only manifests at the Core/Cloud middleware boundaryNote: the repo's actual label set doesn't include
mcp,mcp-tool, priority tiers (high/medium/low), or complexity tiers (simple/medium/complex) mentioned in the triage instructions — I verified the real taxonomy viagh search issues(labels in use:bug,production,enhancement,cloud,documentation,duplicate,arch-review,needs investigation,v1.0,On Hold) and only applied labels that exist.Per triage scope, no code changes, branches, or commits were made — this is a well-specified bug with clear reproduction/evidence and a proposed fix already in the issue body, ready for implementation in a follow-up.
phernandez commentedon Aug 5, 2026
@claude make a pr
claude commentedon Aug 5, 2026
Claude finished @phernandez's task in 10m 4s —— View job •
claude/issue-1197-20260805-2002• Create PR ➔Tasks
mcp.server.fastmcp.exceptions.ToolErrorusages (source + tests)fastmcp.exceptions.ToolErroracross MCP tool/runtime surfacehttpx.HTTPStatusErroras__cause__Summary
Swapped every legacy
mcp.server.fastmcp.exceptions.ToolErrorimport forfastmcp.exceptions.ToolErroracross the MCP tool/runtime surface:mcp/tools/utils.py,edit_note.py,move_note.py,delete_note.py,read_content.py,build_context.py,mcp/project_context.pysearch-notes→ slow SessionStart brief #886):cli/commands/command_utils.py,doctor.py,orphans.py,status.py— kept these deferred, just repointed the module path and updated the commentThe existing
raise ToolError(...) from epattern inmcp/tools/utils.pyalready preserved thehttpx.HTTPStatusErrorcause, so no behavior change was needed there — only the exception class. Added a regression test intests/mcp/test_tool_utils.py(test_call_get_error_raises_fastmcp_runtime_tool_error) assertingcall_getraises the FastMCP runtimeToolError(not the legacy SDK class) with the cause preserved.Verification
just fast-check(lint + format): passes.typecheckreports 4 pre-existingpymilvusunresolved-import errors — unrelated to this change (optional dependency not installed in this sandbox).pytestacross all touched MCP/CLI test files: 257 passed.just doctor(end-to-end file↔DB loop): passes, exercising theToolError-catching path incli/commands/doctor.py.basic_memory.mcp.tools.utils.ToolErroris nowfastmcp.exceptions.ToolError, distinct from the legacymcp.server.fastmcp.exceptions.ToolErrornamed in the issue.