Skip to content

normalize_mcp_schema should add missing 'properties' field for object schemas #3145

@BTForIT

Description

@BTForIT

Description

When importing MCP tools, schemas with {"type": "object"} but no properties field fail validation. The normalize_mcp_schema function should add properties: {} when missing.

Current Behavior

MCP servers may return tool schemas like:

{"type": "object"}

This causes the error:

Failed to auto-sync tools from MCP server mcpjungle-remote: {'type': 'object', 'additionalProperties': False}. 
Server was created successfully but tools were not persisted.

Expected Behavior

normalize_mcp_schema should normalize this to:

{"type": "object", "properties": {}, "additionalProperties": false}

Root Cause

The issue originates from a bug in mcp-go library where empty properties gets dropped during JSON serialization. However, Letta's normalization could easily handle this case.

Suggested Fix

In letta/functions/schema_generator.py, add to normalize_mcp_schema:

def normalize_mcp_schema(schema: Dict[str, Any]) -> Dict[str, Any]:
    # Add empty properties if missing for object types
    if schema.get("type") == "object" and "properties" not in schema:
        schema["properties"] = {}
    
    # ... existing normalization logic

Impact

This affects any MCP server that returns tools with no parameters, causing them to fail import even though they're valid tools.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions