fix(task-14): return the plain point list from COM system_set_variable, not the VARIANT
The tuple/list branch put the win32com VARIANT built for SetVariable into the
returned dict. The system_set_variable tool returns that dict verbatim under
output_schema {"type": "object"}; pydantic cannot serialise a VARIANT, FastMCP
drops the structured content and the client sees "outputSchema defined but no
structured output returned" -- after AutoCAD had already applied the write, so
every raw point-variable write (LIMMIN, LIMMAX, GRIDUNIT, SNAPUNIT, INSBASE)
was a retry/undo trap on the live engine while the audit log said TOOL OK.
The VARIANT is now only the SetVariable argument; "value" carries the
coerced Python list. The fake-ActiveX test asserts the reply, and a new
Client(server.mcp) test drives the tool through the output schema so the
serialisation path is covered.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
This commit is contained in:
co-authored by
Claude Opus 5
parent
e8e7e3c524
commit
df2ab91900
@@ -4003,6 +4003,12 @@ class ComBackend(AutoCADBackend):
|
||||
# AutoCAD rejects e.g. a string "0" for the integer OSMODE. Probe the
|
||||
# current value's type and convert to match; pass through on failure.
|
||||
coerced = value
|
||||
# `payload` is what SetVariable receives. It differs from `coerced`
|
||||
# only for point variables, whose VARIANT wrapper must never reach
|
||||
# the returned dict: pydantic cannot serialise
|
||||
# win32com.client.VARIANT, so the tool would report failure *after*
|
||||
# AutoCAD had already applied the write.
|
||||
payload = value
|
||||
try:
|
||||
current = app.GetVariable(name)
|
||||
if isinstance(current, bool):
|
||||
@@ -4017,10 +4023,11 @@ class ComBackend(AutoCADBackend):
|
||||
# a bare Python tuple is marshalled as VT_VARIANT and rejected.
|
||||
coords = [float(v) for v in value]
|
||||
coords += [0.0] * (len(current) - len(coords))
|
||||
coerced = _av(coords[: len(current)])
|
||||
coerced = coords[: len(current)]
|
||||
payload = _av(coerced) if isinstance(current, (tuple, list)) else coerced
|
||||
except Exception as exc:
|
||||
log.debug("set_variable type probe for %s failed: %s", name, exc)
|
||||
app.SetVariable(name, coerced)
|
||||
app.SetVariable(name, payload)
|
||||
return {"ok": True, "variable": name, "value": coerced}
|
||||
|
||||
return await self._run(_sync)
|
||||
|
||||
Reference in New Issue
Block a user