Skip to content

Add theme field to Icon type for light/dark mode support #1977

@gfortaine

Description

@gfortaine

Summary

The Python SDK's Icon type is missing the theme field that exists in the Go SDK. This field allows servers to specify whether an icon is designed for a light or dark background, enabling clients to select the appropriate icon based on their UI theme.

Go SDK Reference

The Go SDK already implements this feature:

// IconTheme specifies the theme an icon is designed for.
type IconTheme string

const (
    // IconThemeLight indicates the icon is designed for a light background.
    IconThemeLight IconTheme = "light"
    // IconThemeDark indicates the icon is designed for a dark background.
    IconThemeDark IconTheme = "dark"
)

type Icon struct {
    Source   string    `json:"src"`
    MIMEType string    `json:"mimeType,omitempty"`
    Sizes    []string  `json:"sizes,omitempty"`
    // Optional theme specifier. "light" indicates the icon is designed for a light
    // background, "dark" indicates the icon is designed for a dark background.
    Theme    IconTheme `json:"theme,omitempty"`
}

Source: https://github.com/modelcontextprotocol/go-sdk/blob/main/mcp/protocol.go

Current Python SDK Implementation

class Icon(MCPModel):
    """An icon for display in user interfaces."""

    src: str
    """URL or data URI for the icon."""

    mime_type: str | None = None
    """Optional MIME type for the icon."""

    sizes: list[str] | None = None
    """Optional list of strings specifying icon dimensions."""

Proposed Change

Add the theme field to the Icon class:

IconTheme = Literal["light", "dark"]

class Icon(MCPModel):
    """An icon for display in user interfaces."""

    src: str
    """URL or data URI for the icon."""

    mime_type: str | None = None
    """Optional MIME type for the icon."""

    sizes: list[str] | None = None
    """Optional list of strings specifying icon dimensions."""

    theme: IconTheme | None = None
    """Optional theme specifier. 'light' indicates the icon is designed for a light
    background, 'dark' indicates the icon is designed for a dark background."""

Use Case

MCP servers like GitHub MCP Server provide both light and dark variants of their icons. Without the theme field, Python SDK servers cannot express this distinction, limiting their ability to integrate well with themed client UIs.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions