Skip to content

dashboard

dashboard

Dashboard and MCP server commands for Marianne CLI.

This module implements server commands for external integrations: - dashboard: Start the web dashboard for job monitoring - mcp: Start the Model Context Protocol server for AI agent access

★ Insight ───────────────────────────────────── 1. Lazy imports for optional dependencies: The dashboard command only imports uvicorn when executed, not at module load time. This allows the CLI to work even when uvicorn isn't installed, deferring the error until the user tries to use the feature. This is a common pattern for optional dependencies.

  1. State backend preference hierarchy: The dashboard prefers SQLite if a database file exists, falling back to JSON. This respects user choice while providing sensible defaults - SQLite offers better query performance for dashboards while JSON provides simplicity and human readability for debugging.

  2. MCP as external API surface: The MCP server exposes Marianne's capabilities to external AI agents using a standardized protocol. This transforms Marianne from a standalone CLI into an API-accessible service that other AI systems can invoke. ─────────────────────────────────────────────────

Functions

dashboard

dashboard(port=Option(8000, '--port', '-p', help='Port to run dashboard on'), host=Option('127.0.0.1', '--host', help='Host to bind to'), workspace=Option(None, '--workspace', '-w', help='Workspace directory for job state (defaults to current directory)'), reload=Option(False, '--reload', '-r', help='Enable auto-reload for development'))

Start the web dashboard.

Launches the Marianne dashboard API server for job monitoring and control. The API provides endpoints for listing, viewing, and managing jobs.

Examples:

mzt dashboard # Start on localhost:8000 mzt dashboard --port 3000 # Custom port mzt dashboard --host 0.0.0.0 # Allow external connections mzt dashboard --workspace ./jobs # Use specific state directory

Source code in src/marianne/cli/commands/dashboard.py
def dashboard(
    port: int = typer.Option(8000, "--port", "-p", help="Port to run dashboard on"),
    host: str = typer.Option("127.0.0.1", "--host", help="Host to bind to"),
    workspace: Path | None = typer.Option(
        None,
        "--workspace",
        "-w",
        help="Workspace directory for job state (defaults to current directory)",
    ),
    reload: bool = typer.Option(
        False,
        "--reload",
        "-r",
        help="Enable auto-reload for development",
    ),
) -> None:
    """Start the web dashboard.

    Launches the Marianne dashboard API server for job monitoring and control.
    The API provides endpoints for listing, viewing, and managing jobs.

    Examples:
        mzt dashboard                    # Start on localhost:8000
        mzt dashboard --port 3000        # Custom port
        mzt dashboard --host 0.0.0.0     # Allow external connections
        mzt dashboard --workspace ./jobs # Use specific state directory
    """
    try:
        import uvicorn
    except ImportError:
        console.print(
            "[red]Error:[/red] uvicorn is required for the dashboard.\n"
            "Install it with: pip install uvicorn"
        )
        raise typer.Exit(1) from None

    from marianne.dashboard import create_app

    fastapi_app = create_app(
        title="Marianne Dashboard",
        version=__version__,
    )

    # Display startup info
    console.print(
        Panel(
            f"[bold]Marianne Dashboard[/bold]\n\n"
            f"API: http://{host}:{port}\n"
            f"Docs: http://{host}:{port}/docs\n"
            f"OpenAPI: http://{host}:{port}/openapi.json\n\n"
            f"[dim]Press Ctrl+C to stop[/dim]",
            title="Starting Server",
        )
    )

    # Run the server
    try:
        uvicorn.run(
            fastapi_app,
            host=host,
            port=port,
            reload=reload,
            log_level="info",
        )
    except KeyboardInterrupt:
        console.print("\n[yellow]Dashboard stopped.[/yellow]")

mcp

mcp(port=Option(8001, '--port', '-p', help='Port to run MCP server on'), host=Option('127.0.0.1', '--host', help='Host to bind to'), workspace=Option(None, '--workspace', '-w', help='Workspace directory for job operations (defaults to current directory)'))

Start the Marianne MCP (Model Context Protocol) server.

Launches an MCP server that exposes Marianne's job management capabilities as tools for external AI agents. The server provides:

  • Job management tools (run, status, pause, resume, cancel)
  • Artifact browsing and log streaming
  • Configuration access as resources

Security: All tool executions require explicit user consent. File system access is restricted to designated workspace directories.

Examples:

mzt mcp # Start on localhost:8001 mzt mcp --port 8002 # Custom port mzt mcp --workspace ./projects # Use specific workspace root

Source code in src/marianne/cli/commands/dashboard.py
def mcp(
    port: int = typer.Option(8001, "--port", "-p", help="Port to run MCP server on"),
    host: str = typer.Option("127.0.0.1", "--host", help="Host to bind to"),
    workspace: Path | None = typer.Option(
        None,
        "--workspace",
        "-w",
        help="Workspace directory for job operations (defaults to current directory)",
    ),
) -> None:
    """Start the Marianne MCP (Model Context Protocol) server.

    Launches an MCP server that exposes Marianne's job management capabilities
    as tools for external AI agents. The server provides:

    - Job management tools (run, status, pause, resume, cancel)
    - Artifact browsing and log streaming
    - Configuration access as resources

    Security: All tool executions require explicit user consent.
    File system access is restricted to designated workspace directories.

    Examples:
        mzt mcp                          # Start on localhost:8001
        mzt mcp --port 8002              # Custom port
        mzt mcp --workspace ./projects   # Use specific workspace root
    """
    try:
        asyncio.run(_run_mcp_server(host, port, workspace))
    except KeyboardInterrupt:
        console.print("\n[yellow]MCP Server stopped.[/yellow]")