MCPcopy Create free account
hub / github.com/AutoForgeAI/autoforge / update_devserver_config

Function update_devserver_config

server/routers/devserver.py:380–436  ·  view source on GitHub ↗

Update the dev server configuration for a project. Set custom_command to a string to override the auto-detected command. Set custom_command to null/None to clear the custom command and revert to using the auto-detected command. Args: project_name: Name of the project

(
    project_name: str,
    update: DevServerConfigUpdate,
)

Source from the content-addressed store, hash-verified

378
379@router.patch("/config", response_model=DevServerConfigResponse)
380async def update_devserver_config(
381 project_name: str,
382 update: DevServerConfigUpdate,
383) -> DevServerConfigResponse:
384 """
385 Update the dev server configuration for a project.
386
387 Set custom_command to a string to override the auto-detected command.
388 Set custom_command to null/None to clear the custom command and revert
389 to using the auto-detected command.
390
391 Args:
392 project_name: Name of the project
393 update: Configuration update containing the new custom_command
394
395 Returns:
396 Updated configuration details for the project's dev server
397 """
398 project_dir = get_project_dir(project_name)
399
400 # Update the custom command
401 if update.custom_command is None:
402 # Clear the custom command
403 try:
404 clear_dev_command(project_dir)
405 except ValueError as e:
406 raise HTTPException(status_code=400, detail=str(e))
407 else:
408 # Strict structural validation first (most specific errors)
409 try:
410 validate_custom_command_strict(update.custom_command)
411 except ValueError as e:
412 raise HTTPException(status_code=400, detail=str(e))
413
414 # Then validate against security allowlist
415 validate_dev_command(update.custom_command, project_dir)
416
417 # Set the custom command
418 try:
419 set_dev_command(project_dir, update.custom_command)
420 except ValueError as e:
421 raise HTTPException(status_code=400, detail=str(e))
422 except OSError as e:
423 raise HTTPException(
424 status_code=500,
425 detail=f"Failed to save configuration: {e}"
426 )
427
428 # Return updated config
429 config = get_project_config(project_dir)
430
431 return DevServerConfigResponse(
432 detected_type=config["detected_type"],
433 detected_command=config["detected_command"],
434 custom_command=config["custom_command"],
435 effective_command=config["effective_command"],
436 )

Callers

nothing calls this directly

Calls 7

get_project_dirFunction · 0.85
clear_dev_commandFunction · 0.85
validate_dev_commandFunction · 0.85
set_dev_commandFunction · 0.85
get_project_configFunction · 0.85

Tested by

no test coverage detected