fix: env-file loading (#5918)
* fix: premature execution of MCP router logic * style: remove comment * chore: move import statement inside the condition * fix: mypy error valid-type
This commit is contained in:
parent
0d11564dea
commit
5c64e5997a
4 changed files with 13 additions and 8 deletions
|
|
@ -9,7 +9,6 @@ from langflow.api.v1 import (
|
|||
flows_router,
|
||||
folders_router,
|
||||
login_router,
|
||||
mcp_router,
|
||||
monitor_router,
|
||||
starter_projects_router,
|
||||
store_router,
|
||||
|
|
@ -17,7 +16,6 @@ from langflow.api.v1 import (
|
|||
validate_router,
|
||||
variables_router,
|
||||
)
|
||||
from langflow.services.deps import get_settings_service
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/api/v1",
|
||||
|
|
@ -35,6 +33,3 @@ router.include_router(files_router)
|
|||
router.include_router(monitor_router)
|
||||
router.include_router(folders_router)
|
||||
router.include_router(starter_projects_router)
|
||||
|
||||
if get_settings_service().settings.mcp_server_enabled:
|
||||
router.include_router(mcp_router)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ if False:
|
|||
|
||||
logger.debug("MCP module loaded - debug logging enabled")
|
||||
|
||||
enable_progress_notifications = get_settings_service().settings.mcp_server_enable_progress_notifications
|
||||
|
||||
router = APIRouter(prefix="/mcp", tags=["mcp"])
|
||||
|
||||
|
|
@ -58,6 +57,10 @@ current_user_ctx: ContextVar[User] = ContextVar("current_user_ctx")
|
|||
MAX_RETRIES = 2
|
||||
|
||||
|
||||
def get_enable_progress_notifications() -> bool:
|
||||
return get_settings_service().settings.mcp_server_enable_progress_notifications
|
||||
|
||||
|
||||
@server.list_prompts()
|
||||
async def handle_list_prompts():
|
||||
return []
|
||||
|
|
@ -175,7 +178,9 @@ async def handle_list_tools():
|
|||
|
||||
|
||||
@server.call_tool()
|
||||
async def handle_call_tool(name: str, arguments: dict) -> list[types.TextContent]:
|
||||
async def handle_call_tool(
|
||||
name: str, arguments: dict, *, enable_progress_notifications: bool = Depends(get_enable_progress_notifications)
|
||||
) -> list[types.TextContent]:
|
||||
"""Handle tool execution requests."""
|
||||
try:
|
||||
session = await anext(get_session())
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class RunFlowComponent(RunFlowBaseComponent):
|
|||
if node not in tweaks:
|
||||
tweaks[node] = {}
|
||||
tweaks[node][name] = self._attributes[field]
|
||||
# import pdb; pdb.set_trace()
|
||||
|
||||
return await run_flow(
|
||||
inputs=None,
|
||||
output_type="all",
|
||||
|
|
|
|||
|
|
@ -233,6 +233,11 @@ def create_app():
|
|||
|
||||
start_http_server(settings.prometheus_port)
|
||||
|
||||
if settings.mcp_server_enabled:
|
||||
from langflow.api.v1 import mcp_router
|
||||
|
||||
router.include_router(mcp_router)
|
||||
|
||||
app.include_router(router)
|
||||
app.include_router(health_check_router)
|
||||
app.include_router(log_router)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue