Skip to content

fix(mcp): give tool errors structured content that fits the output schema - #2098

Merged
phernandez merged 11 commits into
mainfrom
fix/2094-tool-error-surface
Nov 12, 2026
Merged

phernandez merged 11 commits into
mainfrom
fix/2094-tool-error-surface

Conversation

@phernandez

Copy link
Copy Markdown
Member

Stack 3/4, based on #2097.

Why

Our server already answers a refusal with isError: true, the message as text, and no structuredContent (checked on the wire over streamable HTTP). That is valid MCP. The reporter's client or gateway received structuredContent: null and failed output-schema validation, so the caller saw a Zod error instead of "a note already exists at …".

What

  • ToolErrorResultMiddleware catches ToolError and returns the same text and isError, plus {"result": "<message>"} as structured content. It acts only when the tool's output schema is FastMCP's wrapped result and that schema accepts a string; otherwise the error passes through unchanged.
  • Registered outside MissingProjectMiddleware, so its refusals are covered too.
  • A test checks that every bm_* tool with an output schema accepts the message. bm_read publishes no output schema, so it is left as is.

Closes #2094

Verification

  • just fast-check
  • just fast-test on the top of the stack (-m "not semantic and not benchmark"): 3993 passed, 21 skipped. Postgres runs in CI.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CMYVL1rjJwNnrvxniz1dDD

phernandez and others added 3 commits November 11, 2026 20:25
pybars3 is unmaintained and carries CVE-2026-119716 (code injection when
an attacker controls template source). Basic Memory only used it to render
two fixed prompt templates for the v2 prompt routes, so plain Python now
builds that text and inserts the query and note text as values. The
template loader, the .hbs files, pybars3 and pymeta3 are gone.

Closes #2044

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL1rjJwNnrvxniz1dDD
Signed-off-by: phernandez <paul@basicmachines.co>
`bm cloud sync-setup` compared the typed name to cloud project names exactly,
while pull and push match by permalink. `sync-setup cesar` failed for a cloud
project named `Cesar`, and `pull --name cesar` then found the cloud project
but missed its local entry and pointed back at the sync-setup that had failed.

sync-setup now resolves the cloud project by permalink and saves the entry
under the cloud spelling, or under an existing entry's key. Every config
lookup in the transfer commands matches by permalink too.

Closes #2078

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL1rjJwNnrvxniz1dDD
Signed-off-by: phernandez <paul@basicmachines.co>
…hema

A refused call came back as isError with the message as text and no
structured content. That is valid MCP, but the bm_* tools advertise an
output schema, and a client or gateway that validates structured content on
every result replaced the refusal with a schema error. The caller could not
tell that the note already existed or where.

A middleware now returns tool errors with the same text and isError, plus
the message as {"result": "..."}, which every bm_* output schema accepts.
Tools whose schema cannot hold the message keep FastMCP's plain error.

Closes #2094

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL1rjJwNnrvxniz1dDD
Signed-off-by: phernandez <paul@basicmachines.co>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T16:39:57.170963Z 4fef8a2 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…background (#2099)

Stack 4/4, based on #2098.

## Why
#2000's second request: the background checks (MCP startup, the periodic
CLI check) install any newer release, including a new major version. A
major release can remove tools and settings people rely on, as 1.0
removed the legacy tool names. The pinned-install half of #2000 landed
in #2040.

## What
- A background check (`force=False`) that finds a new major version
returns `UPDATE_AVAILABLE` with the release-notes link and "run `bm
update`". `bm update` passes `force` and still installs it. Minor and
patch releases install as before.
- There is no setting: background checks never install a major version.
Say if you want it configurable.
- Existing upgrade tests used `9.9.9` as the latest version, which is
now a major jump from 1.0.0. They use `1.9.9` instead.
- Note: the two new flow tests use this file's existing PyPI stub
(monkeypatch), because `run_auto_update` has no other seam.
`is_major_upgrade` is tested directly.

Closes #2000

## Verification
- `just fast-check`
- `just fast-test` on the top of the stack (`-m "not semantic and not
benchmark"`): 3993 passed, 21 skipped. Postgres runs in CI.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01CMYVL1rjJwNnrvxniz1dDD

---------

Signed-off-by: phernandez <paul@basicmachines.co>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@phernandez
phernandez changed the base branch from fix/2078-sync-setup-project-case to main November 12, 2026 16:24
@phernandez
phernandez changed the base branch from main to fix/2078-sync-setup-project-case November 12, 2026 16:24
phernandez and others added 7 commits November 12, 2026 10:24
Signed-off-by: phernandez <paul@basicmachines.co>

# Conflicts:
#	pyproject.toml
…-case

Signed-off-by: phernandez <paul@basicmachines.co>
…ror-surface

Signed-off-by: phernandez <paul@basicmachines.co>
#2104 dropped the scope list from the title check, and this test still
read it, so unit tests on main fail with KeyError: 'scopes'. That PR's CI
skipped the unit tests because it only touched a workflow file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016N9c6ouiT4Wid3arGR41Dv
Signed-off-by: phernandez <paul@basicmachines.co>
…x/2044-drop-pybars3

Signed-off-by: phernandez <paul@basicmachines.co>
…-case

Signed-off-by: phernandez <paul@basicmachines.co>
…ror-surface

Signed-off-by: phernandez <paul@basicmachines.co>
Base automatically changed from fix/2078-sync-setup-project-case to main November 12, 2026 16:53
@phernandez
phernandez merged commit 4cb3058 into main Nov 12, 2026
38 of 39 checks passed
@phernandez
phernandez deleted the fix/2094-tool-error-surface branch November 12, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Return and surface a readable domain error when structuredContent is null

1 participant