feat: add theme field to Icon type for light/dark mode support #1978
+8
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add
IconThemetype alias andthemefield to theIconclass for parity with the 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.Changes
IconTheme = Literal["light", "dark"]type aliasthemefield toIconclassIconThemefrommcp.typesGo SDK Reference
The Go SDK already implements this feature:
Source: https://github.com/modelcontextprotocol/go-sdk/blob/main/mcp/protocol.go
Use Case
MCP servers like GitHub MCP Server provide both light and dark variants of their icons. Without the
themefield, Python SDK servers cannot express this distinction, limiting their ability to integrate well with themed client UIs.Testing
from mcp.types import Icon, IconThemeruff checkCloses #1977