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: add letta code source mcp redirect (#8865)

jnjpng8792e88e8b88
diff --git a/letta/services/mcp_manager.py b/letta/services/mcp_manager.py
index 2167882a5..173c909e1 100644
--- a/letta/services/mcp_manager.py
+++ b/letta/services/mcp_manager.py
@@ -1127,11 +1127,14 @@ class MCPManager:
and http_request.headers.__contains__("x-organization-id")
)
+ # Check if request is from letta-code CLI (uses web callback for OAuth)
+ is_letta_code_request = http_request and http_request.headers and http_request.headers.get("x-letta-source", "") == "letta-code"
+
logo_uri = None
NEXT_PUBLIC_CURRENT_HOST = os.getenv("NEXT_PUBLIC_CURRENT_HOST")
LETTA_AGENTS_ENDPOINT = os.getenv("LETTA_AGENTS_ENDPOINT")
- if is_web_request and NEXT_PUBLIC_CURRENT_HOST:
+ if (is_web_request or is_letta_code_request) and NEXT_PUBLIC_CURRENT_HOST:
# Use static callback URI - session is identified via state parameter
redirect_uri = f"{NEXT_PUBLIC_CURRENT_HOST}/oauth/callback/mcp"
logo_uri = f"{NEXT_PUBLIC_CURRENT_HOST}/seo/favicon.svg"
diff --git a/letta/services/mcp_server_manager.py b/letta/services/mcp_server_manager.py
index fcf6ed187..8bd8534d1 100644
--- a/letta/services/mcp_server_manager.py
+++ b/letta/services/mcp_server_manager.py
@@ -1323,11 +1323,14 @@ class MCPServerManager:
and http_request.headers.__contains__("x-organization-id")
)
+ # Check if request is from letta-code CLI (uses web callback for OAuth)
+ is_letta_code_request = http_request and http_request.headers and http_request.headers.get("x-letta-source", "") == "letta-code"
+
logo_uri = None
NEXT_PUBLIC_CURRENT_HOST = os.getenv("NEXT_PUBLIC_CURRENT_HOST")
LETTA_AGENTS_ENDPOINT = os.getenv("LETTA_AGENTS_ENDPOINT")
- if is_web_request and NEXT_PUBLIC_CURRENT_HOST:
+ if (is_web_request or is_letta_code_request) and NEXT_PUBLIC_CURRENT_HOST:
# Use static callback URI - session is identified via state parameter
redirect_uri = f"{NEXT_PUBLIC_CURRENT_HOST}/oauth/callback/mcp"
logo_uri = f"{NEXT_PUBLIC_CURRENT_HOST}/seo/favicon.svg"