Skip to content

Commit 6a147e9

Browse files
authored
Merge pull request #40 from HelgDemidov/dependabot/pip/python-patch-minor-294dccc211
chore(deps): bump the python-patch-minor group across 1 directory with 5 updates
2 parents 9b33218 + 71bcda3 commit 6a147e9

3 files changed

Lines changed: 26 additions & 16 deletions

File tree

refigure/mcp/server.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from mcp.server import MCPServer
3232
from mcp.server.auth.settings import AuthSettings
3333
from mcp.server.mcpserver import Context
34-
from mcp.server.mcpserver.exceptions import ResourceNotFoundError
34+
from mcp.server.mcpserver.exceptions import ResourceNotFoundError, ToolError
3535
from mcp.types import (
3636
CallToolResult,
3737
Completion,
@@ -551,7 +551,7 @@ def _redact(text: str) -> str:
551551
def _classify_exception(exc: Exception, *, transport: Literal["stdio", "http"]) -> str:
552552
"""The one place an exception becomes a stable, transport-redacted
553553
string — shared by ``_call_and_wrap_errors`` (below, which wraps it in
554-
``RuntimeError`` for a single-item tool call) and phase 4's
554+
``ToolError`` for a single-item tool call) and phase 4's
555555
``_run_batch_item`` (which stores it directly as
556556
``BatchItemOutput.error``, never raising it at all — per-item
557557
isolation, ``docs/mcp-server/mcp-server-phase4-batch-progress/
@@ -582,27 +582,37 @@ async def _call_and_wrap_errors(
582582
"""The one place every single-item tool call's exceptions are
583583
classified and formatted — not a decorator (see
584584
``_run_convert_tool``'s docstring). Refigure's typed exceptions become
585-
``RuntimeError("ClassName: message")`` so a calling agent can branch
586-
on the class name, mirroring ``cli.py``'s ``_exit_code_for`` —
587-
``MCPServer``'s own ``@mcp.tool()`` wrapper catches a plain exception
588-
raised here and reports it as ``isError=True`` with the exception text
589-
as content (confirmed against this ``mcp`` version's docs), so raising
590-
is sufficient, no manual ``CallToolResult`` construction needed.
585+
``ToolError("ClassName: message")`` so a calling agent can branch on
586+
the class name, mirroring ``cli.py``'s ``_exit_code_for``.
587+
588+
Raised as the SDK's own ``mcp.server.mcpserver.exceptions.ToolError``,
589+
not a bare ``RuntimeError``/``ValueError`` — as of ``mcp`` 2.1 (this
590+
project's own floor is ``mcp>=2.0,<3``, so both must work),
591+
``Tool.run()`` only keeps an exception's message visible to the
592+
caller for ``ToolError``/``ResourceError``; anything else is treated
593+
as a crash and collapses to a bare ``"Error executing tool <name>"``
594+
with no detail (``UnexpectedToolError`` — confirmed live: this is
595+
exactly what broke every test in this module on the mcp 2.0.0->2.1.1
596+
bump). ``ToolError`` existed already in 2.0.0 too, where it changes
597+
nothing — that version's ``Tool.run()`` wrapped every exception
598+
uniformly regardless of type. Same discipline this project's own
599+
resource-template handler already follows via ``ResourceNotFoundError``
600+
(see this module's other exceptions import) — now extended to tools.
591601
``transport`` is threaded through already, unused on the only
592602
transport phase 1 had (``"stdio"``) — phase 3 extended this for HTTP,
593603
phase 4 extends it a third time for ``convert_batch`` (via
594604
``_classify_exception``, shared below), never rewriting it, per
595605
architecture doc §8."""
596606
try:
597607
return await coro
598-
except ValueError:
608+
except ValueError as exc:
599609
# Input-validation failures from _run_convert_tool itself — already
600610
# a clean, stable message (see _classify_exception's own
601611
# docstring for why this case is excluded from it here), nothing
602612
# further to classify.
603-
raise
613+
raise ToolError(str(exc)) from exc
604614
except Exception as exc: # noqa: BLE001 - unexpected exceptions are the real-bug signal, see _classify_exception
605-
raise RuntimeError(_classify_exception(exc, transport=transport)) from exc
615+
raise ToolError(_classify_exception(exc, transport=transport)) from exc
606616

607617

608618
def _register_convert_docx(

requirements-dev.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# mypy refigure
55
# pytest --cov --cov-report=term-missing
66
-r requirements.txt
7-
ruff==0.16.4
7+
ruff==0.16.5
88
mypy==2.3.1
99
pytest==9.1.1
1010
pytest-cov==7.1.0
@@ -14,11 +14,11 @@ types-openpyxl==3.1.5.20260827
1414
# in the source pipeline). Installed here so the dev/test environment covers that code path;
1515
# NOT declared as a hard dependency of any published extra.
1616
mermaidx==0.9.4
17-
hypothesis==6.165.10
17+
hypothesis==6.167.0
1818
# mcp — pulled in for the dev/test environment same as mermaidx above (not
1919
# a hard dependency of any extra except [mcp] itself); pins anyio/starlette/
2020
# uvicorn transitively.
21-
mcp==2.0.0
21+
mcp==2.1.1
2222
# httpx — tests/unit/mcp/test_http.py drives the MCP HTTP transport in-process
2323
# via httpx.AsyncClient/httpx.ASGITransport. Not a hard dependency of any
2424
# extra (mcp>=2.0 itself already depends on httpx2, not this) — until

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ mammoth==1.12.1 # DOCX -> HTML (refigure/docx.py), [docx] extra
66
markdownify==1.2.3 # HTML -> Markdown (refigure/docx.py), [docx] extra
77
openpyxl==3.1.5 # XLSX read + chart access (refigure/xlsx.py), [xlsx] extra
88
pdfplumber==0.11.10 # docx-group soffice-render crop (refigure/vlm.py), [vlm] extra
9-
openai==3.3.1 # OpenAIClient (refigure/vlm/client.py), [vlm-direct] extra
10-
anthropic==1.0.0 # AnthropicClient (refigure/vlm/client.py), [vlm-direct] extra
9+
openai==3.6.0 # OpenAIClient (refigure/vlm/client.py), [vlm-direct] extra
10+
anthropic==1.2.0 # AnthropicClient (refigure/vlm/client.py), [vlm-direct] extra

0 commit comments

Comments
 (0)