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.

fix: patch MCP error for MCP tools that have no functions (#2041)

Charles Packer0d6261a02f74
diff --git a/letta/functions/schema_generator.py b/letta/functions/schema_generator.py
index 209394640..d26506302 100644
--- a/letta/functions/schema_generator.py
+++ b/letta/functions/schema_generator.py
@@ -466,9 +466,13 @@ def generate_tool_schema_for_mcp(
name = mcp_tool.name
description = mcp_tool.description
- assert "type" in parameters_schema
- assert "required" in parameters_schema
- assert "properties" in parameters_schema
+ assert "type" in parameters_schema, parameters_schema
+ assert "properties" in parameters_schema, parameters_schema
+ # assert "required" in parameters_schema, parameters_schema
+
+ # Zero-arg tools often omit "required" because nothing is required.
+ # Normalise so downstream code can treat it consistently.
+ parameters_schema.setdefault("required", [])
# Add the optional heartbeat parameter
if append_heartbeat:
diff --git a/letta/server/rest_api/app.py b/letta/server/rest_api/app.py
index f2d96bc1f..e786553df 100644
--- a/letta/server/rest_api/app.py
+++ b/letta/server/rest_api/app.py
@@ -184,11 +184,14 @@ def create_application() -> "FastAPI":
@app.exception_handler(Exception)
async def generic_error_handler(request: Request, exc: Exception):
# Log the actual error for debugging
- log.error(f"Unhandled error: {exc}", exc_info=True)
- print(f"Unhandled error: {exc}")
+ log.error(f"Unhandled error: {str(exc)}", exc_info=True)
+ print(f"Unhandled error: {str(exc)}")
+
+ import traceback
# Print the stack trace
- print(f"Stack trace: {exc}")
+ print(f"Stack trace: {traceback.format_exc()}")
+
if (os.getenv("SENTRY_DSN") is not None) and (os.getenv("SENTRY_DSN") != ""):
import sentry_sdk