Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

feat: allow invalid schema tools to be attached with warning (#5341)

jnjpng5d153214c09b
diff --git a/letta/server/rest_api/routers/v1/tools.py b/letta/server/rest_api/routers/v1/tools.py
index 87dd85326..21dfcccb3 100644
--- a/letta/server/rest_api/routers/v1/tools.py
+++ b/letta/server/rest_api/routers/v1/tools.py
@@ -443,14 +443,11 @@ async def add_mcp_tool(
argument_name="mcp_tool_name",
)
- # Check tool health - reject only INVALID tools
- if mcp_tool.health:
- if mcp_tool.health.status == "INVALID":
- raise LettaInvalidMCPSchemaError(
- server_name=mcp_server_name,
- mcp_tool_name=mcp_tool_name,
- reasons=mcp_tool.health.reasons,
- )
+ # Log warning if tool has invalid schema but allow attachment
+ if mcp_tool.health and mcp_tool.health.status == "INVALID":
+ logger.warning(
+ f"Attaching MCP tool {mcp_tool_name} from server {mcp_server_name} with invalid schema. Reasons: {mcp_tool.health.reasons}"
+ )
tool_create = ToolCreate.from_mcp(mcp_server_name=mcp_server_name, mcp_tool=mcp_tool)
# For config-based servers, use the server name as ID since they don't have database IDs
diff --git a/letta/services/mcp_manager.py b/letta/services/mcp_manager.py
index c1e1fa10d..92e6a5d97 100644
--- a/letta/services/mcp_manager.py
+++ b/letta/services/mcp_manager.py
@@ -73,7 +73,7 @@ class MCPManager:
tools = await mcp_client.list_tools()
# Add health information to each tool
for tool in tools:
- # Try to normalize the schema and re-validate\
+ # 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)
@@ -174,10 +174,7 @@ class MCPManager:
# After normalization attempt, check if still INVALID
if mcp_tool.health and mcp_tool.health.status == "INVALID":
- raise ValueError(
- f"Tool {mcp_tool_name} cannot be attached, JSON schema is invalid even after normalization. "
- f"Reasons: {', '.join(mcp_tool.health.reasons)}"
- )
+ logger.warning(f"Tool {mcp_tool_name} has potentially invalid schema. Reasons: {', '.join(mcp_tool.health.reasons)}")
tool_create = ToolCreate.from_mcp(mcp_server_name=mcp_server_name, mcp_tool=mcp_tool)
return await self.tool_manager.create_mcp_tool_async(