File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121from mcp .server .fastmcp import server
2222from mcp .server .fastmcp .server import FastMCP , Settings
2323from mcp .server .fastmcp .tools .base import Tool as MCPTool
24+ from pydantic_settings import SettingsConfigDict
2425from sensai .util import logging
2526from sensai .util .helper import mark_used
2627
@@ -271,6 +272,12 @@ async def monitor_global_shutdown() -> None:
271272 signal .signal (signal .SIGINT , sigint_singal )
272273 signal .signal (signal .SIGTERM , sigterm_signal )
273274
275+
276+ # Override model_config to disable the use of `.env` files for reading settings, because user projects are likely to contain
277+ # `.env` files (e.g. containing LOG_LEVEL) that are not supposed to override the MCP settings;
278+ # retain only FASTMCP_ prefix for already set environment variables.
279+ Settings .model_config = SettingsConfigDict (env_prefix = "FASTMCP_" )
280+
274281 mcp_settings = Settings (lifespan = server_lifespan , host = host , port = port )
275282 mcp = FastMCP (** mcp_settings .model_dump ())
276283 return mcp , serena_agent_process
You can’t perform that action at this time.
0 commit comments