Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: add schema patching for mcp list tools (#5105)
Sarah Woodersaf2a28b1b1bb
diff --git a/letta/services/mcp_manager.py b/letta/services/mcp_manager.pyindex 67b1bf5e5..8790f9098 100644--- a/letta/services/mcp_manager.py+++ b/letta/services/mcp_manager.py@@ -18,6 +18,7 @@ from letta.functions.mcp_client.types import (StdioServerConfig,StreamableHTTPServerConfig,)+from letta.functions.schema_generator import normalize_mcp_schemafrom letta.functions.schema_validator import validate_complete_json_schemafrom letta.log import get_loggerfrom letta.orm.errors import NoResultFound@@ -72,7 +73,9 @@ class MCPManager:tools = await mcp_client.list_tools()# Add health information to each toolfor tool in tools:+ # Try to normalize the schema and re-validate\if tool.inputSchema:+ tool.inputSchema = normalize_mcp_schema(tool.inputSchema)health_status, reasons = validate_complete_json_schema(tool.inputSchema)tool.health = MCPToolHealth(status=health_status.value, reasons=reasons)@@ -146,9 +149,6 @@ class MCPManager:logger.info(f"Original health reasons: {mcp_tool.health.reasons}")# Try to normalize the schema and re-validate- from letta.functions.schema_generator import normalize_mcp_schema- from letta.functions.schema_validator import validate_complete_json_schema-try:# Normalize the schema to fix common issueslogger.debug(f"Normalizing schema for {mcp_tool_name}")