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
- Add
IconTheme = Literal["light", "dark"] to fastmcp.utilities.types (with forward-compatible import from mcp.types when available)
- Export
IconTheme from fastmcp
- Update icon documentation to cover the
theme field
- Add tests for icon theme support
Summary
Add
IconThemetype alias and document thethemefield onIconfor 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
themefield on theIcontype (see schema). Sincemcp.types.Iconusesextra='allow', thethemefield already works at runtime when passed as a kwarg. However, there's noIconThemetype 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):
Go SDK Reference
The Go SDK already implements this:
Use Case
MCP servers like GitHub MCP Server provide both light and dark variants of their icons. Without
IconThemeexported from FastMCP, users lack type safety when specifying icon themes.Proposed Changes
IconTheme = Literal["light", "dark"]tofastmcp.utilities.types(with forward-compatible import frommcp.typeswhen available)IconThemefromfastmcpthemefield