From 60a0a5264de14e8407edbe4357bf7360b054b76f Mon Sep 17 00:00:00 2001 From: jnjpng Date: Wed, 30 Jul 2025 11:02:21 -0700 Subject: [PATCH] fix: oauth prod environment variables Co-authored-by: Jin Peng --- letta/server/rest_api/routers/v1/tools.py | 12 ++++++++---- letta/settings.py | 4 ---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/letta/server/rest_api/routers/v1/tools.py b/letta/server/rest_api/routers/v1/tools.py index d2f8de46..b7c16159 100644 --- a/letta/server/rest_api/routers/v1/tools.py +++ b/letta/server/rest_api/routers/v1/tools.py @@ -1,5 +1,6 @@ import asyncio import json +import os from collections.abc import AsyncGenerator from typing import Any, Dict, List, Optional, Union @@ -40,7 +41,7 @@ from letta.server.server import SyncServer from letta.services.mcp.oauth_utils import MCPOAuthSession, create_oauth_provider, drill_down_exception, oauth_stream_event from letta.services.mcp.stdio_client import AsyncStdioMCPClient from letta.services.mcp.types import OauthStreamEvent -from letta.settings import settings, tool_settings +from letta.settings import tool_settings router = APIRouter(prefix="/tools", tags=["tools"]) @@ -754,7 +755,7 @@ async def connect_mcp_server( oauth_session = await server.mcp_manager.create_oauth_session(session_create, actor) session_id = oauth_session.id - # TODO: @jnjpng make this check more robust + # TODO: @jnjpng make this check more robust and remove direct os.getenv # Check if request is from web frontend to determine redirect URI is_web_request = ( http_request @@ -764,8 +765,8 @@ async def connect_mcp_server( ) logo_uri = None - NEXT_PUBLIC_CURRENT_HOST = settings.next_public_current_host - LETTA_AGENTS_ENDPOINT = settings.letta_agents_endpoint + 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: redirect_uri = f"{NEXT_PUBLIC_CURRENT_HOST}/oauth/callback/{session_id}" @@ -774,6 +775,9 @@ async def connect_mcp_server( # API and SDK usage should call core server directly redirect_uri = f"{LETTA_AGENTS_ENDPOINT}/v1/tools/mcp/oauth/callback/{session_id}" else: + logger.error( + f"No redirect URI found for request and base urls: {http_request} {NEXT_PUBLIC_CURRENT_HOST} {LETTA_AGENTS_ENDPOINT}" + ) raise HTTPException(status_code=400, detail="No redirect URI found") # Create OAuth provider for the instance of the stream connection diff --git a/letta/settings.py b/letta/settings.py index e34db63f..df842d7e 100644 --- a/letta/settings.py +++ b/letta/settings.py @@ -271,10 +271,6 @@ class Settings(BaseSettings): # for OCR mistral_api_key: Optional[str] = None - # OAuth redirect URLs - letta_agents_endpoint: Optional[str] = os.getenv("LETTA_AGENTS_ENDPOINT") - next_public_current_host: Optional[str] = os.getenv("NEXT_PUBLIC_CURRENT_HOST") - # LLM request timeout settings (model + embedding model) llm_request_timeout_seconds: float = Field(default=60.0, ge=10.0, le=1800.0, description="Timeout for LLM requests in seconds") llm_stream_timeout_seconds: float = Field(default=60.0, ge=10.0, le=1800.0, description="Timeout for LLM streaming requests in seconds")