Skip to content

datarobot_genai.drmcp.core.dr_mcp_server_logo

log_server_custom_banner

log_server_custom_banner(server: FastMCP[Any], transport: str, *, host: str | None = None, port: int | None = None, path: str | None = None, tools_count: int | None = None, prompts_count: int | None = None, resources_count: int | None = None) -> None

Create and log a formatted banner with server information and logo.

Parameters:

Name Type Description Default
server FastMCP[Any]

The FastMCP server instance

required
transport str

The transport protocol being used

required
host str | None

Host address (for HTTP transports)

None
port int | None

Port number (for HTTP transports)

None
path str | None

Server path (for HTTP transports)

None
tools_count int | None

Number of tools registered

None
prompts_count int | None

Number of prompts registered

None
resources_count int | None

Number of resources registered

None
Source code in datarobot_genai/drmcp/core/dr_mcp_server_logo.py
def log_server_custom_banner(
    server: FastMCP[Any],
    transport: str,
    *,
    host: str | None = None,
    port: int | None = None,
    path: str | None = None,
    tools_count: int | None = None,
    prompts_count: int | None = None,
    resources_count: int | None = None,
) -> None:
    """
    Create and log a formatted banner with server information and logo.

    Args:
        server: The FastMCP server instance
        transport: The transport protocol being used
        host: Host address (for HTTP transports)
        port: Port number (for HTTP transports)
        path: Server path (for HTTP transports)
        tools_count: Number of tools registered
        prompts_count: Number of prompts registered
        resources_count: Number of resources registered
    """
    # Create the logo text
    # Use Text with no_wrap and markup disabled to preserve ANSI escape codes
    logo_text = Text.from_ansi(DR_LOGO_ASCII, no_wrap=True)

    # Create the main title
    title_text = Text(f"DataRobot MCP Server {datarobot_genai_version}", style="dim green")
    stats_text = Text(
        f"{tools_count} tools, {prompts_count} prompts, {resources_count} resources",
        style="bold green",
    )

    # Create the information table
    info_table = Table.grid(padding=(0, 1))
    info_table.add_column(style="bold", justify="center")  # Emoji column
    info_table.add_column(style="cyan", justify="left")  # Label column
    info_table.add_column(style="dim", justify="left")  # Value column

    match transport:
        case "http" | "streamable-http":
            display_transport = "HTTP"
        case "sse":
            display_transport = "SSE"
        case "stdio":
            display_transport = "STDIO"

    info_table.add_row("🖥", "Server name:", Text(server.name + "\n", style="bold blue"))
    info_table.add_row("📦", "Transport:", display_transport)
    info_table.add_row("🌐", "MCP port:", str(port))

    # Show connection info based on transport
    if transport in ("http", "streamable-http", "sse") and host and port:
        server_url = f"http://{host}:{port}"
        if path:
            server_url += f"/{path.lstrip('/')}"
        info_table.add_row("🔗", "Server URL:", server_url)

    # Add documentation link
    info_table.add_row("", "", "")
    info_table.add_row("📚", "Docs:", "https://docs.datarobot.com")
    info_table.add_row("🚀", "Hosting:", "https://datarobot.com")

    # Create panel with logo, title, and information using Group
    panel_content = Group(
        Align.center(logo_text),
        "",
        Align.center(title_text),
        Align.center(stats_text),
        "",
        "",
        Align.center(info_table),
    )

    panel = Panel(
        panel_content,
        border_style="dim",
        padding=(1, 4),
        # expand=False,
        width=80,  # Set max width for the pane
    )

    console = Console(stderr=True)
    # Center the panel itself
    console.print(Group("\n", Align.center(panel), "\n"))