Add icons support for ResourceTemplate (#1412)
Some checks failed
Main branch checks / checks (push) Has been cancelled
Some checks failed
Main branch checks / checks (push) Has been cancelled
This commit is contained in:
parent
f676f6c0f0
commit
3e798bfc01
1 changed files with 28 additions and 2 deletions
|
|
@ -39,6 +39,12 @@ async def test_icons_and_website_url():
|
|||
"""A test prompt with an icon."""
|
||||
return text
|
||||
|
||||
# Create resource template with icon
|
||||
@mcp.resource("test://weather/{city}", icons=[test_icon])
|
||||
def test_resource_template(city: str) -> str:
|
||||
"""Get weather for a city."""
|
||||
return f"Weather for {city}"
|
||||
|
||||
# Test server metadata includes websiteUrl and icons
|
||||
assert mcp.name == "TestServer"
|
||||
assert mcp.website_url == "https://example.com"
|
||||
|
|
@ -75,6 +81,16 @@ async def test_icons_and_website_url():
|
|||
assert len(prompt.icons) == 1
|
||||
assert prompt.icons[0].src == test_icon.src
|
||||
|
||||
# Test resource template includes icon
|
||||
templates = await mcp.list_resource_templates()
|
||||
assert len(templates) == 1
|
||||
template = templates[0]
|
||||
assert template.name == "test_resource_template"
|
||||
assert template.uriTemplate == "test://weather/{city}"
|
||||
assert template.icons is not None
|
||||
assert len(template.icons) == 1
|
||||
assert template.icons[0].src == test_icon.src
|
||||
|
||||
|
||||
async def test_multiple_icons():
|
||||
"""Test that multiple icons can be added to tools, resources, and prompts."""
|
||||
|
|
|
|||
Loading…
Reference in a new issue