Skip to content

feat: add IconTheme type for light/dark mode icon support #3162

@gfortaine

Description

@gfortaine

Summary

Add IconTheme type alias and document the theme field on Icon for parity with the MCP Python SDK and Go SDK. This 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.

Background

The MCP specification supports a theme field on the Icon type (see schema). Since mcp.types.Icon uses extra='allow', the theme field already works at runtime when passed as a kwarg. However, there's no IconTheme type exported from FastMCP for type safety, and the docs don't mention theme support.

MCP Python SDK Reference

The MCP Python SDK recently added this (merged in modelcontextprotocol/python-sdk#1978):

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

class Icon(MCPModel):
    src: str
    mimeType: str | None = None
    sizes: list[str] | None = None
    theme: IconTheme | None = None

Go SDK Reference

The Go SDK already implements this:

type IconTheme string
const (
    IconThemeLight IconTheme = "light"
    IconThemeDark  IconTheme = "dark"
)

Use Case

MCP servers like GitHub MCP Server provide both light and dark variants of their icons. Without IconTheme exported from FastMCP, users lack type safety when specifying icon themes.

Proposed Changes

  1. Add IconTheme = Literal["light", "dark"] to fastmcp.utilities.types (with forward-compatible import from mcp.types when available)
  2. Export IconTheme from fastmcp
  3. Update icon documentation to cover the theme field
  4. Add tests for icon theme support

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprovement to existing functionality. For issues and smaller PR improvements.serverRelated to FastMCP server implementation or server-side functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions