Skip to content

Commit d028efb

Browse files
committed
Add icon documentation to README
1 parent 883d2b4 commit d028efb

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,42 @@ def debug_error(error: str) -> list[base.Message]:
515515
_Full example: [examples/snippets/servers/basic_prompt.py](https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/snippets/servers/basic_prompt.py)_
516516
<!-- /snippet-source -->
517517

518+
### Icons
519+
520+
MCP servers can provide icons for UI display. Icons can be added to the server implementation, tools, resources, and prompts:
521+
522+
```python
523+
from mcp.server.fastmcp import FastMCP
524+
from mcp.types import Icon
525+
526+
# Create an icon from a file path or URL
527+
icon = Icon(
528+
src="icon.png",
529+
mimeType="image/png",
530+
sizes="64x64"
531+
)
532+
533+
# Add icons to server
534+
mcp = FastMCP(
535+
"My Server",
536+
website_url="https://example.com",
537+
icons=[icon]
538+
)
539+
540+
# Add icons to tools, resources, and prompts
541+
@mcp.tool(icons=[icon])
542+
def my_tool():
543+
"""Tool with an icon."""
544+
return "result"
545+
546+
@mcp.resource("demo://resource", icons=[icon])
547+
def my_resource():
548+
"""Resource with an icon."""
549+
return "content"
550+
```
551+
552+
_Full example: [examples/fastmcp/icons_demo.py](https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/fastmcp/icons_demo.py)_
553+
518554
### Images
519555

520556
FastMCP provides an `Image` class that automatically handles image data:
@@ -895,6 +931,8 @@ The FastMCP server instance accessible via `ctx.fastmcp` provides access to serv
895931

896932
- `ctx.fastmcp.name` - The server's name as defined during initialization
897933
- `ctx.fastmcp.instructions` - Server instructions/description provided to clients
934+
- `ctx.fastmcp.website_url` - Optional website URL for the server
935+
- `ctx.fastmcp.icons` - Optional list of icons for UI display
898936
- `ctx.fastmcp.settings` - Complete server configuration object containing:
899937
- `debug` - Debug mode flag
900938
- `log_level` - Current logging level

0 commit comments

Comments
 (0)