arcade-mcp/libs/arcade-core
Eric Gustin 3204201360
fix: TypedDict total=False output breaks validation (#816)
When a tool’s output TypedDict uses total=False, MCP clients reject the
response with:
```
MCP error -32602: Structured content does not match the tool's output schema
```
Note that the bug also exists for the Engine transport
(/worker/tools/execute), but since the engine doesn't validate the
output schema, the bug never surfaced. This PR addresses the problem
holistically (MCP and Engine) in preparation for a future where the
Engine transport validates output schemas.

Two bugs combined to cause this:
1. Schema: The outputSchema had no required array and declared all
fields as strict types (e.g. "type": "string"), making every field look
mandatory and non-null.
2. Serialization: model_dump() on TypedDict-derived Pydantic models
emitted None for absent optional fields. A tool returning {"name":
"hello"} produced {"name": "hello", "optional_field": null} which is a
value the schema forbids.


<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Adjusts core schema generation and MCP JSON Schema conversion for
TypedDicts, affecting how tool input/output contracts are emitted and
validated across clients; mistakes could break compatibility or
validation behavior.
> 
> **Overview**
> Fixes MCP/engine validation failures for `TypedDict(total=False)`
outputs by ensuring absent optional keys are **omitted from serialized
output** and that emitted schemas correctly describe **required vs
optional** keys.
> 
> `arcade-core` now tracks `required_keys`/`inner_required_keys` and
per-field `nullable` in `ValueSchema`, derives required sets from
TypedDict `__required_keys__`, and unwraps `Optional[T]` to support
optional nested TypedDicts; TypedDict-derived Pydantic models now
`model_dump(exclude_unset=True)` to avoid leaking missing fields as
`null`.
> 
> `arcade-mcp-server` JSON Schema conversion now emits `required` arrays
(including for arrays of objects), supports `nullable` by generating
`type: [<type>, "null"]` (and `enum` including `None`), and treats
nullable top-level objects as valid unwrapped output schemas. Adds
focused unit/end-to-end tests plus an expanded example server
demonstrating total-false, mixed required/optional, nullable, and
optional-nested TypedDict outputs, and bumps package
versions/dependencies accordingly.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
53fe8365f613053599130520b75f30b614b465ca. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2026-04-09 17:47:57 -07:00
..
arcade_core fix: TypedDict total=False output breaks validation (#816) 2026-04-09 17:47:57 -07:00
pyproject.toml fix: TypedDict total=False output breaks validation (#816) 2026-04-09 17:47:57 -07:00
README.md PyPI release arcade-serve and arcade-tdk (#432) 2025-06-13 13:06:11 -07:00

Arcade Core

Core library for the Arcade platform providing foundational components and utilities.

Overview

Arcade Core provides the essential building blocks for the Arcade platform:

  • Tool Catalog & Toolkit Management: Core classes for managing and organizing tools
  • Configuration & Schema Handling: Configuration management and validation
  • Authentication & Authorization: Auth providers and security utilities
  • Error Handling: Comprehensive error types and handling
  • Telemetry & Observability: Monitoring and tracing capabilities
  • Utilities: Common helper functions and validators

Installation

pip install arcade-core

Usage

  1. Install an arcade toolkit
pip install arcade-math
  1. Load the toolkit
import arcade_math
from arcade_core import ToolCatalog, Toolkit

# Create a tool catalog
catalog = ToolCatalog()

# Load a toolkit
toolkit = Toolkit.from_module(arcade_math)

License

MIT License - see LICENSE file for details.