docs: load media examples from disk instead of inline base64 (#3108)
This commit is contained in:
parent
ebcc4dc3fb
commit
3a6f2996cd
1 changed files with 108 additions and 50 deletions
|
|
@ -1,20 +1,15 @@
|
|||
from mcp_types import Icon
|
||||
from pathlib import Path
|
||||
|
||||
from mcp.server import MCPServer
|
||||
from mcp.server.mcpserver import Image
|
||||
|
||||
LOGO = Icon(src="https://example.com/brand-kit.png", mime_type="image/png", sizes=["48x48"])
|
||||
PALETTE = Icon(src="https://example.com/palette.svg", mime_type="image/svg+xml", sizes=["any"])
|
||||
mcp = MCPServer("Brand kit")
|
||||
|
||||
mcp = MCPServer("Brand kit", icons=[LOGO])
|
||||
LOGO_FILE = Path(__file__).parent / "logo.png"
|
||||
|
||||
|
||||
@mcp.tool(icons=[PALETTE])
|
||||
def palette() -> list[str]:
|
||||
"""The brand colour palette as hex codes."""
|
||||
return ["#1d4ed8", "#f59e0b", "#10b981"]
|
||||
|
||||
|
||||
@mcp.resource("brand://guidelines", icons=[LOGO])
|
||||
def guidelines() -> str:
|
||||
"""How to use the brand assets."""
|
||||
return "Use the primary colour for calls to action."
|
||||
@mcp.tool()
|
||||
def logo_from_bytes() -> Image:
|
||||
"""The brand logo as a PNG."""
|
||||
png = LOGO_FILE.read_bytes() # a database read, an HTTP response, Pillow output...
|
||||
return Image(data=png, format="png")
|
||||
|
|
|
|||
Loading…
Reference in a new issue