Skip to content

fix(adapters/langgraph): tolerate nested schema titles in MCP tool schemas#21

Merged
spichen merged 1 commit into
oi-forkfrom
fix/mcp-nested-schema-titles
Jul 3, 2026
Merged

fix(adapters/langgraph): tolerate nested schema titles in MCP tool schemas#21
spichen merged 1 commit into
oi-forkfrom
fix/mcp-nested-schema-titles

Conversation

@spichen

@spichen spichen commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Problem

Attaching an MCP toolbox whose server ships OpenAPI-derived tool schemas (e.g. the Notion MCP server) kills every agent run with:

ValidationError: 1 validation error for Property
  Value error, Titles of properties should not contain special characters or blank space. Found: 'Rich Text'

_get_or_create_langgraph_mcp_tools builds an on-the-fly MCPTool (only used to back the tracing callback) with Property(title=arg_name, json_schema=arg_json_schema) from the server's raw schemas. Property's validator recursively rejects any nested title containing spaces/special characters, so a schema like Notion's children argument (nested "title": "Rich Text") fails the whole run at the model step.

Fix

Strip title annotations from the arg schema before constructing the tracing Property. The traversal mirrors exactly the positions the validator visits (items, anyOf, additionalProperties, properties values) - a generic recursive strip would corrupt non-schema payloads such as default/examples values containing a title key. The LLM-facing args_schema on the langchain tool is untouched, and the port name is passed explicitly as title=, so nothing behavioral changes for tool calling.

Tests

  • test_strip_schema_titles_removes_only_schema_title_annotations - helper unit test incl. a property literally named title and a default payload that must survive.
  • test_mcp_toolbox_tolerates_openapi_style_nested_schema_titles - toolbox conversion with a Notion-shaped tool schema; fails with the exact production error without the fix.

tests/adapters/langgraph/mcp/ passes (1 pre-existing local-server fixture failure unrelated to this change, fails on base commit too); tests/test_properties.py 176 passed.

…hemas

MCP servers commonly derive tool schemas from OpenAPI documents whose
nested schemas carry human-readable titles (e.g. Notion's "Rich Text").
The on-the-fly MCPTool built for the tracing callback fed those raw
schemas into Property, whose title validation rejects any title with
spaces or special characters, failing the whole agent run before the
model was ever invoked.

Strip title annotations from the arg schema before building the tracing
Property, visiting exactly the positions the validator traverses (items,
anyOf, additionalProperties, properties values) so non-schema payloads
like default values are left intact. The LLM-facing args_schema is
untouched.
@spichen spichen merged commit 08f4ebd into oi-fork Jul 3, 2026
0 of 5 checks passed
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.

1 participant